Struct StunClient

Source
pub struct StunClient {
    pub timeout: Duration,
    pub retry_interval: Duration,
    pub stun_server: SocketAddr,
    pub software: Option<&'static str>,
}
Expand description

Options for querying STUN server

Fields§

§timeout: Duration

“End-to-end” timeout for the operation.

§retry_interval: Duration

How often to repeat STUN binding requests

§stun_server: SocketAddr

Address of the STUN server

§software: Option<&'static str>

SOFTWARE attribute value in binding request

Implementations§

Source§

impl StunClient

Source

pub fn new(stun_server: SocketAddr) -> Self

A constructor with default parameters

Source

pub fn with_google_stun_server() -> Self

Use hard coded STUN server stun.l.google.com:19302.

Not for production use, for tests, prototypes and demos. May block the thread. May panic in case of address resolution problems.

Source

pub fn set_timeout(&mut self, timeout: Duration) -> &mut Self

Set timeout field, builder pattern.

Source

pub fn set_retry_interval(&mut self, retry_interval: Duration) -> &mut Self

Set retry_interval field, builder pattern.

Source

pub fn set_software(&mut self, software: Option<&'static str>) -> &mut Self

Set software field, builder pattern.

Source§

impl StunClient

Source

pub fn query_external_address( &self, udp: &UdpSocket, ) -> Result<SocketAddr, Error>

Get external (server-reflexive transport address) IP address and port of specified UDP socket

Source

pub async fn query_external_address_async( self, udp: &UdpSocket, ) -> Result<SocketAddr, Error>

async version of query_external_address.

Requires async crate feature to be enabled (it is by default)

Auto Trait Implementations§

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V