[−][src]Struct tox_core::net_crypto::NetCrypto
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]
&self,
peer_real_pk: PublicKey,
peer_dht_pk: PublicKey
)
Add connection to a friend when its DHT PublicKey
is known.
pub async fn kill_connection(
&self,
real_pk: PublicKey
) -> Result<(), KillConnectionError>
[src]
&self,
real_pk: PublicKey
) -> Result<(), KillConnectionError>
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]
&self,
real_pk: PublicKey,
packet: Vec<u8>
) -> Result<(), SendLosslessPacketError>
Send lossless packet to a friend via established connection.
pub async fn handle_udp_cookie_request(
&self,
packet: &CookieRequest,
addr: SocketAddr
) -> Result<(), HandlePacketError>
[src]
&self,
packet: &CookieRequest,
addr: SocketAddr
) -> Result<(), HandlePacketError>
Handle CookieRequest
packet received from UDP socket
pub async fn handle_tcp_cookie_request(
&self,
packet: &CookieRequest,
sender_pk: PublicKey
) -> Result<(), HandlePacketError>
[src]
&self,
packet: &CookieRequest,
sender_pk: PublicKey
) -> Result<(), HandlePacketError>
Handle CookieRequest
packet received from TCP socket
pub async fn handle_cookie_response(
&self,
connection: &mut CryptoConnection,
packet: &CookieResponse
) -> Result<(), HandlePacketError>
[src]
&self,
connection: &mut CryptoConnection,
packet: &CookieResponse
) -> Result<(), HandlePacketError>
Handle CookieResponse
and if it's correct change connection status to HandshakeSending
.
pub async fn handle_udp_cookie_response(
&self,
packet: &CookieResponse,
addr: SocketAddr
) -> Result<(), HandlePacketError>
[src]
&self,
packet: &CookieResponse,
addr: SocketAddr
) -> Result<(), HandlePacketError>
Handle CookieResponse
packet received from UDP socket
pub async fn handle_tcp_cookie_response(
&self,
packet: &CookieResponse,
sender_pk: PublicKey
) -> Result<(), HandlePacketError>
[src]
&self,
packet: &CookieResponse,
sender_pk: PublicKey
) -> Result<(), HandlePacketError>
Handle CookieResponse
packet received from TCP socket
pub async fn handle_crypto_handshake(
&self,
connection: &mut CryptoConnection,
packet: &CryptoHandshake
) -> Result<(), HandlePacketError>
[src]
&self,
connection: &mut CryptoConnection,
packet: &CryptoHandshake
) -> Result<(), HandlePacketError>
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]
&self,
packet: &CryptoHandshake,
addr: SocketAddr
) -> Result<(), HandlePacketError>
Handle CryptoHandshake
packet received from UDP socket
pub async fn handle_tcp_crypto_handshake(
&self,
packet: &CryptoHandshake,
sender_pk: PublicKey
) -> Result<(), HandlePacketError>
[src]
&self,
packet: &CryptoHandshake,
sender_pk: PublicKey
) -> Result<(), HandlePacketError>
Handle CryptoHandshake
packet received from TCP socket
pub async fn handle_udp_crypto_data(
&self,
packet: &CryptoData,
addr: SocketAddr
) -> Result<(), HandlePacketError>
[src]
&self,
packet: &CryptoData,
addr: SocketAddr
) -> Result<(), HandlePacketError>
Handle CryptoData
packet received from UDP socket
pub async fn handle_tcp_crypto_data(
&self,
packet: &CryptoData,
sender_pk: PublicKey
) -> Result<(), HandlePacketError>
[src]
&self,
packet: &CryptoData,
sender_pk: PublicKey
) -> Result<(), HandlePacketError>
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]
&self,
dht_pk_tx: UnboundedSender<(PublicKey, PublicKey)>
)
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]
&self,
connection_status_tx: UnboundedSender<(PublicKey, bool)>
)
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
Auto Trait Implementations
impl !RefUnwindSafe for NetCrypto
[src]
impl Send for NetCrypto
[src]
impl Sync for NetCrypto
[src]
impl Unpin for NetCrypto
[src]
impl !UnwindSafe for NetCrypto
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,