pub struct Mfs {
pub hash_default: String,
pub cid_default: i32,
pub raw_leaves_default: bool,
/* private fields */
}
Expand description
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§
Source§impl Mfs
impl Mfs
pub fn new(api: &str) -> Result<Mfs, InvalidUri>
Sourcepub async fn rm_r<P: AsRef<Path>>(&self, p: P) -> Result<(), MfsError>
pub async fn rm_r<P: AsRef<Path>>(&self, p: P) -> Result<(), MfsError>
Remove file or folder (possibly non-empty)
Sourcepub async fn mkdirs<P: AsRef<Path>>(&self, p: P) -> Result<(), MfsError>
pub async fn mkdirs<P: AsRef<Path>>(&self, p: P) -> Result<(), MfsError>
Create directory p
and parents as needed.
Sourcepub async fn mkdir<P: AsRef<Path>>(&self, p: P) -> Result<(), MfsError>
pub async fn mkdir<P: AsRef<Path>>(&self, p: P) -> Result<(), MfsError>
Create directory p
. Requires that its parent already exist.
Sourcepub async fn mv<PS: AsRef<Path>, PD: AsRef<Path>>(
&self,
s: PS,
d: PD,
) -> Result<(), MfsError>
pub async fn mv<PS: AsRef<Path>, PD: AsRef<Path>>( &self, s: PS, d: PD, ) -> Result<(), MfsError>
Rename / move s
to d
.
Sourcepub async fn cp<PS: AsRef<Path>, PD: AsRef<Path>>(
&self,
s: PS,
d: PD,
) -> Result<(), MfsError>
pub async fn cp<PS: AsRef<Path>, PD: AsRef<Path>>( &self, s: PS, d: PD, ) -> Result<(), MfsError>
Copy path s
to path d
. Beware of s
starting with /ipfs
or /ipns
.
Sourcepub async fn ls<P: AsRef<Path>>(&self, p: P) -> Result<Vec<PathBuf>, MfsError>
pub async fn ls<P: AsRef<Path>>(&self, p: P) -> Result<Vec<PathBuf>, MfsError>
List files in folder
Sourcepub fn get<'a, P: AsRef<Path>>(
&self,
s: P,
) -> impl Stream<Item = Result<Bytes, MfsError>>
pub fn get<'a, P: AsRef<Path>>( &self, s: P, ) -> impl Stream<Item = Result<Bytes, MfsError>>
Read file at s
.
Sourcepub async fn get_fully<P: AsRef<Path>>(&self, s: P) -> Result<Vec<u8>, MfsError>
pub async fn get_fully<P: AsRef<Path>>(&self, s: P) -> Result<Vec<u8>, MfsError>
Read file at s
into in-memory buffer.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Mfs
impl !RefUnwindSafe for Mfs
impl Send for Mfs
impl Sync for Mfs
impl Unpin for Mfs
impl !UnwindSafe for Mfs
Blanket Implementations§
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
Mutably borrows from an owned value. Read more