pub struct CyberdropClient { /* private fields */ }Expand description
Async HTTP client for a subset of Cyberdrop endpoints.
Implementations§
Source§impl CyberdropClient
impl CyberdropClient
Sourcepub async fn login(
&self,
username: impl Into<String>,
password: impl Into<String>,
) -> Result<AuthToken, CyberdropError>
pub async fn login( &self, username: impl Into<String>, password: impl Into<String>, ) -> Result<AuthToken, CyberdropError>
Authenticate and retrieve a token.
The returned token can be installed on a client via CyberdropClient::with_auth_token.
§Errors
CyberdropError::AuthenticationFailed/CyberdropError::RequestFailedfor non-2xx statusesCyberdropError::MissingTokenif the response body omits the token fieldCyberdropError::Httpfor transport failures (including timeouts)
Sourcepub async fn register(
&self,
username: impl Into<String>,
password: impl Into<String>,
) -> Result<AuthToken, CyberdropError>
pub async fn register( &self, username: impl Into<String>, password: impl Into<String>, ) -> Result<AuthToken, CyberdropError>
Register a new account and retrieve a token.
The returned token can be installed on a client via CyberdropClient::with_auth_token.
Note: the API returns HTTP 200 even for validation failures; this method converts
{"success":false,...} responses into CyberdropError::Api.
§Errors
CyberdropError::Apiif the API reports a validation failure (e.g. username taken)CyberdropError::MissingTokenif the response body omits the token field on successCyberdropError::Httpfor transport failures (including timeouts)
Sourcepub async fn verify_token(
&self,
token: impl Into<String>,
) -> Result<TokenVerification, CyberdropError>
pub async fn verify_token( &self, token: impl Into<String>, ) -> Result<TokenVerification, CyberdropError>
Verify a token and fetch associated permissions.
This request does not require the client to be authenticated; the token to verify is supplied in the request body.
§Errors
CyberdropError::AuthenticationFailed/CyberdropError::RequestFailedfor non-2xx statusesCyberdropError::MissingFieldif expected fields are missing in the response bodyCyberdropError::Httpfor transport failures (including timeouts)
Source§impl CyberdropClient
impl CyberdropClient
Sourcepub async fn get_album_by_id(
&self,
album_id: u64,
) -> Result<Album, CyberdropError>
pub async fn get_album_by_id( &self, album_id: u64, ) -> Result<Album, CyberdropError>
Fetch an album from CyberdropClient::list_albums by numeric ID.
§Errors
Returns CyberdropError::AlbumNotFound if the authenticated account has no album with
album_id; otherwise returns the same errors as CyberdropClient::list_albums.
Sourcepub async fn list_albums(&self) -> Result<Vec<Album>, CyberdropError>
pub async fn list_albums(&self) -> Result<Vec<Album>, CyberdropError>
List albums for the authenticated user.
Requires an auth token (see CyberdropClient::with_auth_token).
§Errors
CyberdropError::MissingAuthTokenif the client has no configured tokenCyberdropError::AuthenticationFailed/CyberdropError::RequestFailedfor non-2xx statusesCyberdropError::MissingFieldif expected fields are missing in the response bodyCyberdropError::Httpfor transport failures (including timeouts)
Sourcepub async fn list_album_files(
&self,
album_id: u64,
) -> Result<AlbumFiles, CyberdropError>
pub async fn list_album_files( &self, album_id: u64, ) -> Result<AlbumFiles, CyberdropError>
List all files in an album (“folder”) by iterating pages until exhaustion.
Starts at page = 0 and stops when:
- enough files have been collected to satisfy the API-reported
count, or - a page returns zero files.
Requires an auth token (see CyberdropClient::with_auth_token).
§Returns
An AlbumFiles value containing all collected files and the API-reported total count.
§Errors
CyberdropError::MissingAuthTokenif the client has no configured tokenCyberdropError::AuthenticationFailed/CyberdropError::RequestFailedfor non-2xx statusesCyberdropError::Apifor service-reported failuresCyberdropError::MissingFieldif expected fields are missing in the response bodyCyberdropError::Httpfor transport failures (including timeouts)
Sourcepub async fn create_album(
&self,
name: impl Into<String>,
description: Option<impl Into<String>>,
) -> Result<u64, CyberdropError>
pub async fn create_album( &self, name: impl Into<String>, description: Option<impl Into<String>>, ) -> Result<u64, CyberdropError>
Create a new album and return its numeric ID.
Requires an auth token. If the service reports that an album with a similar name already
exists, this returns CyberdropError::AlbumAlreadyExists.
§Errors
CyberdropError::MissingAuthTokenif the client has no configured tokenCyberdropError::AuthenticationFailed/CyberdropError::RequestFailedfor non-2xx statusesCyberdropError::AlbumAlreadyExistsif the service indicates an album already existsCyberdropError::Apifor other service-reported failuresCyberdropError::MissingFieldif expected fields are missing in the response bodyCyberdropError::Httpfor transport failures (including timeouts)
Sourcepub async fn edit_album(
&self,
id: u64,
name: impl Into<String>,
description: impl Into<String>,
download: bool,
public: bool,
request_new_link: bool,
) -> Result<EditAlbumResult, CyberdropError>
pub async fn edit_album( &self, id: u64, name: impl Into<String>, description: impl Into<String>, download: bool, public: bool, request_new_link: bool, ) -> Result<EditAlbumResult, CyberdropError>
Edit an existing album (“folder”).
This endpoint updates album metadata such as name/description and visibility flags. It can also request a new link identifier.
Requires an auth token.
§Returns
The API returns either a name (typical edits) or an identifier (when requesting a new
link). This crate exposes both as optional fields on EditAlbumResult.
§Errors
CyberdropError::MissingAuthTokenif the client has no configured tokenCyberdropError::AuthenticationFailed/CyberdropError::RequestFailedfor non-2xx statusesCyberdropError::Apifor service-reported failuresCyberdropError::MissingFieldif the response is missing expected fieldsCyberdropError::Httpfor transport failures (including timeouts)
Source§impl CyberdropClient
impl CyberdropClient
Sourcepub fn new() -> Result<Self, CyberdropError>
pub fn new() -> Result<Self, CyberdropError>
Build a client with the crate defaults.
Sourcepub fn new_with_token(token: impl Into<String>) -> Result<Self, CyberdropError>
pub fn new_with_token(token: impl Into<String>) -> Result<Self, CyberdropError>
Build a client with the crate defaults and an auth token.
Sourcepub fn auth_token(&self) -> Option<&str>
pub fn auth_token(&self) -> Option<&str>
Current auth token if configured.
Sourcepub fn with_auth_token(self, token: impl Into<String>) -> Self
pub fn with_auth_token(self, token: impl Into<String>) -> Self
Return a clone of this client that applies authentication to requests.
The token is attached as an HTTP header named token.
Source§impl CyberdropClient
impl CyberdropClient
Sourcepub async fn get_upload_url(&self) -> Result<Url, CyberdropError>
pub async fn get_upload_url(&self) -> Result<Url, CyberdropError>
Fetch the upload node URL for the authenticated user.
Requires an auth token (see CyberdropClient::with_auth_token).
Sourcepub async fn upload_file(
&self,
file_path: impl AsRef<Path>,
album_id: Option<u64>,
) -> Result<UploadedFile, CyberdropError>
pub async fn upload_file( &self, file_path: impl AsRef<Path>, album_id: Option<u64>, ) -> Result<UploadedFile, CyberdropError>
Upload a single file.
Requires an auth token.
Implementation notes:
- Small files are streamed.
- Large files are uploaded in chunks from disk.
- Files larger than
95_000_000bytes are uploaded in chunks. - If
album_idis provided, it is sent as analbumidheader on the chunk/single-upload requests and included in thefinishchunkspayload.
§Errors
CyberdropError::MissingAuthTokenif the client has no configured tokenCyberdropError::InvalidFileNameiffile_pathdoes not have a valid UTF-8 file nameCyberdropError::Ioif reading the file failsCyberdropError::AuthenticationFailed/CyberdropError::RequestFailedfor non-2xx statusesCyberdropError::Apiif the service reports an upload failure (including per-chunk failures)CyberdropError::MissingFieldif expected fields are missing in the response bodyCyberdropError::Httpfor transport failures (including timeouts)
Sourcepub async fn upload_file_with_progress<F>(
&self,
file_path: impl AsRef<Path>,
album_id: Option<u64>,
on_progress: F,
) -> Result<UploadedFile, CyberdropError>
pub async fn upload_file_with_progress<F>( &self, file_path: impl AsRef<Path>, album_id: Option<u64>, on_progress: F, ) -> Result<UploadedFile, CyberdropError>
Upload a single file and emit per-file progress updates.
The on_progress callback is invoked as bytes are streamed or as chunks complete.
Trait Implementations§
Source§impl Clone for CyberdropClient
impl Clone for CyberdropClient
Source§fn clone(&self) -> CyberdropClient
fn clone(&self) -> CyberdropClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more