[][src]Struct bgb_link::net::stream::BgbStream

pub struct BgbStream<T: Read + Write> { /* fields omitted */ }

Methods

impl<T: Read + Write> BgbStream<T>[src]

pub fn wrap(inner: T) -> BgbStream<T>[src]

Takes ownership of the given read/writer and uses it for communication.

For use over TCP, see connect.

pub fn read_raw(&mut self) -> Result<RawBgbCommand>[src]

Reads 8 bytes from the connection and interprets the raw command data.

pub fn read(&mut self) -> Result<TypedBgbCommand>[src]

Reads 8 bytes from the connection and interprets them as a command.

If the command is too malformed to interpret, returns an error of kind InvalidData.

pub fn write(&mut self, command: &impl BgbCommand) -> Result<()>[src]

Serializes the command to an 8-byte packet and writes it to the stream.

impl BgbStream<TcpStream>[src]

pub fn connect<A: ToSocketAddrs>(addr: A) -> Result<BgbStream<TcpStream>>[src]

Establishes a TCP connection to a listening socket over the BGB protocol.

This method also enables TCP_NODELAY, as recommended in the spec, and waits for the handshake to complete before returning. If the other party provides an invalid handshake, returns an error of kind InvalidData.

pub fn maybe_read_raw(&mut self) -> Result<Option<RawBgbCommand>>[src]

Uses TcpStream.peek to check if 8 bytes are available, and if so, reads them and interprets the raw data.

pub fn maybe_read(&mut self) -> Result<Option<TypedBgbCommand>>[src]

As read but for maybe_read_raw instead of read_raw.

Trait Implementations

impl<T: Debug + Read + Write> Debug for BgbStream<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for BgbStream<T> where
    T: RefUnwindSafe

impl<T> Send for BgbStream<T> where
    T: Send

impl<T> Sync for BgbStream<T> where
    T: Sync

impl<T> Unpin for BgbStream<T> where
    T: Unpin

impl<T> UnwindSafe for BgbStream<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?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.