Skip to main content

ValidatedMessage

Struct ValidatedMessage 

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

A received message that passed a Validator, reduced to what its checks cover.

It dereferences to a Message that holds the header and the attributes ahead of the first integrity attribute: get, contains and every Getter work on it and cannot see an attribute that was appended after the integrity attribute. The integrity attributes and FINGERPRINT are not in it either; ask integrity and has_fingerprint.

Implementations§

Source§

impl ValidatedMessage

Source

pub fn message(&self) -> &Message

The message, with the covered attributes only.

Source

pub fn into_message(self) -> Message

Gives up the wrapper and returns the message with the covered attributes only.

Source

pub fn integrity(&self) -> Option<IntegrityAlgorithm>

The integrity attribute that was verified, or None for a message accepted through Validator::unauthenticated.

A response to this message carries the same one and no other (RFC 8489 section 9.1.3).

Source

pub fn is_authenticated(&self) -> bool

Whether the message was authenticated.

Source

pub fn has_fingerprint(&self) -> bool

Whether the message carried a (correct) FINGERPRINT.

Methods from Deref<Target = Message>§

Source

pub fn marshal_binary(&self) -> Result<Vec<u8>>

Marshal_binary implements the encoding.BinaryMarshaler interface.

Source

pub fn write_to<W: Write>(&self, writer: &mut W) -> Result<usize>

WriteTo implements WriterTo via calling Write(m.Raw) on w and returning call result.

Source

pub fn clone_to(&self, b: &mut Message) -> Result<()>

CloneTo clones m to b securing any further m mutations.

Source

pub fn contains(&self, t: AttrType) -> bool

Contains return true if message contain t attribute.

Source

pub fn get(&self, t: AttrType) -> Result<Vec<u8>>

Get returns byte slice that represents attribute value, if there is no attribute with such type, ErrAttributeNotFound is returned.

Source

pub fn unknown_required_attributes(&self, known: &[AttrType]) -> Vec<AttrType>

The comprehension-required attributes of this message (types below 0x8000) that are not in known, in the order they appear, each once.

RFC 8489 section 6.3: a request that has any is answered 420 (Unknown Attribute) with them in UNKNOWN-ATTRIBUTES (section 6.3.1); an indication or a response that has any is discarded (sections 6.3.2 to 6.3.4). known is what the usage understands: STUN_ATTRIBUTES plus its own.

This looks at every attribute. In an authenticated message only the attributes ahead of the integrity attribute count: use Validator, which does both.

Source

pub fn check<C: Checker>(&self, checkers: &[C]) -> Result<()>

Check applies checkers to message in batch, returning on first error.

Source

pub fn parse<G: Getter>(&self, getters: &mut [G]) -> Result<()>

Parse applies getters to message in batch, returning on first error.

Trait Implementations§

Source§

impl AsRef<Message> for ValidatedMessage

Source§

fn as_ref(&self) -> &Message

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for ValidatedMessage

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ValidatedMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for ValidatedMessage

Source§

type Target = Message

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Message

Dereferences the value.
Source§

impl PartialEq for ValidatedMessage

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ValidatedMessage

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.