From 005467dc5a24dbb214973a3743374c6dbe2b963a Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Fri, 12 Jul 2024 01:59:26 +1000 Subject: [PATCH] docs: a couple of docs improvements --- stun-types/src/attribute/mod.rs | 2 +- stun-types/src/data.rs | 4 ++++ stun-types/src/message.rs | 7 ++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/stun-types/src/attribute/mod.rs b/stun-types/src/attribute/mod.rs index 395b161..4b35cd7 100644 --- a/stun-types/src/attribute/mod.rs +++ b/stun-types/src/attribute/mod.rs @@ -61,7 +61,7 @@ //! } //! impl<'a> From<&MyAttribute> for RawAttribute<'a> { //! fn from(value: &MyAttribute) -> RawAttribute<'a> { -//! let mut ret = vec![0; 4]; +//! let mut ret = [0; 4]; //! BigEndian::write_u32(&mut ret, value.value); //! RawAttribute::new(MyAttribute::TYPE, &ret).into_owned() //! } diff --git a/stun-types/src/data.rs b/stun-types/src/data.rs index 4e2f4ce..3342aa5 100644 --- a/stun-types/src/data.rs +++ b/stun-types/src/data.rs @@ -6,6 +6,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +//! Data handling +//! +//! Provides a CoW interface for slices of `[u8]` and `Box<[u8]>` + /// A slice of data #[derive(Debug, Clone, PartialEq, Eq)] #[repr(transparent)] diff --git a/stun-types/src/message.rs b/stun-types/src/message.rs index 9d8d44f..122de81 100644 --- a/stun-types/src/message.rs +++ b/stun-types/src/message.rs @@ -30,8 +30,8 @@ //! 0x00, 0x00, 0x00, 0x00, // \ //! 0x00, 0x00, 0x00, 0x00, // } transaction ID //! 0x00, 0x00, 0x73, 0x92, // / -//! 0x00, 0x1D, 0x00, 0x04, // PasswordAlgorithm ttribute -//! 0x00, 0x02, 0x00, 0x00 // PasswordAlgorithm attribute +//! 0x00, 0x1D, 0x00, 0x04, // PasswordAlgorithm attribute header (type and length) +//! 0x00, 0x02, 0x00, 0x00 // PasswordAlgorithm attribute value //! ]; //! let msg = Message::from_bytes(&msg_data).unwrap(); //! @@ -84,7 +84,7 @@ use crate::attribute::*; use tracing::{debug, warn}; -/// The value of magic cookie (in network byte order) as specified in RFC5389, and RFC8489. +/// The value of the magic cookie (in network byte order) as specified in RFC5389, and RFC8489. pub const MAGIC_COOKIE: u32 = 0x2112A442; /// The value of the binding message type. Can be used in either a request or an indication @@ -1331,6 +1331,7 @@ impl<'a> Iterator for MessageAttributesIter<'a> { } } +/// A builder of a STUN Message to a sequence of bytes. #[derive(Clone, Debug)] pub struct MessageBuilder<'a> { msg_type: MessageType,