Struct stun_types::attribute::RawAttribute

source ·
pub struct RawAttribute {
    pub header: AttributeHeader,
    pub value: Vec<u8>,
}
Expand description

The header and raw bytes of an unparsed Attribute

Fields§

§header: AttributeHeader§value: Vec<u8>

The raw bytes of this RawAttribute

Implementations§

source§

impl RawAttribute

source

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

source

pub fn from_bytes(data: &[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

Trait Implementations§

source§

impl Clone for RawAttribute

source§

fn clone(&self) -> RawAttribute

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 Debug for RawAttribute

source§

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

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

impl Display for RawAttribute

source§

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

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

impl From<AlternateDomain> for RawAttribute

source§

fn from(value: AlternateDomain) -> RawAttribute

Converts to this type from the input type.
source§

impl From<AlternateServer> for RawAttribute

source§

fn from(value: AlternateServer) -> RawAttribute

Converts to this type from the input type.
source§

impl From<ErrorCode> for RawAttribute

source§

fn from(value: ErrorCode) -> RawAttribute

Converts to this type from the input type.
source§

impl From<Fingerprint> for RawAttribute

source§

fn from(value: Fingerprint) -> RawAttribute

Converts to this type from the input type.
source§

impl From<IceControlled> for RawAttribute

source§

fn from(value: IceControlled) -> RawAttribute

Converts to this type from the input type.
source§

impl From<IceControlling> for RawAttribute

source§

fn from(value: IceControlling) -> RawAttribute

Converts to this type from the input type.
source§

impl From<MessageIntegrity> for RawAttribute

source§

fn from(value: MessageIntegrity) -> RawAttribute

Converts to this type from the input type.
source§

impl From<MessageIntegritySha256> for RawAttribute

source§

fn from(value: MessageIntegritySha256) -> RawAttribute

Converts to this type from the input type.
source§

impl From<Nonce> for RawAttribute

source§

fn from(value: Nonce) -> RawAttribute

Converts to this type from the input type.
source§

impl From<PasswordAlgorithm> for RawAttribute

source§

fn from(value: PasswordAlgorithm) -> RawAttribute

Converts to this type from the input type.
source§

impl From<PasswordAlgorithms> for RawAttribute

source§

fn from(value: PasswordAlgorithms) -> RawAttribute

Converts to this type from the input type.
source§

impl From<Priority> for RawAttribute

source§

fn from(value: Priority) -> RawAttribute

Converts to this type from the input type.
source§

impl From<RawAttribute> for Vec<u8>

source§

fn from(f: RawAttribute) -> Self

Converts to this type from the input type.
source§

impl From<Realm> for RawAttribute

source§

fn from(value: Realm) -> RawAttribute

Converts to this type from the input type.
source§

impl From<Software> for RawAttribute

source§

fn from(value: Software) -> RawAttribute

Converts to this type from the input type.
source§

impl From<UnknownAttributes> for RawAttribute

source§

fn from(value: UnknownAttributes) -> RawAttribute

Converts to this type from the input type.
source§

impl From<UseCandidate> for RawAttribute

source§

fn from(_value: UseCandidate) -> RawAttribute

Converts to this type from the input type.
source§

impl From<Userhash> for RawAttribute

source§

fn from(value: Userhash) -> RawAttribute

Converts to this type from the input type.
source§

impl From<Username> for RawAttribute

source§

fn from(value: Username) -> RawAttribute

Converts to this type from the input type.
source§

impl From<XorMappedAddress> for RawAttribute

source§

fn from(value: XorMappedAddress) -> RawAttribute

Converts to this type from the input type.
source§

impl PartialEq for RawAttribute

source§

fn eq(&self, other: &RawAttribute) -> 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 TryFrom<&[u8]> for RawAttribute

§

type Error = StunParseError

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

fn try_from(value: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 TryFrom<&RawAttribute> 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 Eq for RawAttribute

source§

impl StructuralPartialEq for RawAttribute

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