pub struct MessageDecoder;Implementations§
Source§impl MessageDecoder
impl MessageDecoder
Sourcepub fn decode<'a>(
bytes: &'a [u8],
attributes: &'a mut Attributes,
) -> Result<MessageRef<'a>, StunError>
pub fn decode<'a>( bytes: &'a [u8], attributes: &'a mut Attributes, ) -> Result<MessageRef<'a>, StunError>
§Test
use std::convert::TryFrom;
use turn_server::stun::attribute::*;
use turn_server::stun::method::*;
use turn_server::stun::*;
let buffer: [u8; 20] = [
0x00, 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.method(),
StunMethod::Binding(StunMethodKind::Request)
);
assert!(message.get::<UserName>().is_none());Sourcepub fn message_size(buf: &[u8]) -> Result<usize, StunError>
pub fn message_size(buf: &[u8]) -> Result<usize, StunError>
§Test
use turn_server::stun::*;
let buffer: [u8; 20] = [
0x00, 0x01, 0x00, 0x00, 0x21, 0x12, 0xa4, 0x42, 0x72, 0x6d, 0x49, 0x42,
0x72, 0x52, 0x64, 0x48, 0x57, 0x62, 0x4b, 0x2b,
];
let size = MessageDecoder::message_size(&buffer[..]).unwrap();
assert_eq!(size, 20);Auto Trait Implementations§
impl Freeze for MessageDecoder
impl RefUnwindSafe for MessageDecoder
impl Send for MessageDecoder
impl Sync for MessageDecoder
impl Unpin for MessageDecoder
impl UnwindSafe for MessageDecoder
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