Struct Fs

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

A Jottacloud “filesystem”.

Implementations§

Source§

impl Fs

Source

pub fn new<S: TokenStore + 'static>(token_store: S) -> Self

Create a new filesystem.

§Panics

Panics if the HTTP client fails to initialize.

Source

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)
Source

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 than range)
  • jottacloud erorr
  • network error
Source

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
Source

pub async fn file_detail( &self, path: &UserScopedPath, ) -> Result<FileDetail, Error>

Get metadata associated with a file.

§Errors
  • network errors
  • jottacloud errors
  • no such file
Source

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
Source

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
Source

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
Source

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§

Source§

impl Debug for Fs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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<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, 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, 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<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> ErasedDestructor for T
where T: 'static,