Skip to main content

ApiV3Client

Struct ApiV3Client 

Source
pub struct ApiV3Client {
    pub base_url: String,
    pub http_client: Client,
    pub session_cookie: Option<String>,
}
Expand description

API v3 client structure

Fields§

§base_url: String§http_client: Client§session_cookie: Option<String>

Implementations§

Source§

impl ApiV3Client

Source

pub async fn create_download( &self, request: &Aria2CreateRequest<'_>, ) -> Result<(), Error>

Create one or more aria2 offline-download tasks.

Cloudreve v3 returns the created tasks in data (an array of objects whose exact shape varies by version, e.g. with/without gid), so we accept any JSON payload. Callers only need success/failure here — use Self::list_downloading to follow the new tasks afterwards.

Source

pub async fn list_downloading(&self) -> Result<Vec<Aria2DownloadingTask>, Error>

List in-flight aria2 tasks (GET /aria2/downloading).

Cloudreve v3 returns a flat array (no pagination wrapper). When there are no active downloads the response carries code: 0, data: null, which deserialises to an empty vector here.

Source

pub async fn list_finished(&self) -> Result<Vec<Aria2FinishedTask>, Error>

List finished aria2 tasks (GET /aria2/finished).

Cloudreve v3’s response is a flat array; the legacy /aria2/finished/:page path segment was removed years ago and no longer exists on supported servers. Returns an empty vector when the server replies with data: null.

Source

pub async fn delete_task(&self, gid: &str) -> Result<(), Error>

Cancel an aria2 task by GID.

Source§

impl ApiV3Client

Source

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

List directory contents

Source

pub async fn create_directory( &self, request: &CreateDirectoryRequest<'_>, ) -> Result<(), Error>

Create a directory

Source§

impl ApiV3Client

Source

pub async fn search_files( &self, keyword: &str, path: &str, ) -> Result<DirectoryList, Error>

Search for files by keyword, scoped to path.

Pass “/” as path to search the entire drive. The response reuses the directory listing shape, so the matches arrive in objects.

Source

pub async fn upload_file( &self, request: &UploadFileRequest<'_>, ) -> Result<UploadSession, Error>

Source

pub async fn complete_upload(&self, session_id: &str) -> Result<(), Error>

Source

pub async fn upload_chunk( &self, session_id: &str, chunk_index: u32, data: Vec<u8>, ) -> Result<(), Error>

Upload one chunk of an open session (POST /file/upload/{sessionId}/{index}).

The index has to reach the server: V3 derives the append offset from it (AppendStart = chunkSize * index) and rejects out-of-order chunks, so pinning the URL to chunk 0 made every multi-chunk upload either fail or overwrite the first chunk.

V3 answers 200 even for failures and carries the real outcome in the body’s code, so the status alone must not be read as success.

Source

pub async fn delete_upload_session(&self, session_id: &str) -> Result<(), Error>

Delete one upload session by id (DELETE /file/upload/{sessionId}).

Opening a session makes V3 insert a placeholder file row that keeps the name taken. If the upload never finishes, every later upload_file for the same path fails with 40054 “Upload session existed” until the server-side GC runs (upload_session_timeout, 24h by default). Deleting the session drops that placeholder and is the only way a client can clear the conflict itself.

A session the server no longer knows returns CodeUploadSessionExpired; callers that are only cleaning up can treat that as already done.

Source

pub async fn delete_all_upload_sessions(&self) -> Result<(), Error>

Delete every upload placeholder the current user owns (DELETE /file/upload).

This is the recovery path for orphan sessions whose ids the client lost (killed mid-upload, local store wiped, session created but the response never arrived). It is account-wide, so any upload still in flight loses its placeholder too — only call it when nothing else is uploading.

Source

pub async fn download_file(&self, id: &str) -> Result<DownloadUrl, Error>

Source

pub async fn get_file_source( &self, request: &FileSourceRequest, ) -> Result<Vec<FileSource>, Error>

Source

pub async fn preview_file(&self, id: &str) -> Result<DirectoryList, Error>

Source

pub async fn get_thumbnail(&self, id: &str) -> Result<DirectoryList, Error>

Source

pub async fn create_file( &self, request: &CreateFileRequest<'_>, ) -> Result<(), Error>

Source§

impl ApiV3Client

Source

pub async fn get_object_property( &self, id: &str, is_folder: Option<bool>, trace_root: Option<bool>, ) -> Result<Property, Error>

Get object (file/folder) property

Source

pub async fn rename_object( &self, request: &RenameObjectRequest<'_>, ) -> Result<(), Error>

Rename object

Source

pub async fn move_object( &self, request: &MoveObjectRequest<'_>, ) -> Result<(), Error>

Move object

Source

pub async fn copy_object( &self, request: &CopyObjectRequest<'_>, ) -> Result<(), Error>

Copy object

Source

pub async fn delete_object( &self, request: &DeleteObjectRequest<'_>, ) -> Result<(), Error>

Delete object

Source§

impl ApiV3Client

Source

pub async fn login(&mut self, request: &LoginRequest<'_>) -> Result<User, Error>

Login with email and password

Source

pub async fn login_2fa( &mut self, request: &OtpLoginRequest, ) -> Result<User, Error>

Login with OTP (Two-Factor Authentication)

Source

pub async fn logout(&self) -> Result<(), Error>

Logout from current session

Source§

impl ApiV3Client

Source

pub async fn create_share(&self, request: &ShareRequest) -> Result<Share, Error>

Create a share link Note: The V3 API may return either an ApiResponse object or a plain string URL

Source§

impl ApiV3Client

Source

pub async fn get_site_config(&self) -> Result<SiteConfig, Error>

Get site configuration

Source

pub async fn get_captcha(&mut self) -> Result<CaptchaResponse, Error>

Get CAPTCHA for login

Source

pub async fn is_captcha_required(&self) -> Result<bool, Error>

Check if CAPTCHA is required for login

Source

pub async fn get_user_storage(&self) -> Result<StorageInfo, Error>

Get user storage information

Source

pub async fn ping(&self) -> Result<String, Error>

Ping the server and get server version

Source

pub async fn get_version(&self) -> Result<VersionInfo, Error>

Get API version information

Source

pub async fn get_user_settings(&self) -> Result<StorageInfo, Error>

Get user settings

Source

pub async fn get_task_queue(&self, page: i32) -> Result<UserTaskList, Error>

Get the user’s general task queue (GET /user/setting/tasks).

This endpoint is for Cloudreve’s broader task system (transfer, compress, etc.), not aria2 offline downloads. page is 1-based; Cloudreve returns at most ~10 entries per page along with the cumulative total.

Source§

impl ApiV3Client

Source

pub async fn get_webdav_accounts(&self) -> Result<Vec<WebdavAccount>, Error>

Get WebDAV accounts

Source§

impl ApiV3Client

Source

pub fn new(base_url: &str) -> Self

Source

pub fn get_url(&self, endpoint: &str) -> String

Source

pub async fn get<T>(&self, endpoint: &str) -> Result<T, Error>

Source

pub async fn post<T>( &self, endpoint: &str, body: &impl Serialize, ) -> Result<T, Error>

Source

pub async fn post_raw( &self, endpoint: &str, body: &impl Serialize, ) -> Result<String, Error>

POST request that returns raw text instead of parsing JSON

Source

pub async fn put<T>( &self, endpoint: &str, body: &impl Serialize, ) -> Result<T, Error>

Source

pub async fn patch<T>( &self, endpoint: &str, body: &impl Serialize, ) -> Result<T, Error>

Source

pub async fn delete<T>(&self, endpoint: &str) -> Result<T, Error>

Source

pub async fn delete_with_body<T>( &self, endpoint: &str, body: &impl Serialize, ) -> Result<T, Error>

Source

pub async fn put_text( &self, endpoint: &str, body: &impl Serialize, ) -> Result<String, Error>

PUT request that returns raw text response instead of JSON

Trait Implementations§

Source§

impl Clone for ApiV3Client

Source§

fn clone(&self) -> ApiV3Client

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

impl Debug for ApiV3Client

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> 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, 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> 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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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