pub struct CyberdropClient { /* private fields */ }Expand description
Async HTTP client for a subset of Cyberdrop endpoints.
Most higher-level methods map non-2xx responses to CyberdropError. For raw access where
you want to inspect status codes and bodies directly, use CyberdropClient::get.
Implementations§
Source§impl CyberdropClient
impl CyberdropClient
Sourcepub fn builder() -> CyberdropClientBuilder
pub fn builder() -> CyberdropClientBuilder
Start configuring a client with the crate’s defaults.
Defaults:
- Base URL:
https://cyberdrop.cr/ - Timeout: 30 seconds
- User agent: a browser-like UA string
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.
pub async fn get_album_by_id( &self, album_id: u64, ) -> Result<Album, CyberdropError>
Sourcepub async fn get(
&self,
path: impl AsRef<str>,
) -> Result<Response, CyberdropError>
pub async fn get( &self, path: impl AsRef<str>, ) -> Result<Response, CyberdropError>
Execute a GET request against a relative path on the configured base URL.
This method returns the raw reqwest::Response and does not convert non-2xx status
codes into errors. If a token is configured, it will be attached, but authentication is
not required.
§Errors
Returns CyberdropError::Http on transport failures (including timeouts). This method
does not map HTTP status codes to CyberdropError variants.
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
or CyberdropClientBuilder::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
or CyberdropClientBuilder::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)
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 list_albums(&self) -> Result<AlbumsList, CyberdropError>
pub async fn list_albums(&self) -> Result<AlbumsList, 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<AlbumFilesPage, CyberdropError>
pub async fn list_album_files( &self, album_id: u64, ) -> Result<AlbumFilesPage, CyberdropError>
List all files in an album (“folder”) by iterating pages until exhaustion.
This calls CyberdropClient::list_album_files_page repeatedly starting at page = 0 and
stops when:
- enough files have been collected to satisfy the API-reported
count, or - a page returns zero files, or
- a page yields no new file IDs (defensive infinite-loop guard).
Requires an auth token (see CyberdropClient::with_auth_token).
§Returns
An AlbumFilesPage containing all collected files. The returned count is the total
file count as reported by the API.
§Errors
Any error returned by CyberdropClient::list_album_files_page.
Sourcepub async fn list_album_files_page(
&self,
album_id: u64,
page: u64,
) -> Result<AlbumFilesPage, CyberdropError>
pub async fn list_album_files_page( &self, album_id: u64, page: u64, ) -> Result<AlbumFilesPage, CyberdropError>
List files in an album (“folder”) for a specific page.
Page numbers are zero-based (page = 0 is the first page). This is intentionally exposed
so a higher-level pagination helper can be added later.
Requires an auth token (see CyberdropClient::with_auth_token).
§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)
Sourcepub async fn request_new_album_link(
&self,
album_id: u64,
) -> Result<String, CyberdropError>
pub async fn request_new_album_link( &self, album_id: u64, ) -> Result<String, CyberdropError>
Request a new public link identifier for an existing album, preserving its current settings.
This is a convenience wrapper around:
CyberdropClient::list_albums(to fetch current album settings)CyberdropClient::edit_albumwithrequest_new_link = true
Requires an auth token (see CyberdropClient::with_auth_token).
§Returns
The new album public URL in the form https://cyberdrop.cr/a/<identifier>.
Note: this URL is always built against https://cyberdrop.cr/ (it does not use the
client’s configured base URL).
§Errors
CyberdropError::MissingAuthTokenif the client has no configured tokenCyberdropError::AlbumNotFoundifalbum_idis not present in the album listCyberdropError::AuthenticationFailed/CyberdropError::RequestFailedfor non-2xx statusesCyberdropError::Apifor service-reported failuresCyberdropError::MissingFieldif the API omits the new identifierCyberdropError::Httpfor transport failures (including timeouts)
Sourcepub async fn set_album_name(
&self,
album_id: u64,
name: impl Into<String>,
) -> Result<EditAlbumResult, CyberdropError>
pub async fn set_album_name( &self, album_id: u64, name: impl Into<String>, ) -> Result<EditAlbumResult, CyberdropError>
Update an album name, preserving existing description and visibility flags.
This is a convenience wrapper around:
CyberdropClient::list_albums(to fetch current album settings)CyberdropClient::edit_albumwithrequest_new_link = false
Requires an auth token (see CyberdropClient::with_auth_token).
§Returns
The API response mapped into an EditAlbumResult.
§Errors
CyberdropError::MissingAuthTokenif the client has no configured tokenCyberdropError::AlbumNotFoundifalbum_idis not present in the album listCyberdropError::AuthenticationFailed/CyberdropError::RequestFailedfor non-2xx statusesCyberdropError::Apifor service-reported failuresCyberdropError::MissingFieldif the response is missing expected fieldsCyberdropError::Httpfor transport failures (including timeouts)
Sourcepub async fn set_album_description(
&self,
album_id: u64,
description: impl Into<String>,
) -> Result<EditAlbumResult, CyberdropError>
pub async fn set_album_description( &self, album_id: u64, description: impl Into<String>, ) -> Result<EditAlbumResult, CyberdropError>
Update an album description, preserving existing name and visibility flags.
This is a convenience wrapper around:
CyberdropClient::list_albums(to fetch current album settings)CyberdropClient::edit_albumwithrequest_new_link = false
Requires an auth token (see CyberdropClient::with_auth_token).
§Returns
The API response mapped into an EditAlbumResult.
§Errors
CyberdropError::MissingAuthTokenif the client has no configured tokenCyberdropError::AlbumNotFoundifalbum_idis not present in the album listCyberdropError::AuthenticationFailed/CyberdropError::RequestFailedfor non-2xx statusesCyberdropError::Apifor service-reported failuresCyberdropError::MissingFieldif the response is missing expected fieldsCyberdropError::Httpfor transport failures (including timeouts)
Sourcepub async fn set_album_download(
&self,
album_id: u64,
download: bool,
) -> Result<EditAlbumResult, CyberdropError>
pub async fn set_album_download( &self, album_id: u64, download: bool, ) -> Result<EditAlbumResult, CyberdropError>
Update an album download flag, preserving existing name/description and public flag.
This is a convenience wrapper around:
CyberdropClient::list_albums(to fetch current album settings)CyberdropClient::edit_albumwithrequest_new_link = false
Requires an auth token (see CyberdropClient::with_auth_token).
§Returns
The API response mapped into an EditAlbumResult.
§Errors
CyberdropError::MissingAuthTokenif the client has no configured tokenCyberdropError::AlbumNotFoundifalbum_idis not present in the album listCyberdropError::AuthenticationFailed/CyberdropError::RequestFailedfor non-2xx statusesCyberdropError::Apifor service-reported failuresCyberdropError::MissingFieldif the response is missing expected fieldsCyberdropError::Httpfor transport failures (including timeouts)
Sourcepub async fn set_album_public(
&self,
album_id: u64,
public: bool,
) -> Result<EditAlbumResult, CyberdropError>
pub async fn set_album_public( &self, album_id: u64, public: bool, ) -> Result<EditAlbumResult, CyberdropError>
Update an album public flag, preserving existing name/description and download flag.
This is a convenience wrapper around:
CyberdropClient::list_albums(to fetch current album settings)CyberdropClient::edit_albumwithrequest_new_link = false
Requires an auth token (see CyberdropClient::with_auth_token).
§Returns
The API response mapped into an EditAlbumResult.
§Errors
CyberdropError::MissingAuthTokenif the client has no configured tokenCyberdropError::AlbumNotFoundifalbum_idis not present in the album listCyberdropError::AuthenticationFailed/CyberdropError::RequestFailedfor non-2xx statusesCyberdropError::Apifor service-reported failuresCyberdropError::MissingFieldif the response is missing expected fieldsCyberdropError::Httpfor transport failures (including timeouts)
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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more