Skip to main content

Mfs

Struct Mfs 

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

Handle to the node’s mutable filesystem. Obtain it via crate::Ipfs::mfs.

Implementations§

Source§

impl Mfs

Source

pub fn with_shard_threshold(self, threshold: Option<u64>) -> Self

Source

pub async fn root(&self) -> Result<Option<Cid>, Error>

Returns the current MFS root Cid, or None if nothing has been written yet.

Source

pub async fn mkdir(&self, path: &str, parents: bool) -> Result<(), Error>

Creates a directory at path. With parents, missing intermediate directories are created; otherwise a missing parent is an error.

Source

pub async fn write( &self, path: &str, data: &[u8], parents: bool, ) -> Result<(), Error>

Writes data as the whole file at path, creating or replacing it.

Source

pub async fn write_with( &self, path: &str, data: &[u8], opts: WriteOptions, ) -> Result<(), Error>

Writes data into the file at path starting at opts.offset, preserving the surrounding bytes (read-modify-rewrite). create makes a missing file, truncate discards existing content first, parents creates missing directories.

Source

pub async fn truncate(&self, path: &str, size: u64) -> Result<(), Error>

Sets the file at path to exactly size bytes, truncating or zero-extending.

Source

pub fn write_from_file( &self, path: &str, file: impl AsRef<Path>, parents: bool, ) -> MfsWrite

Write the whole content of file at path.

Source

pub fn write_stream<S>(&self, path: &str, stream: S, parents: bool) -> MfsWrite
where S: Stream<Item = Result<Bytes>> + Send + 'static,

Writes the whole file at path from a byte stream without buffering the content, creating or replacing it.

Source

pub async fn read(&self, path: &str) -> Result<Vec<u8>, Error>

Reads the whole content of the file at path.

Source

pub async fn read_range( &self, path: &str, offset: u64, count: Option<u64>, ) -> Result<Vec<u8>, Error>

Reads count bytes (or to EOF if None) of the file at path, starting at offset.

Source

pub fn read_stream( &self, path: &str, ) -> impl Stream<Item = Result<Bytes, Error>>

Streams the content of the file at path as it is read, without buffering the whole file.

Source

pub fn read_stream_range( &self, path: &str, offset: u64, count: Option<u64>, ) -> impl Stream<Item = Result<Bytes, Error>>

Streams count bytes (or to EOF if None) of the file at path, starting at offset, reading only the blocks that overlap the range.

Source

pub fn read_to_file(&self, path: &str, dest: impl AsRef<Path>) -> MfsRead

Reads the file at path and writes it to the local filesystem at dest, streaming through without buffering. The returned MfsRead is both a progress Stream and a future resolving to the number of bytes written.

Source

pub async fn rm(&self, path: &str, recursive: bool) -> Result<(), Error>

Removes the entry at path. A non-empty directory requires recursive.

Source

pub async fn rm_force(&self, path: &str, recursive: bool) -> Result<(), Error>

Removes the entry at path if present, succeeding when it is already absent.

Source

pub async fn cp(&self, from: &str, to: &str, parents: bool) -> Result<(), Error>

Copies from to the MFS path to. from is either another MFS path or an /ipfs (or /ipld) path, in which case the referenced DAG is fetched locally and imported.

Source

pub async fn mv(&self, from: &str, to: &str, parents: bool) -> Result<(), Error>

Moves the MFS entry at from to to. Non-atomic: it links the destination then unlinks the source as two commits, so a failure between them leaves the entry at both paths (never lost).

Source

pub async fn ls(&self, path: &str) -> Result<Vec<MfsEntry>, Error>

Lists the immediate entries of the directory at path (/ for the root). A file path lists the single file itself, matching ipfs files ls.

Source

pub async fn stat(&self, path: &str) -> Result<MfsStat, Error>

Returns type and size information for the entry at path.

Source

pub async fn exists(&self, path: &str) -> Result<bool, Error>

Returns whether anything exists at path.

Trait Implementations§

Source§

impl Clone for Mfs

Source§

fn clone(&self) -> Mfs

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Mfs

§

impl !UnwindSafe for Mfs

§

impl Freeze for Mfs

§

impl Send for Mfs

§

impl Sync for Mfs

§

impl Unpin for Mfs

§

impl UnsafeUnpin for Mfs

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> TimeoutExt for T

Source§

fn timeout(self, duration: Duration) -> Timeout<Self>

Requires a Future or Stream to complete before the specific duration has elapsed. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more