WsStreamTrait

Trait WsStreamTrait 

Source
pub trait WsStreamTrait<E> {
    type Stream: Stream<Item = Result<Packet, StreamError<E>>> + Sink<Packet, Error = StreamError<E>> + Unpin + Sized;

    // Required method
    fn connect(
        url: &str,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Stream, E>> + '_>>;
}
Expand description

Trait of helper objects to connect bilibili websocket server.

This trait is used when constructing normal bililive streams or auto-retry bililive streams.

An implementation of WsStreamTrait takes in a ws server url and decodes the data into a stream of Packet with heartbeat auto-response mechanism implemented (see HeartbeatStream for details).

Required Associated Types§

Source

type Stream: Stream<Item = Result<Packet, StreamError<E>>> + Sink<Packet, Error = StreamError<E>> + Unpin + Sized

The returned stream type.

Required Methods§

Source

fn connect( url: &str, ) -> Pin<Box<dyn Future<Output = Result<Self::Stream, E>> + '_>>

Connect to bilibili websocket server.

§Errors

Returns an error when websocket connection fails.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§