embassy_socket/channel/
socket_msg.rs

1/// socket msg
2#[derive(Copy, Clone)]
3pub struct SocketMsg<const N: usize> {
4    /// send cache bytes
5    pub(crate) bytes: [u8; N],
6    /// real send bytes len
7    pub(crate) len: usize,
8}
9
10/// custom method
11impl<const N: usize> SocketMsg<N> {
12    /// create socket msg
13    #[inline]
14    pub const fn new(bytes: [u8; N], len: usize) -> Self {
15        Self { bytes, len }
16    }
17
18    /// get real bytes data
19    #[inline]
20    pub fn as_bytes(&self) -> &[u8] {
21        &self.bytes[..self.len]
22    }
23}