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: AttributeHeaderThe AttributeHeader of this RawAttribute
value: Vec<u8>The raw bytes of this RawAttribute
Implementations§
source§impl RawAttribute
impl RawAttribute
pub fn new(atype: AttributeType, data: &[u8]) -> Self
sourcepub fn from_bytes(data: &[u8]) -> Result<Self, StunParseError>
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);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
Trait Implementations§
source§impl Clone for RawAttribute
impl Clone for RawAttribute
source§fn clone(&self) -> RawAttribute
fn clone(&self) -> RawAttribute
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 Debug for RawAttribute
impl Debug for RawAttribute
source§impl Display for RawAttribute
impl Display for RawAttribute
source§impl From<AlternateDomain> for RawAttribute
impl From<AlternateDomain> for RawAttribute
source§fn from(value: AlternateDomain) -> RawAttribute
fn from(value: AlternateDomain) -> RawAttribute
Converts to this type from the input type.
source§impl From<AlternateServer> for RawAttribute
impl From<AlternateServer> for RawAttribute
source§fn from(value: AlternateServer) -> RawAttribute
fn from(value: AlternateServer) -> RawAttribute
Converts to this type from the input type.
source§impl From<ErrorCode> for RawAttribute
impl From<ErrorCode> for RawAttribute
source§fn from(value: ErrorCode) -> RawAttribute
fn from(value: ErrorCode) -> RawAttribute
Converts to this type from the input type.
source§impl From<Fingerprint> for RawAttribute
impl From<Fingerprint> for RawAttribute
source§fn from(value: Fingerprint) -> RawAttribute
fn from(value: Fingerprint) -> RawAttribute
Converts to this type from the input type.
source§impl From<IceControlled> for RawAttribute
impl From<IceControlled> for RawAttribute
source§fn from(value: IceControlled) -> RawAttribute
fn from(value: IceControlled) -> RawAttribute
Converts to this type from the input type.
source§impl From<IceControlling> for RawAttribute
impl From<IceControlling> for RawAttribute
source§fn from(value: IceControlling) -> RawAttribute
fn from(value: IceControlling) -> RawAttribute
Converts to this type from the input type.
source§impl From<MessageIntegrity> for RawAttribute
impl From<MessageIntegrity> for RawAttribute
source§fn from(value: MessageIntegrity) -> RawAttribute
fn from(value: MessageIntegrity) -> RawAttribute
Converts to this type from the input type.
source§impl From<MessageIntegritySha256> for RawAttribute
impl From<MessageIntegritySha256> for RawAttribute
source§fn from(value: MessageIntegritySha256) -> RawAttribute
fn from(value: MessageIntegritySha256) -> RawAttribute
Converts to this type from the input type.
source§impl From<Nonce> for RawAttribute
impl From<Nonce> for RawAttribute
source§fn from(value: Nonce) -> RawAttribute
fn from(value: Nonce) -> RawAttribute
Converts to this type from the input type.
source§impl From<PasswordAlgorithm> for RawAttribute
impl From<PasswordAlgorithm> for RawAttribute
source§fn from(value: PasswordAlgorithm) -> RawAttribute
fn from(value: PasswordAlgorithm) -> RawAttribute
Converts to this type from the input type.
source§impl From<PasswordAlgorithms> for RawAttribute
impl From<PasswordAlgorithms> for RawAttribute
source§fn from(value: PasswordAlgorithms) -> RawAttribute
fn from(value: PasswordAlgorithms) -> RawAttribute
Converts to this type from the input type.
source§impl From<Priority> for RawAttribute
impl From<Priority> for RawAttribute
source§fn from(value: Priority) -> RawAttribute
fn from(value: Priority) -> RawAttribute
Converts to this type from the input type.
source§impl From<RawAttribute> for Vec<u8>
impl From<RawAttribute> for Vec<u8>
source§fn from(f: RawAttribute) -> Self
fn from(f: RawAttribute) -> Self
Converts to this type from the input type.
source§impl From<Realm> for RawAttribute
impl From<Realm> for RawAttribute
source§fn from(value: Realm) -> RawAttribute
fn from(value: Realm) -> RawAttribute
Converts to this type from the input type.
source§impl From<Software> for RawAttribute
impl From<Software> for RawAttribute
source§fn from(value: Software) -> RawAttribute
fn from(value: Software) -> RawAttribute
Converts to this type from the input type.
source§impl From<UnknownAttributes> for RawAttribute
impl From<UnknownAttributes> for RawAttribute
source§fn from(value: UnknownAttributes) -> RawAttribute
fn from(value: UnknownAttributes) -> RawAttribute
Converts to this type from the input type.
source§impl From<UseCandidate> for RawAttribute
impl From<UseCandidate> for RawAttribute
source§fn from(_value: UseCandidate) -> RawAttribute
fn from(_value: UseCandidate) -> RawAttribute
Converts to this type from the input type.
source§impl From<Userhash> for RawAttribute
impl From<Userhash> for RawAttribute
source§fn from(value: Userhash) -> RawAttribute
fn from(value: Userhash) -> RawAttribute
Converts to this type from the input type.
source§impl From<Username> for RawAttribute
impl From<Username> for RawAttribute
source§fn from(value: Username) -> RawAttribute
fn from(value: Username) -> RawAttribute
Converts to this type from the input type.
source§impl From<XorMappedAddress> for RawAttribute
impl From<XorMappedAddress> for RawAttribute
source§fn from(value: XorMappedAddress) -> RawAttribute
fn from(value: XorMappedAddress) -> RawAttribute
Converts to this type from the input type.
source§impl PartialEq for RawAttribute
impl PartialEq for RawAttribute
source§fn eq(&self, other: &RawAttribute) -> bool
fn eq(&self, other: &RawAttribute) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl TryFrom<&[u8]> for RawAttribute
impl TryFrom<&[u8]> for RawAttribute
source§impl TryFrom<&RawAttribute> for AlternateDomain
impl TryFrom<&RawAttribute> for AlternateDomain
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for AlternateServer
impl TryFrom<&RawAttribute> for AlternateServer
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for ErrorCode
impl TryFrom<&RawAttribute> for ErrorCode
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for Fingerprint
impl TryFrom<&RawAttribute> for Fingerprint
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for IceControlled
impl TryFrom<&RawAttribute> for IceControlled
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for IceControlling
impl TryFrom<&RawAttribute> for IceControlling
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for MessageIntegrity
impl TryFrom<&RawAttribute> for MessageIntegrity
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for MessageIntegritySha256
impl TryFrom<&RawAttribute> for MessageIntegritySha256
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for Nonce
impl TryFrom<&RawAttribute> for Nonce
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for PasswordAlgorithm
impl TryFrom<&RawAttribute> for PasswordAlgorithm
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for PasswordAlgorithms
impl TryFrom<&RawAttribute> for PasswordAlgorithms
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for Priority
impl TryFrom<&RawAttribute> for Priority
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for Realm
impl TryFrom<&RawAttribute> for Realm
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for Software
impl TryFrom<&RawAttribute> for Software
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for UnknownAttributes
impl TryFrom<&RawAttribute> for UnknownAttributes
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for UseCandidate
impl TryFrom<&RawAttribute> for UseCandidate
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for Userhash
impl TryFrom<&RawAttribute> for Userhash
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for Username
impl TryFrom<&RawAttribute> for Username
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
source§impl TryFrom<&RawAttribute> for XorMappedAddress
impl TryFrom<&RawAttribute> for XorMappedAddress
§type Error = StunParseError
type Error = StunParseError
The type returned in the event of a conversion error.
impl Eq for RawAttribute
impl StructuralPartialEq for RawAttribute
Auto Trait Implementations§
impl Freeze for RawAttribute
impl RefUnwindSafe for RawAttribute
impl Send for RawAttribute
impl Sync for RawAttribute
impl Unpin for RawAttribute
impl UnwindSafe for RawAttribute
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