[−][src]Struct bgb_link::net::stream::BgbStream
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
Auto Trait Implementations
impl<T> RefUnwindSafe for BgbStream<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for BgbStream<T> where
T: Send,
T: Send,
impl<T> Sync for BgbStream<T> where
T: Sync,
T: Sync,
impl<T> Unpin for BgbStream<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for BgbStream<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,