blob: 17159e0038be5b511e31b35c96d37f2d3954b6fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
use serde::Serialize;
/// Store an arbitrary chunk of data.
///
/// The data is just arbitrary binary data.
///
/// A chunk also contains its associated metadata, except its
/// identifier.
#[derive(Debug, Serialize)]
pub struct DataChunk {
data: Vec<u8>,
}
impl DataChunk {
/// Construct a new chunk.
pub fn new(data: Vec<u8>) -> Self {
Self { data }
}
/// Return a chunk's data.
pub fn data(&self) -> &[u8] {
&self.data
}
}
|