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]) -> Blob
pub fn from_slice(content: &[u8]) -> Blob
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<Blob, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Blob, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Blob
Source§impl Serialize for Blob
impl Serialize for Blob
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
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