Struct adnl::AdnlClient
source · pub struct AdnlClient<T: AsyncReadExt + AsyncWriteExt> { /* private fields */ }
Expand description
Abstraction over AdnlSender
and AdnlReceiver
to keep things simple
Implementations§
source§impl AdnlClient<TcpStream>
impl AdnlClient<TcpStream>
sourcepub async fn connect<P: AdnlPublicKey, A: ToSocketAddrs>(
ls_public: P,
ls_addr: A
) -> Result<AdnlClient<TcpStream>, AdnlError>
pub async fn connect<P: AdnlPublicKey, A: ToSocketAddrs>( ls_public: P, ls_addr: A ) -> Result<AdnlClient<TcpStream>, AdnlError>
Create ADNL client use random private key and random AES params
source§impl<T: AsyncReadExt + AsyncWriteExt + Unpin> AdnlClient<T>
impl<T: AsyncReadExt + AsyncWriteExt + Unpin> AdnlClient<T>
sourcepub async fn perform_handshake<P: AdnlPublicKey>(
transport: T,
handshake: &AdnlHandshake<P>
) -> Result<Self, AdnlError>
pub async fn perform_handshake<P: AdnlPublicKey>( transport: T, handshake: &AdnlHandshake<P> ) -> Result<Self, AdnlError>
Send handshake
over transport
and check that handshake was successful
sourcepub async fn send(&mut self, data: &mut [u8]) -> Result<(), AdnlError>
pub async fn send(&mut self, data: &mut [u8]) -> Result<(), AdnlError>
Send data
to another peer with random nonce
sourcepub async fn send_with_nonce(
&mut self,
data: &mut [u8],
nonce: &mut [u8; 32]
) -> Result<(), AdnlError>
pub async fn send_with_nonce( &mut self, data: &mut [u8], nonce: &mut [u8; 32] ) -> Result<(), AdnlError>
Send data
to another peer. Random nonce
must be provided to eliminate bit-flipping attacks.
sourcepub async fn receive<C: AsyncWriteExt + Unpin>(
&mut self,
consumer: &mut C
) -> Result<(), AdnlError>
pub async fn receive<C: AsyncWriteExt + Unpin>( &mut self, consumer: &mut C ) -> Result<(), AdnlError>
Receive data from another peer into consumer
which will process the data with
a BUFFER
size of 8192 bytes.
sourcepub async fn receive_with_buffer<C: AsyncWriteExt + Unpin, const BUFFER: usize>(
&mut self,
consumer: &mut C
) -> Result<(), AdnlError>
pub async fn receive_with_buffer<C: AsyncWriteExt + Unpin, const BUFFER: usize>( &mut self, consumer: &mut C ) -> Result<(), AdnlError>
Receive data from another peer into consumer
which will process the data. Set BUFFER
according to your memory requirements, recommended size is 8192 bytes.
Auto Trait Implementations§
impl<T> RefUnwindSafe for AdnlClient<T>where
T: RefUnwindSafe,
impl<T> Send for AdnlClient<T>where
T: Send,
impl<T> Sync for AdnlClient<T>where
T: Sync,
impl<T> Unpin for AdnlClient<T>where
T: Unpin,
impl<T> UnwindSafe for AdnlClient<T>where
T: UnwindSafe,
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