[][src]Struct mfs::Mfs

pub struct Mfs {
    pub hash_default: String,
    pub cid_default: i32,
    pub raw_leaves_default: bool,
    // some fields omitted
}

The main struct

All of its functions will panic if the passed paths are not valid unicode.

Fields

hash_default: String

Default hash function to use for write / create operations.

cid_default: i32

Default cid version to request on write / create operations. Defaults to 1.

raw_leaves_default: bool

Whether to write files with raw-leaves

Implementations

impl Mfs[src]

pub fn new(api: &str) -> Result<Mfs, InvalidUri>[src]

pub async fn rm_r<P: AsRef<Path>, '_>(&'_ self, p: P) -> Result<(), MfsError>[src]

Remove file or folder (possibly non-empty)

pub async fn rm<P: AsRef<Path>, '_>(&'_ self, p: P) -> Result<(), MfsError>[src]

Remove file

pub async fn mkdirs<P: AsRef<Path>, '_>(&'_ self, p: P) -> Result<(), MfsError>[src]

Create directory p and parents as needed.

pub async fn mkdir<P: AsRef<Path>, '_>(&'_ self, p: P) -> Result<(), MfsError>[src]

Create directory p. Requires that its parent already exist.

pub async fn mv<PS: AsRef<Path>, PD: AsRef<Path>, '_>(
    &'_ self,
    s: PS,
    d: PD
) -> Result<(), MfsError>
[src]

Rename / move s to d.

pub async fn cp<PS: AsRef<Path>, PD: AsRef<Path>, '_>(
    &'_ self,
    s: PS,
    d: PD
) -> Result<(), MfsError>
[src]

Copy path s to path d. Beware of s starting with /ipfs or /ipns.

pub async fn ls<P: AsRef<Path>, '_>(
    &'_ self,
    p: P
) -> Result<Vec<PathBuf>, MfsError>
[src]

List files in folder

pub fn get<'a, P: AsRef<Path>>(
    &self,
    s: P
) -> impl Stream<Item = Result<Bytes, MfsError>>
[src]

Read file at s.

pub async fn get_fully<P: AsRef<Path>, '_>(
    &'_ self,
    s: P
) -> Result<Vec<u8>, MfsError>
[src]

Read file at s into in-memory buffer.

pub async fn flush<P: AsRef<Path>, '_>(&'_ self, p: P) -> Result<(), MfsError>[src]

Flush folder

pub async fn put<P: AsRef<Path>, R: 'static + AsyncRead + Send + Sync + Unpin, '_>(
    &'_ self,
    d: P,
    __arg2: R
) -> Result<(), MfsError>
[src]

Write file to d.

Internally buffers chunks of 8 MiB and writes them with separate calls to IPFS due to limitations of multipart.

pub async fn stat<P: AsRef<Path>, '_>(
    &'_ self,
    p: P
) -> Result<Option<FilesStatResponse>, MfsError>
[src]

Request hash, type, sizes, and block count of p. Returns None if the file does not exist

Trait Implementations

impl Clone for Mfs[src]

Auto Trait Implementations

impl !RefUnwindSafe for Mfs

impl Send for Mfs

impl Sync for Mfs

impl Unpin for Mfs

impl !UnwindSafe for Mfs

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.