pub struct Protocol<W> { /* private fields */ }live only.Expand description
The core live API protocol.
Implementations§
Source§impl<W> Protocol<W>where
W: AsyncWriteExt + Unpin,
impl<W> Protocol<W>where
W: AsyncWriteExt + Unpin,
Sourcepub fn new(sender: W) -> Self
pub fn new(sender: W) -> Self
Creates a new instance of the live API protocol that will send raw API messages
to sender.
Sourcepub async fn authenticate<R>(
&mut self,
recver: &mut R,
key: &ApiKey,
dataset: &str,
options: SessionOptions<'_>,
) -> Result<String>where
R: AsyncBufReadExt + Unpin,
pub async fn authenticate<R>(
&mut self,
recver: &mut R,
key: &ApiKey,
dataset: &str,
options: SessionOptions<'_>,
) -> Result<String>where
R: AsyncBufReadExt + Unpin,
Conducts CRAM authentication with the live gateway. Returns the session ID.
§Errors
This function returns an error if the gateway fails to respond or the authentication request is rejected.
§Cancel safety
This method is not cancellation safe. If this method is used in a
tokio::select! statement and another branch completes first, the
authentication may have been only partially sent, resulting in the gateway
rejecting the authentication and closing the connection.
Sourcepub async fn subscribe(&mut self, sub: &Subscription) -> Result<()>
pub async fn subscribe(&mut self, sub: &Subscription) -> Result<()>
Sends one or more subscription messages for sub depending on the number of symbols.
§Errors
This function returns an error if it’s unable to communicate with the gateway.
§Cancel safety
This method is not cancellation safe. If this method is used in a
tokio::select! statement and another branch completes first, the subscription
may have been partially sent, resulting in the gateway rejecting the
subscription, sending an error, and closing the connection.
Sourcepub async fn start_session(&mut self) -> Result<()>
pub async fn start_session(&mut self) -> Result<()>
Sends a start session message to the live gateway.
§Errors
This function returns an error if it’s unable to communicate with the gateway.
§Cancel safety
This method is not cancellation safe. If this method is used in a
tokio::select! statement and another branch completes first, the live
gateway may only receive a partial message, resulting in it sending an error and
closing the connection.
Sourcepub async fn shutdown(&mut self) -> Result<()>
pub async fn shutdown(&mut self) -> Result<()>
Shuts down the inner writer.
§Errors
This function returns an error if the shut down did not complete successfully.
Sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Consumes the protocol instance and returns the inner sender.