[][src]Struct hypercore_protocol::Protocol

pub struct Protocol<R, W> where
    R: AsyncRead + Send + Unpin + 'static,
    W: AsyncWrite + Send + Unpin + 'static, 
{ /* fields omitted */ }

A Protocol stream.

Implementations

impl<R, W> Protocol<R, W> where
    R: AsyncRead + Send + Unpin + 'static,
    W: AsyncWrite + Send + Unpin + 'static, 
[src]

pub fn new(reader: R, writer: W, options: ProtocolOptions) -> Self[src]

Create a new Protocol instance.

pub fn builder(is_initiator: bool) -> ProtocolBuilder[src]

Create a protocol builder.

pub fn is_initiator(&self) -> bool[src]

pub async fn loop_next<'_>(&'_ mut self) -> Result<Event>[src]

Wait for the next protocol event.

This function should be called in a loop until this returns an error.

pub fn remote_key(&self) -> Option<&[u8]>[src]

Get the peer's Noise public key.

Empty before the handshake completed.

pub fn destroy(&mut self, error: Error)[src]

Destroy the protocol instance with an error.

pub async fn open<'_>(&'_ mut self, key: Vec<u8>) -> Result<()>[src]

Open a new protocol channel.

Once the other side proofed that it also knows the key, the channel is emitted as Event::Channel on the protocol event stream.

pub fn release(self) -> (R, W)[src]

Stop the protocol and return the inner reader and writer.

pub fn into_stream(self) -> ProtocolStream<R, W>[src]

Convert the protocol into a Stream of Events.

pub fn control(&self) -> ControlTx[src]

Get a sender to send control events.

Auto Trait Implementations

impl<R, W> !RefUnwindSafe for Protocol<R, W>

impl<R, W> Send for Protocol<R, W>

impl<R, W> !Sync for Protocol<R, W>

impl<R, W> Unpin for Protocol<R, W>

impl<R, W> !UnwindSafe for Protocol<R, 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> Same<T> for T

type Output = T

Should always be Self

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,