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>>,
) -> Self
pub fn new<S>( byte_stream: S, cfg: Config, recon_strat: Option<ReconStrat<S>>, ) -> Self
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,
) -> Self
Available on crate feature encrypted
only.
pub fn new_encrypted<S>( byte_stream: S, cfg: Config, recon_strat: Option<ReconStrat<S>>, sign: PublicKey, ) -> Self
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> Freeze for Connection<P>
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