1use alloc::vec;
5use alloc::vec::Vec;
6
7#[repr(C)]
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub struct VesicleHeader {
11 pub target_id: u64, pub source_id: u64, pub ttl: u8, pub flags: u8, pub _pad: [u8; 6], }
17
18impl VesicleHeader {
19 pub const SIZE: usize = 24;
20}
21
22#[derive(Debug, Clone)]
24pub struct Vesicle {
25 data: Vec<u8>,
26}
27
28impl Vesicle {
29 pub fn wrap(data: Vec<u8>) -> Self {
30 Self { data }
31 }
32
33 pub fn with_capacity(capacity: usize) -> Self {
34 Self {
35 data: vec![0; capacity],
36 }
37 }
38
39 pub fn as_slice(&self) -> &[u8] {
40 &self.data
41 }
42
43 pub fn as_mut_slice(&mut self) -> &mut [u8] {
44 &mut self.data
45 }
46
47 pub fn len(&self) -> usize {
48 self.data.len()
49 }
50
51 pub fn is_empty(&self) -> bool {
52 self.data.is_empty()
53 }
54
55 pub fn into_inner(self) -> Vec<u8> {
56 self.data
57 }
58}