Skip to content

Commit

Permalink
/// -> // for private types+fns
Browse files Browse the repository at this point in the history
  • Loading branch information
rrybarczyk committed Oct 14, 2024
1 parent 6653b2a commit 4bdf140
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions protocols/v2/framing-sv2/src/framing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<T, B> From<Sv2Frame<T, B>> for Frame<T, B> {
pub struct Sv2Frame<T, B> {
header: Header,
payload: Option<T>,
/// Serialized header + payload
// Serialized header + payload
serialized: Option<B>,
}

Expand Down Expand Up @@ -225,7 +225,7 @@ impl HandShakeFrame {
Self { payload: bytes }
}

/// Returns the size of the `HandShakeFrame` payload.
// Returns the size of the `HandShakeFrame` payload.
#[inline]
fn encoded_length(&self) -> usize {
self.payload.len()
Expand Down Expand Up @@ -253,10 +253,10 @@ pub fn handshake_message_to_frame<T: AsRef<[u8]>>(message: T) -> HandShakeFrame
}
}

/// Basically a boolean bit filter for `extension_type`.
/// Takes an `extension_type` represented as a `u16` and a boolean flag (`channel_msg`).
/// If `channel_msg` is true, it sets the most significant bit of `extension_type` to 1,
/// otherwise, it clears the most significant bit to 0.
// Basically a boolean bit filter for `extension_type`.
// Takes an `extension_type` represented as a `u16` and a boolean flag (`channel_msg`).
// If `channel_msg` is true, it sets the most significant bit of `extension_type` to 1,
// otherwise, it clears the most significant bit to 0.
fn update_extension_type(extension_type: u16, channel_msg: bool) -> u16 {
if channel_msg {
let mask = 0b1000_0000_0000_0000;
Expand Down
24 changes: 12 additions & 12 deletions protocols/v2/framing-sv2/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ pub const NOISE_HEADER_SIZE: usize = const_sv2::NOISE_FRAME_HEADER_SIZE;
/// Abstraction for a SV2 Frame Header.
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
pub struct Header {
/// Unique identifier of the extension describing this protocol message. Most significant bit
/// (i.e.bit 15, 0-indexed, aka channel_msg) indicates a message which is specific to a channel,
/// whereas if the most significant bit is unset, the message is to be interpreted by the
/// immediate receiving device. Note that the channel_msg bit is ignored in the extension
/// lookup, i.e.an extension_type of 0x8ABC is for the same "extension" as 0x0ABC. If the
/// channel_msg bit is set, the first four bytes of the payload field is a U32 representing the
/// channel_id this message is destined for. Note that for the Job Declaration and Template
/// Distribution Protocols the channel_msg bit is always unset.
// Unique identifier of the extension describing this protocol message. Most significant bit
// (i.e.bit 15, 0-indexed, aka channel_msg) indicates a message which is specific to a channel,
// whereas if the most significant bit is unset, the message is to be interpreted by the
// immediate receiving device. Note that the channel_msg bit is ignored in the extension
// lookup, i.e.an extension_type of 0x8ABC is for the same "extension" as 0x0ABC. If the
// channel_msg bit is set, the first four bytes of the payload field is a U32 representing the
// channel_id this message is destined for. Note that for the Job Declaration and Template
// Distribution Protocols the channel_msg bit is always unset.
extension_type: u16, // fix: use U16 type
/// Unique identifier of the extension describing this protocol message
// Unique identifier of the extension describing this protocol message
msg_type: u8, // fix: use specific type?
/// Length of the protocol message, not including this header
// Length of the protocol message, not including this header
msg_length: U24,
}

Expand All @@ -51,15 +51,15 @@ impl Header {
})
}

/// Get the payload length
// Get the payload length
#[allow(clippy::len_without_is_empty)]
#[inline]
pub(crate) fn len(&self) -> usize {
let inner: u32 = self.msg_length.into();
inner as usize
}

/// Construct a `Header` from payload length, type and extension type.
// Construct a `Header` from payload length, type and extension type.
#[inline]
pub(crate) fn from_len(msg_length: u32, msg_type: u8, extension_type: u16) -> Option<Header> {
Some(Self {
Expand Down

0 comments on commit 4bdf140

Please sign in to comment.