pub struct Mfs { /* private fields */ }Expand description
Handle to the node’s mutable filesystem. Obtain it via crate::Ipfs::mfs.
Implementations§
Source§impl Mfs
impl Mfs
pub fn with_shard_threshold(self, threshold: Option<u64>) -> Self
Sourcepub async fn root(&self) -> Result<Option<Cid>, Error>
pub async fn root(&self) -> Result<Option<Cid>, Error>
Returns the current MFS root Cid, or None if nothing has been written yet.
Sourcepub async fn mkdir(&self, path: &str, parents: bool) -> Result<(), Error>
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.
Sourcepub async fn write(
&self,
path: &str,
data: &[u8],
parents: bool,
) -> Result<(), Error>
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.
Sourcepub async fn write_with(
&self,
path: &str,
data: &[u8],
opts: WriteOptions,
) -> Result<(), Error>
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.
Sourcepub async fn truncate(&self, path: &str, size: u64) -> Result<(), Error>
pub async fn truncate(&self, path: &str, size: u64) -> Result<(), Error>
Sets the file at path to exactly size bytes, truncating or zero-extending.
Sourcepub fn write_from_file(
&self,
path: &str,
file: impl AsRef<Path>,
parents: bool,
) -> MfsWrite
pub fn write_from_file( &self, path: &str, file: impl AsRef<Path>, parents: bool, ) -> MfsWrite
Write the whole content of file at path.
Sourcepub fn write_stream<S>(&self, path: &str, stream: S, parents: bool) -> MfsWrite
pub fn write_stream<S>(&self, path: &str, stream: S, parents: bool) -> MfsWrite
Writes the whole file at path from a byte stream without buffering the content, creating or
replacing it.
Sourcepub async fn read(&self, path: &str) -> Result<Vec<u8>, Error>
pub async fn read(&self, path: &str) -> Result<Vec<u8>, Error>
Reads the whole content of the file at path.
Sourcepub async fn read_range(
&self,
path: &str,
offset: u64,
count: Option<u64>,
) -> Result<Vec<u8>, Error>
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.
Sourcepub fn read_stream(
&self,
path: &str,
) -> impl Stream<Item = Result<Bytes, Error>>
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.
Sourcepub fn read_stream_range(
&self,
path: &str,
offset: u64,
count: Option<u64>,
) -> impl Stream<Item = Result<Bytes, Error>>
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.
Sourcepub async fn rm(&self, path: &str, recursive: bool) -> Result<(), Error>
pub async fn rm(&self, path: &str, recursive: bool) -> Result<(), Error>
Removes the entry at path. A non-empty directory requires recursive.
Sourcepub async fn rm_force(&self, path: &str, recursive: bool) -> Result<(), Error>
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.
Sourcepub async fn cp(&self, from: &str, to: &str, parents: bool) -> Result<(), Error>
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.
Sourcepub async fn mv(&self, from: &str, to: &str, parents: bool) -> Result<(), Error>
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).
Sourcepub async fn ls(&self, path: &str) -> Result<Vec<MfsEntry>, Error>
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.
Trait Implementations§
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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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