pub struct Blob { /* private fields */ }Expand description
A blob stores raw file contents.
Blobs are content-addressed: the hash is computed from the content itself. Two files with identical content will share the same blob.
Implementations§
Source§impl Blob
impl Blob
Sourcepub fn from_slice(content: &[u8]) -> Self
pub fn from_slice(content: &[u8]) -> Self
Create a blob from a byte slice.
Sourcepub fn content_str(&self) -> Option<&str>
pub fn content_str(&self) -> Option<&str>
Get the content as a string (if valid UTF-8).
Sourcepub fn into_content(self) -> Vec<u8> ⓘ
pub fn into_content(self) -> Vec<u8> ⓘ
Consume the blob and return the content.
Sourcepub fn hash(&self) -> ContentHash
pub fn hash(&self) -> ContentHash
Compute the content hash for this blob.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Blob
impl<'de> Deserialize<'de> for Blob
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Blob
impl StructuralPartialEq for Blob
Auto Trait Implementations§
impl Freeze for Blob
impl RefUnwindSafe for Blob
impl Send for Blob
impl Sync for Blob
impl Unpin for Blob
impl UnsafeUnpin for Blob
impl UnwindSafe for Blob
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more