Struct stun_types::attribute::RawAttribute

source ·
pub struct RawAttribute<'a> {
    pub header: AttributeHeader,
    pub value: Data<'a>,
}
Expand description

The header and raw bytes of an unparsed Attribute

Fields§

§header: AttributeHeader§value: Data<'a>

The raw bytes of this RawAttribute

Implementations§

source§

impl<'a> RawAttribute<'a>

source

pub fn new(atype: AttributeType, data: &'a [u8]) -> Self

Create a new RawAttribute

source

pub fn from_bytes(data: &'a [u8]) -> Result<Self, StunParseError>

Deserialize a RawAttribute from bytes.

§Examples
let data = &[0, 1, 0, 2, 5, 6, 0, 0];
let attr = RawAttribute::from_bytes(data).unwrap();
assert_eq!(attr.get_type(), AttributeType::new(1));
assert_eq!(attr.length(), 2);
source

pub fn to_bytes(&self) -> Vec<u8>

Serialize a RawAttribute to bytes.

§Examples
let attr = RawAttribute::new(AttributeType::new(1), &[5, 6]);
assert_eq!(attr.to_bytes(), &[0, 1, 0, 2, 5, 6, 0, 0]);
source

pub fn get_type(&self) -> AttributeType

Returns the AttributeType of this RawAttribute

source

pub fn length(&self) -> u16

Returns the length of this RawAttribute

source

pub fn check_type_and_len( &self, atype: AttributeType, allowed_range: impl RangeBounds<usize>, ) -> Result<(), StunParseError>

Helper for checking that a raw attribute is of a particular type and within a certain range

source

pub fn into_owned<'b>(self) -> RawAttribute<'b>

Consume this RawAttribute and return a new owned RawAttribute

Trait Implementations§

source§

impl<'a> Clone for RawAttribute<'a>

source§

fn clone(&self) -> RawAttribute<'a>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for RawAttribute<'a>

source§

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

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

impl<'a> Display for RawAttribute<'a>

source§

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

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

impl<'a> From<&AlternateDomain> for RawAttribute<'a>

source§

fn from(value: &AlternateDomain) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&AlternateServer> for RawAttribute<'a>

source§

fn from(value: &AlternateServer) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&ErrorCode> for RawAttribute<'a>

source§

fn from(value: &ErrorCode) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&Fingerprint> for RawAttribute<'a>

source§

fn from(value: &Fingerprint) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&IceControlled> for RawAttribute<'a>

source§

fn from(value: &IceControlled) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&IceControlling> for RawAttribute<'a>

source§

fn from(value: &IceControlling) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&'a MessageIntegrity> for RawAttribute<'a>

source§

fn from(value: &'a MessageIntegrity) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&'a MessageIntegritySha256> for RawAttribute<'a>

source§

fn from(value: &'a MessageIntegritySha256) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&'a Nonce> for RawAttribute<'a>

source§

fn from(value: &'a Nonce) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&PasswordAlgorithm> for RawAttribute<'a>

source§

fn from(value: &PasswordAlgorithm) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&PasswordAlgorithms> for RawAttribute<'a>

source§

fn from(value: &PasswordAlgorithms) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&Priority> for RawAttribute<'a>

source§

fn from(value: &Priority) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&'a Realm> for RawAttribute<'a>

source§

fn from(value: &'a Realm) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&'a Software> for RawAttribute<'a>

source§

fn from(value: &'a Software) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&UnknownAttributes> for RawAttribute<'a>

source§

fn from(value: &UnknownAttributes) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&UseCandidate> for RawAttribute<'a>

source§

fn from(_value: &UseCandidate) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&'a Userhash> for RawAttribute<'a>

source§

fn from(value: &'a Userhash) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&'a Username> for RawAttribute<'a>

source§

fn from(value: &'a Username) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<&XorMappedAddress> for RawAttribute<'a>

source§

fn from(value: &XorMappedAddress) -> RawAttribute<'a>

Converts to this type from the input type.
source§

impl<'a> From<RawAttribute<'a>> for Vec<u8>

source§

fn from(f: RawAttribute<'_>) -> Self

Converts to this type from the input type.
source§

impl<'a> PartialEq for RawAttribute<'a>

source§

fn eq(&self, other: &RawAttribute<'a>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for AlternateDomain

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for AlternateServer

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for ErrorCode

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for Fingerprint

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for IceControlled

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for IceControlling

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for MessageIntegrity

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for MessageIntegritySha256

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for Nonce

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for PasswordAlgorithm

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for PasswordAlgorithms

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for Priority

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for Realm

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for Software

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for UnknownAttributes

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for UseCandidate

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for Userhash

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for Username

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&RawAttribute<'a>> for XorMappedAddress

§

type Error = StunParseError

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

fn try_from(raw: &RawAttribute<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> Eq for RawAttribute<'a>

source§

impl<'a> StructuralPartialEq for RawAttribute<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for RawAttribute<'a>

§

impl<'a> RefUnwindSafe for RawAttribute<'a>

§

impl<'a> Send for RawAttribute<'a>

§

impl<'a> Sync for RawAttribute<'a>

§

impl<'a> Unpin for RawAttribute<'a>

§

impl<'a> UnwindSafe for RawAttribute<'a>

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§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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

§

type Output = T

Should always be Self
source§

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

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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

§

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

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more