pub struct MessageRef<'a> { /* private fields */ }Implementations§
Source§impl<'a> MessageRef<'a>
impl<'a> MessageRef<'a>
Sourcepub fn method(&self) -> StunMethod
pub fn method(&self) -> StunMethod
message method.
Sourcepub fn get<T: Attribute<'a>>(&self) -> Option<T::Item>
pub fn get<T: Attribute<'a>>(&self) -> Option<T::Item>
get attribute.
get attribute from message attribute list.
§Test
use std::convert::TryFrom;
use turn_server::stun::attribute::*;
use turn_server::stun::*;
let buffer = [
0x00u8, 0x01, 0x00, 0x00, 0x21, 0x12, 0xa4, 0x42, 0x72, 0x6d, 0x49,
0x42, 0x72, 0x52, 0x64, 0x48, 0x57, 0x62, 0x4b, 0x2b,
];
let mut attributes = Attributes::default();
let message = MessageDecoder::decode(&buffer[..], &mut attributes).unwrap();
assert!(message.get::<UserName>().is_none());Sourcepub fn get_all<T: Attribute<'a>>(&self) -> impl Iterator<Item = T::Item>
pub fn get_all<T: Attribute<'a>>(&self) -> impl Iterator<Item = T::Item>
Gets all the values of an attribute from a list.
Normally a stun message can have multiple attributes with the same name, and this function will all the values of the current attribute.
§Test
use std::convert::TryFrom;
use turn_server::stun::attribute::*;
use turn_server::stun::*;
let buffer = [
0x00u8, 0x01, 0x00, 0x00, 0x21, 0x12, 0xa4, 0x42, 0x72, 0x6d, 0x49,
0x42, 0x72, 0x52, 0x64, 0x48, 0x57, 0x62, 0x4b, 0x2b,
];
let mut attributes = Attributes::default();
let message = MessageDecoder::decode(&buffer[..], &mut attributes).unwrap();
assert_eq!(message.get_all::<UserName>().next(), None);Sourcepub fn integrity(&self, digest: &[u8; 16]) -> Result<(), StunError>
pub fn integrity(&self, digest: &[u8; 16]) -> Result<(), StunError>
check MessageRefIntegrity attribute.
return whether the MessageRefIntegrity attribute
contained in the message can pass the check.
§Test
use std::convert::TryFrom;
use turn_server::stun::*;
let buffer = [
0x00u8, 0x03, 0x00, 0x50, 0x21, 0x12, 0xa4, 0x42, 0x64, 0x4f, 0x5a,
0x78, 0x6a, 0x56, 0x33, 0x62, 0x4b, 0x52, 0x33, 0x31, 0x00, 0x19, 0x00,
0x04, 0x11, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x70, 0x61, 0x6e,
0x64, 0x61, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x09, 0x72, 0x61, 0x73,
0x70, 0x62, 0x65, 0x72, 0x72, 0x79, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00,
0x10, 0x31, 0x63, 0x31, 0x33, 0x64, 0x32, 0x62, 0x32, 0x34, 0x35, 0x62,
0x33, 0x61, 0x37, 0x33, 0x34, 0x00, 0x08, 0x00, 0x14, 0xd6, 0x78, 0x26,
0x99, 0x0e, 0x15, 0x56, 0x15, 0xe5, 0xf4, 0x24, 0x74, 0xe2, 0x3c, 0x26,
0xc5, 0xb1, 0x03, 0xb2, 0x6d,
];
let mut attributes = Attributes::default();
let message = MessageDecoder::decode(&buffer[..], &mut attributes).unwrap();
let result = message
.integrity(&util::long_term_credential_digest(
"panda",
"panda",
"raspberry",
))
.is_ok();
assert!(result);Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for MessageRef<'a>
impl<'a> RefUnwindSafe for MessageRef<'a>
impl<'a> Send for MessageRef<'a>
impl<'a> Sync for MessageRef<'a>
impl<'a> Unpin for MessageRef<'a>
impl<'a> UnwindSafe for MessageRef<'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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more