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: AttributeHeaderThe AttributeHeader of this RawAttribute
value: Data<'a>The raw bytes of this RawAttribute
Implementations§
source§impl<'a> RawAttribute<'a>
impl<'a> RawAttribute<'a>
sourcepub fn new(atype: AttributeType, data: &'a [u8]) -> Self
pub fn new(atype: AttributeType, data: &'a [u8]) -> Self
Create a new RawAttribute
sourcepub fn from_bytes(data: &'a [u8]) -> Result<Self, StunParseError>
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);sourcepub fn to_bytes(&self) -> Vec<u8>
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]);sourcepub fn get_type(&self) -> AttributeType
pub fn get_type(&self) -> AttributeType
Returns the AttributeType of this RawAttribute
sourcepub fn length(&self) -> u16
pub fn length(&self) -> u16
Returns the length of this RawAttribute
sourcepub fn check_type_and_len(
&self,
atype: AttributeType,
allowed_range: impl RangeBounds<usize>,
) -> Result<(), StunParseError>
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
sourcepub fn into_owned<'b>(self) -> RawAttribute<'b>
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>
impl<'a> Clone for RawAttribute<'a>
source§fn clone(&self) -> RawAttribute<'a>
fn clone(&self) -> RawAttribute<'a>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl<'a> Debug for RawAttribute<'a>
impl<'a> Debug for RawAttribute<'a>
source§impl<'a> Display for RawAttribute<'a>
impl<'a> Display for RawAttribute<'a>
source§impl<'a> From<&AlternateDomain> for RawAttribute<'a>
impl<'a> From<&AlternateDomain> for RawAttribute<'a>
source§fn from(value: &AlternateDomain) -> RawAttribute<'a>
fn from(value: &AlternateDomain) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&AlternateServer> for RawAttribute<'a>
impl<'a> From<&AlternateServer> for RawAttribute<'a>
source§fn from(value: &AlternateServer) -> RawAttribute<'a>
fn from(value: &AlternateServer) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&ErrorCode> for RawAttribute<'a>
impl<'a> From<&ErrorCode> for RawAttribute<'a>
source§fn from(value: &ErrorCode) -> RawAttribute<'a>
fn from(value: &ErrorCode) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&Fingerprint> for RawAttribute<'a>
impl<'a> From<&Fingerprint> for RawAttribute<'a>
source§fn from(value: &Fingerprint) -> RawAttribute<'a>
fn from(value: &Fingerprint) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&IceControlled> for RawAttribute<'a>
impl<'a> From<&IceControlled> for RawAttribute<'a>
source§fn from(value: &IceControlled) -> RawAttribute<'a>
fn from(value: &IceControlled) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&IceControlling> for RawAttribute<'a>
impl<'a> From<&IceControlling> for RawAttribute<'a>
source§fn from(value: &IceControlling) -> RawAttribute<'a>
fn from(value: &IceControlling) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&'a MessageIntegrity> for RawAttribute<'a>
impl<'a> From<&'a MessageIntegrity> for RawAttribute<'a>
source§fn from(value: &'a MessageIntegrity) -> RawAttribute<'a>
fn from(value: &'a MessageIntegrity) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&'a MessageIntegritySha256> for RawAttribute<'a>
impl<'a> From<&'a MessageIntegritySha256> for RawAttribute<'a>
source§fn from(value: &'a MessageIntegritySha256) -> RawAttribute<'a>
fn from(value: &'a MessageIntegritySha256) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&'a Nonce> for RawAttribute<'a>
impl<'a> From<&'a Nonce> for RawAttribute<'a>
source§fn from(value: &'a Nonce) -> RawAttribute<'a>
fn from(value: &'a Nonce) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&PasswordAlgorithm> for RawAttribute<'a>
impl<'a> From<&PasswordAlgorithm> for RawAttribute<'a>
source§fn from(value: &PasswordAlgorithm) -> RawAttribute<'a>
fn from(value: &PasswordAlgorithm) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&PasswordAlgorithms> for RawAttribute<'a>
impl<'a> From<&PasswordAlgorithms> for RawAttribute<'a>
source§fn from(value: &PasswordAlgorithms) -> RawAttribute<'a>
fn from(value: &PasswordAlgorithms) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&Priority> for RawAttribute<'a>
impl<'a> From<&Priority> for RawAttribute<'a>
source§fn from(value: &Priority) -> RawAttribute<'a>
fn from(value: &Priority) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&'a Realm> for RawAttribute<'a>
impl<'a> From<&'a Realm> for RawAttribute<'a>
source§fn from(value: &'a Realm) -> RawAttribute<'a>
fn from(value: &'a Realm) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&'a Software> for RawAttribute<'a>
impl<'a> From<&'a Software> for RawAttribute<'a>
source§fn from(value: &'a Software) -> RawAttribute<'a>
fn from(value: &'a Software) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&UnknownAttributes> for RawAttribute<'a>
impl<'a> From<&UnknownAttributes> for RawAttribute<'a>
source§fn from(value: &UnknownAttributes) -> RawAttribute<'a>
fn from(value: &UnknownAttributes) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&UseCandidate> for RawAttribute<'a>
impl<'a> From<&UseCandidate> for RawAttribute<'a>
source§fn from(_value: &UseCandidate) -> RawAttribute<'a>
fn from(_value: &UseCandidate) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&'a Userhash> for RawAttribute<'a>
impl<'a> From<&'a Userhash> for RawAttribute<'a>
source§fn from(value: &'a Userhash) -> RawAttribute<'a>
fn from(value: &'a Userhash) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&'a Username> for RawAttribute<'a>
impl<'a> From<&'a Username> for RawAttribute<'a>
source§fn from(value: &'a Username) -> RawAttribute<'a>
fn from(value: &'a Username) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<&XorMappedAddress> for RawAttribute<'a>
impl<'a> From<&XorMappedAddress> for RawAttribute<'a>
source§fn from(value: &XorMappedAddress) -> RawAttribute<'a>
fn from(value: &XorMappedAddress) -> RawAttribute<'a>
Converts to this type from the input type.
source§impl<'a> From<RawAttribute<'a>> for Vec<u8>
impl<'a> From<RawAttribute<'a>> for Vec<u8>
source§fn from(f: RawAttribute<'_>) -> Self
fn from(f: RawAttribute<'_>) -> Self
Converts to this type from the input type.
source§impl<'a> PartialEq for RawAttribute<'a>
impl<'a> PartialEq for RawAttribute<'a>
source§fn eq(&self, other: &RawAttribute<'a>) -> bool
fn eq(&self, other: &RawAttribute<'a>) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl<'a> TryFrom<&RawAttribute<'a>> for AlternateDomain
impl<'a> TryFrom<&RawAttribute<'a>> for AlternateDomain
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for AlternateServer
impl<'a> TryFrom<&RawAttribute<'a>> for AlternateServer
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for ErrorCode
impl<'a> TryFrom<&RawAttribute<'a>> for ErrorCode
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for Fingerprint
impl<'a> TryFrom<&RawAttribute<'a>> for Fingerprint
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for IceControlled
impl<'a> TryFrom<&RawAttribute<'a>> for IceControlled
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for IceControlling
impl<'a> TryFrom<&RawAttribute<'a>> for IceControlling
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for MessageIntegrity
impl<'a> TryFrom<&RawAttribute<'a>> for MessageIntegrity
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for MessageIntegritySha256
impl<'a> TryFrom<&RawAttribute<'a>> for MessageIntegritySha256
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for Nonce
impl<'a> TryFrom<&RawAttribute<'a>> for Nonce
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for PasswordAlgorithm
impl<'a> TryFrom<&RawAttribute<'a>> for PasswordAlgorithm
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for PasswordAlgorithms
impl<'a> TryFrom<&RawAttribute<'a>> for PasswordAlgorithms
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for Priority
impl<'a> TryFrom<&RawAttribute<'a>> for Priority
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for Realm
impl<'a> TryFrom<&RawAttribute<'a>> for Realm
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for Software
impl<'a> TryFrom<&RawAttribute<'a>> for Software
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for UnknownAttributes
impl<'a> TryFrom<&RawAttribute<'a>> for UnknownAttributes
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for UseCandidate
impl<'a> TryFrom<&RawAttribute<'a>> for UseCandidate
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for Userhash
impl<'a> TryFrom<&RawAttribute<'a>> for Userhash
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for Username
impl<'a> TryFrom<&RawAttribute<'a>> for Username
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl<'a> TryFrom<&RawAttribute<'a>> for XorMappedAddress
impl<'a> TryFrom<&RawAttribute<'a>> for XorMappedAddress
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
impl<'a> Eq for RawAttribute<'a>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)