← snapshot
753 bytes
//! Blobs: file content.
use bytes::Bytes;
/// File content, stored whole.
///
/// `Bytes` so a blob can be cloned into narration or an interop image
/// without copying the underlying buffer.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Blob(Bytes);
impl Blob {
/// Wraps content bytes.
#[must_use]
pub fn new(content: impl Into<Bytes>) -> Self {
Self(content.into())
}
/// The content.
#[must_use]
pub const fn as_bytes(&self) -> &Bytes {
&self.0
}
/// Content length in bytes.
#[must_use]
pub const fn len(&self) -> usize {
self.0.len()
}
/// Whether the blob is empty.
#[must_use]
pub const fn is_empty(&self) -> bool {
self.0.is_empty()
}
}