Skip to main content

IpfrsClient

Struct IpfrsClient 

Source
pub struct IpfrsClient { /* private fields */ }
Expand description

Non-NAPI version used in unit tests and when building without the napi feature (e.g. cargo test --lib).

Implementations§

Source§

impl IpfrsClient

Source

pub fn create(data_dir: String) -> Result<Self, ClientError>

Create a new IpfrsClient backed by an in-memory store.

data_dir is recorded for informational purposes (e.g. stats()); it is not used for actual I/O in the in-memory implementation.

Source

pub fn add_bytes_inner(&self, data: &[u8]) -> Result<String, ClientError>

Add raw bytes, returning the CIDv1 string.

Source

pub fn get_bytes_inner(&self, cid: &str) -> Result<Option<Vec<u8>>, ClientError>

Retrieve bytes by CID. Returns None when the CID is not present.

Source

pub fn has_inner(&self, cid: &str) -> Result<bool, ClientError>

Return true if cid is in the store.

Source

pub fn list_cids_inner(&self) -> Result<Vec<String>, ClientError>

Return all stored CIDs.

Source

pub fn delete_inner(&self, cid: &str) -> Result<bool, ClientError>

Delete a block. Returns true if the block existed and was removed.

Source

pub fn version_inner(&self) -> String

Return the library version string.

Source

pub fn stats_inner(&self) -> Result<String, ClientError>

Return a JSON string with basic storage statistics.

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.