[][src]Struct tox_core::net_crypto::NetCrypto

pub struct NetCrypto { /* fields omitted */ }

Struct that manages crypto connections to friends and handles net crypto packets from both UDP and TCP connections.

Implementations

impl NetCrypto[src]

pub fn new(args: NetCryptoNewArgs) -> NetCrypto[src]

Create new NetCrypto object

pub async fn add_friend(&self, real_pk: PublicKey)[src]

Add a friend to accept incoming connections from him.

pub async fn remove_friend(&self, real_pk: PublicKey)[src]

Remove a friend to stop accepting incoming connections from him.

pub async fn add_connection(
    &self,
    peer_real_pk: PublicKey,
    peer_dht_pk: PublicKey
)
[src]

Add connection to a friend when its DHT PublicKey is known.

pub async fn kill_connection(
    &self,
    real_pk: PublicKey
) -> Result<(), KillConnectionError>
[src]

Kill a connection sending PACKET_ID_KILL packet and removing it from the connections list.

pub async fn set_friend_udp_addr(&self, real_pk: PublicKey, saddr: SocketAddr)[src]

Set friend's UDP IP address when it gets known.

pub async fn send_lossless(
    &self,
    real_pk: PublicKey,
    packet: Vec<u8>
) -> Result<(), SendLosslessPacketError>
[src]

Send lossless packet to a friend via established connection.

Handle CookieRequest packet received from UDP socket

Handle CookieRequest packet received from TCP socket

Handle CookieResponse and if it's correct change connection status to HandshakeSending.

Handle CookieResponse packet received from UDP socket

Handle CookieResponse packet received from TCP socket

pub async fn handle_crypto_handshake(
    &self,
    connection: &mut CryptoConnection,
    packet: &CryptoHandshake
) -> Result<(), HandlePacketError>
[src]

Handle CryptoHandshake and if it's correct change connection status to NotConfirmed.

pub async fn handle_udp_crypto_handshake(
    &self,
    packet: &CryptoHandshake,
    addr: SocketAddr
) -> Result<(), HandlePacketError>
[src]

Handle CryptoHandshake packet received from UDP socket

pub async fn handle_tcp_crypto_handshake(
    &self,
    packet: &CryptoHandshake,
    sender_pk: PublicKey
) -> Result<(), HandlePacketError>
[src]

Handle CryptoHandshake packet received from TCP socket

pub async fn handle_udp_crypto_data(
    &self,
    packet: &CryptoData,
    addr: SocketAddr
) -> Result<(), HandlePacketError>
[src]

Handle CryptoData packet received from UDP socket

pub async fn handle_tcp_crypto_data(
    &self,
    packet: &CryptoData,
    sender_pk: PublicKey
) -> Result<(), HandlePacketError>
[src]

Handle CryptoData packet received from TCP socket

pub async fn run(&self) -> Result<(), RunError>[src]

Run net_crypto periodical tasks. Result future will never be completed successfully.

pub async fn set_dht_pk_sink(
    &self,
    dht_pk_tx: UnboundedSender<(PublicKey, PublicKey)>
)
[src]

Set sink to send DHT PublicKey when it gets known.

pub async fn set_connection_status_sink(
    &self,
    connection_status_tx: UnboundedSender<(PublicKey, bool)>
)
[src]

Set sink to send a connection status when it becomes connected or disconnected.

pub async fn set_tcp_sink(&self, tcp_tx: Sender<(TcpDataPayload, PublicKey)>)[src]

Set sink for sending TCP packets via relays.

Trait Implementations

impl Clone for NetCrypto[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.