1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
use std::{convert::Infallible, io};
use crate::{Blob, BlobRef};
impl Blob {
/// Write the blobs data to `out` verbatim.
pub fn write_to(&self, mut out: impl io::Write) -> io::Result<()> {
out.write_all(&self.data)
}
}
impl<'a> BlobRef<'a> {
/// Instantiate a `Blob` from the given `data`, which is used as-is.
pub fn from_bytes(data: &[u8]) -> Result<BlobRef<'_>, Infallible> {
Ok(BlobRef { data })
}
}