mr_bundle/
resource.rs

1/// Arbitrary opaque bytes representing a Resource in a [`Bundle`](crate::Bundle)
2#[derive(
3    Clone,
4    PartialEq,
5    Eq,
6    Hash,
7    serde::Serialize,
8    serde::Deserialize,
9    derive_more::From,
10    derive_more::Deref,
11)]
12pub struct ResourceBytes(#[serde(with = "serde_bytes")] Vec<u8>);
13
14impl ResourceBytes {
15    /// Accessor
16    pub fn inner(&self) -> &[u8] {
17        self.0.as_slice()
18    }
19
20    /// Convert to raw vec
21    pub fn into_inner(self) -> Vec<u8> {
22        self.0
23    }
24}
25
26impl std::fmt::Debug for ResourceBytes {
27    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28        f.write_fmt(format_args!(
29            "mr_bundle::ResourceBytes({})",
30            &holochain_util::hex::many_bytes_string(self.0.as_slice())
31        ))
32    }
33}