MessageBuilder

Struct MessageBuilder 

Source
pub struct MessageBuilder { /* private fields */ }
Expand description

STUN message builder.

Implementations§

Source§

impl MessageBuilder

Source

pub const fn new( class: MessageClass, method: Method, transaction_id: [u8; 12], ) -> Self

Create a new message builder.

Source

pub fn binding_request(transaction_id: [u8; 12]) -> Self

Create a new message builder for a STUN binding request.

Source

pub fn response(class: MessageClass, request: &Message) -> Self

Create a new message builder for a STUN response.

Source

pub fn success_response(request: &Message) -> Self

Create a new message builder for a success STUN response.

Source

pub fn error_response(request: &Message, error_code: ErrorCode) -> Self

Create a new message builder for an error STUN response.

Source

pub fn class(&mut self, class: MessageClass) -> &mut Self

Set message class.

Source

pub fn method(&mut self, method: Method) -> &mut Self

Set STUN method.

Set magic cookie as defined in RFC 5389.

Source

pub fn transaction_id(&mut self, transaction_id: [u8; 12]) -> &mut Self

Set transaction ID as defined in RFC 5389.

Source

pub fn long_transaction_id(&mut self, transaction_id: [u8; 16]) -> &mut Self

Set transaction ID as defined in RFC 3489.

Source

pub fn mapped_address(&mut self, addr: SocketAddr) -> &mut Self

Set mapped address.

Source

pub fn xor_mapped_address(&mut self, addr: SocketAddr) -> &mut Self

Set XOR mapped address.

Source

pub fn username<T>(&mut self, username: T) -> &mut Self
where T: ToString,

Set username.

Source

pub fn message_integrity<T>(&mut self, key: T) -> &mut Self
where T: Into<Vec<u8>>,

Enable message integrity and use a given key.

Source

pub fn fingerprint(&mut self, enable: bool) -> &mut Self

Enable or disable message fingerprint.

Source

pub fn error_code(&mut self, error_code: ErrorCode) -> &mut Self

Set error code.

Source

pub fn realm<T>(&mut self, realm: T) -> &mut Self
where T: ToString,

Set realm.

Source

pub fn nonce<T>(&mut self, nonce: T) -> &mut Self
where T: ToString,

Set nonce.

Source

pub fn unknown_attributes<T>(&mut self, unknown_attributes: T) -> &mut Self
where T: Into<Vec<u16>>,

Set unknown attributes.

Source

pub fn software<T>(&mut self, software: T) -> &mut Self
where T: ToString,

Set software.

Source

pub fn alternate_server(&mut self, server: SocketAddr) -> &mut Self

Set alternate server.

Source

pub fn build(&self) -> Bytes

Finalize the message.

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.