pub struct Fs { /* private fields */ }
Expand description
A Jottacloud “filesystem”.
Implementations§
Source§impl Fs
impl Fs
Sourcepub fn new<S: TokenStore + 'static>(token_store: S) -> Self
pub fn new<S: TokenStore + 'static>(token_store: S) -> Self
Sourcepub async fn allocate(&self, req: &AllocReq<'_>) -> Result<AllocRes, Error>
pub async fn allocate(&self, req: &AllocReq<'_>) -> Result<AllocRes, Error>
Allocate for uploading a new file or a new file revision.
§Errors
- network errors
- authentication errors (invalid token)
- jottacloud errors
- too little space left? (not verified)
Sourcepub async fn upload_range(
&self,
upload_url: &str,
body: impl Into<Body>,
range: RangeInclusive<u64>,
) -> Result<UploadRes, Error>
pub async fn upload_range( &self, upload_url: &str, body: impl Into<Body>, range: RangeInclusive<u64>, ) -> Result<UploadRes, Error>
Upload some or all data. upload_url
is acquired from Fs::allocate
.
§Errors
- invalid upload url
- premature end of body (smaller
body
thanrange
) - jottacloud erorr
- network error
Sourcepub async fn index(&self, path: &UserScopedPath) -> Result<FolderDetail, Error>
pub async fn index(&self, path: &UserScopedPath) -> Result<FolderDetail, Error>
List all files and folders at a path. Similar to the UNIX fs
command.
§Errors
- network errors
- jottacloud errors (including auth)
- path doesn’t exist
Sourcepub async fn file_detail(
&self,
path: &UserScopedPath,
) -> Result<FileDetail, Error>
pub async fn file_detail( &self, path: &UserScopedPath, ) -> Result<FileDetail, Error>
Sourcepub async fn delete_folder(
&self,
path: &UserScopedPath,
) -> Result<FolderDetail, Error>
pub async fn delete_folder( &self, path: &UserScopedPath, ) -> Result<FolderDetail, Error>
Permanently delete a folder. It must be a folder. It fails if you try to delete a single file.
§Errors
- your usual Jottacloud errors
- trying to delete a file instead of a folder
Sourcepub async fn file_to_stream(
&self,
path: &UserScopedPath,
range: impl ByteRange,
) -> Result<impl Stream<Item = Result<Bytes, Error>>, Error>
pub async fn file_to_stream( &self, path: &UserScopedPath, range: impl ByteRange, ) -> Result<impl Stream<Item = Result<Bytes, Error>>, Error>
Open a stream to a file.
§Errors
- file doesn’t exist
- range is larger than the file itself
- network errors
- jottacloud errors
Sourcepub async fn file_to_string(
&self,
path: &UserScopedPath,
) -> Result<String, Error>
pub async fn file_to_string( &self, path: &UserScopedPath, ) -> Result<String, Error>
Read a file as a string.
§Errors
- file doesn’t exist
- range is larger than the file itself
- network errors
- jottacloud errors
Sourcepub async fn file_to_bytes(
&self,
path: &UserScopedPath,
range: impl ByteRange,
) -> Result<Bytes, Error>
pub async fn file_to_bytes( &self, path: &UserScopedPath, range: impl ByteRange, ) -> Result<Bytes, Error>
Read a file as bytes.
§Errors
- file doesn’t exist
- range is larger than the file itself
- network errors
- jottacloud errors
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Fs
impl !RefUnwindSafe for Fs
impl Send for Fs
impl Sync for Fs
impl Unpin for Fs
impl !UnwindSafe for Fs
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