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>

source

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>

source

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

source

pub async fn send(&mut self, data: &mut [u8]) -> Result<(), AdnlError>

Send data to another peer with random nonce

source

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.

source

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.

source

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V