Skip to main content

Cas

Struct Cas 

Source
pub struct Cas { /* private fields */ }

Implementations§

Source§

impl Cas

Source

pub fn put_for( &mut self, bytes: &[u8], origin: &BlockOrigin, ) -> Result<B3Hash, StorageError>

Puts the bytes and records the origin they were put for. Ok means both the object and the record are durable; a second put with the same origin adds nothing.

§Errors

StorageError::Io naming the path the store would not take.

Source

pub fn origins(&self, hash: &B3Hash) -> Result<Vec<BlockOrigin>, StorageError>

Every origin recorded for a block, oldest first; empty for a block put with no origin and for a hash the store never saw.

§Errors

StorageError::Io when a record exists and cannot be read.

Source§

impl Cas

Source

pub fn open(dir: &Path) -> Result<Cas, StorageError>

Production entrance: std filesystem underneath.

Source

pub fn put(&mut self, bytes: &[u8]) -> Result<B3Hash, StorageError>

Content-addressed put: hash, dedup by existence, tmp + sync + rename + dir sync. Ok means the named object is durable.

Source

pub fn contains(&self, hash: &B3Hash) -> bool

Existence judgment; no failure surface.

Source

pub fn get(&self, hash: &B3Hash) -> Result<Vec<u8>, StorageError>

Full read, re-verified against the address.

Source

pub fn get_range( &self, hash: &B3Hash, range: &Range, ) -> Result<Vec<u8>, StorageError>

Range retrieval per the Locator grammar; out of bounds refuses.

The answer is read where it sits, so a fragment of a two hundred megabyte object costs the fragment. The price of that is stated in [ranges]: a range read cannot re-verify an address that covers the whole object, so it trusts what put verified, and a caller that needs the address proved calls Cas::get.

Source

pub fn size(&self, hash: &B3Hash) -> Result<u64, StorageError>

The object’s length in bytes, read from the filesystem rather than from the object, so asking how long a two hundred megabyte version is costs nothing like two hundred megabytes. A window of a stored document version needs it to keep its request inside the object (crates/storage/spec/Cas.lean §8-36). Like a range read, it trusts what put verified.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Cas

§

impl !Sync for Cas

§

impl !UnwindSafe for Cas

§

impl Freeze for Cas

§

impl Send for Cas

§

impl Unpin for Cas

§

impl UnsafeUnpin for Cas

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.