[][src]Struct ssb_packetstream::PacketSink

pub struct PacketSink<W> { /* fields omitted */ }

#Examples

use futures::io::Cursor;
use futures::executor::block_on;
use futures::sink::SinkExt;
use ssb_packetstream::*;

let mut sink = PacketSink::new(Cursor::new(vec![0u8; 14]));
block_on(async {
    sink.send(Packet::new(IsStream::Yes,
                          IsEnd::No,
                          BodyType::Json,
                          123,
                          vec![1,2,3,4,5])).await;
    sink.close().await;
    let buf = sink.into_inner().into_inner();
    assert_eq!(&buf, &[0b0000_1010,   // flags
                       0, 0, 0, 5,    // body length
                       0, 0, 0, 123,  // packet id
                       1, 2, 3, 4, 5, // body
                       0, 0, 0, 0, 0, 0, 0, 0, 0]); // goodbye packet
});

Methods

impl<W> PacketSink<W>[src]

pub fn new(w: W) -> PacketSink<W>[src]

pub fn into_inner(self) -> W[src]

Trait Implementations

impl<W> Sink<Packet> for PacketSink<W> where
    W: AsyncWrite + Unpin + 'static, 
[src]

type Error = Error

The type of value produced by the sink when an error occurs.

Auto Trait Implementations

impl<W> !RefUnwindSafe for PacketSink<W>

impl<W> !Send for PacketSink<W>

impl<W> !Sync for PacketSink<W>

impl<W> Unpin for PacketSink<W> where
    W: Unpin

impl<W> !UnwindSafe for PacketSink<W>

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, Item> SinkExt<Item> for T where
    T: Sink<Item> + ?Sized
[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.