[][src]Struct memory_socket::MemorySocket

pub struct MemorySocket { /* fields omitted */ }

An in-memory stream between two local sockets.

A MemorySocket can either be created by connecting to an endpoint, via the connect method, or by accepting a connection from a listener. It can be read or written to using the Read and Write traits.

Examples

use std::io::{Read, Result, Write};
use memory_socket::MemorySocket;

let (mut socket_a, mut socket_b) = MemorySocket::new_pair();

socket_a.write_all(b"stormlight")?;
socket_a.flush()?;

let mut buf = [0; 10];
socket_b.read_exact(&mut buf)?;
assert_eq!(&buf, b"stormlight");

Implementations

impl MemorySocket[src]

pub fn new_pair() -> (Self, Self)[src]

Construct both sides of an in-memory socket.

Examples

use memory_socket::MemorySocket;

let (socket_a, socket_b) = MemorySocket::new_pair();

pub fn connect(port: u16) -> Result<MemorySocket>[src]

Create a new in-memory Socket connected to the specified port.

This function will create a new MemorySocket socket and attempt to connect it to the port provided.

Examples

use memory_socket::MemorySocket;

let socket = MemorySocket::connect(16)?;

Trait Implementations

impl AsyncRead for MemorySocket[src]

impl AsyncWrite for MemorySocket[src]

impl Read for MemorySocket[src]

impl Write for MemorySocket[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<R> AsyncReadExt for R where
    R: AsyncRead + ?Sized
[src]

impl<W> AsyncWriteExt for W where
    W: AsyncWrite + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.