Struct fire_stream::client::Connection
source · pub struct Connection<P> { /* private fields */ }Expand description
A connection to a server
Implementations§
source§impl<P> Connection<P>
impl<P> Connection<P>
sourcepub fn new<S>(
byte_stream: S,
cfg: Config,
recon_strat: Option<ReconStrat<S>>
) -> Selfwhere
S: ByteStream,
P: Packet<PlainBytes> + Send + 'static,
P::Header: Send,
pub fn new<S>( byte_stream: S, cfg: Config, recon_strat: Option<ReconStrat<S>> ) -> Selfwhere S: ByteStream, P: Packet<PlainBytes> + Send + 'static, P::Header: Send,
Creates a new connection to a server with an existing stream
sourcepub fn new_encrypted<S>(
byte_stream: S,
cfg: Config,
recon_strat: Option<ReconStrat<S>>,
sign: PublicKey
) -> Selfwhere
S: ByteStream,
P: Packet<EncryptedBytes> + Send + 'static,
P::Header: Send,
Available on crate feature encrypted only.
pub fn new_encrypted<S>( byte_stream: S, cfg: Config, recon_strat: Option<ReconStrat<S>>, sign: PublicKey ) -> Selfwhere S: ByteStream, P: Packet<EncryptedBytes> + Send + 'static, P::Header: Send,
encrypted only.Creates a new connection to a server and encrypting all packets sent
sourcepub fn update_config(&self, cfg: Config)
pub fn update_config(&self, cfg: Config)
Update the connection configuration
sourcepub fn configurator(&self) -> Configurator<Config>
pub fn configurator(&self) -> Configurator<Config>
Get’s a Configurator which allows to configure this connection
without needing to have access to the connection
sourcepub async fn request(&self, packet: P) -> Result<P, RequestError>
pub async fn request(&self, packet: P) -> Result<P, RequestError>
Send a request waiting until a response is available or the connection closes
Errors
- Writing the packet failed
- Reading the response packet failed
- Io Error
sourcepub async fn request_sender(
&self,
packet: P
) -> Result<StreamSender<P>, RequestError>
pub async fn request_sender( &self, packet: P ) -> Result<StreamSender<P>, RequestError>
Create a new stream to send packets.
sourcepub async fn request_receiver(
&self,
packet: P
) -> Result<StreamReceiver<P>, RequestError>
pub async fn request_receiver( &self, packet: P ) -> Result<StreamReceiver<P>, RequestError>
Opens a new stream to listen to packets.
Auto Trait Implementations§
impl<P> !RefUnwindSafe for Connection<P>
impl<P> Send for Connection<P>where P: Send,
impl<P> Sync for Connection<P>where P: Send,
impl<P> Unpin for Connection<P>
impl<P> !UnwindSafe for Connection<P>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more