embassy_socket/channel/
socket_msg.rs1#[derive(Copy, Clone)]
3pub struct SocketMsg<const N: usize> {
4 pub(crate) bytes: [u8; N],
6 pub(crate) len: usize,
8}
9
10impl<const N: usize> Default for SocketMsg<N> {
12 #[inline]
13 fn default() -> Self {
14 Self::new([0; N], 0)
15 }
16}
17
18impl<const N: usize> SocketMsg<N> {
20 #[inline]
22 pub const fn new(bytes: [u8; N], len: usize) -> Self {
23 Self { bytes, len }
24 }
25
26 #[inline]
28 pub fn as_bytes(&self) -> &[u8] {
29 &self.bytes[..self.len]
30 }
31}