pub struct PreviewClient<'a, T: Transport, A: AuthProvider> { /* private fields */ }Expand description
Client for fetching image previews and thumbnails from Nextcloud.
Executes calls through any Transport and applies credentials via an AuthProvider.
Both are held by reference, allowing the client to be freely cloned or borrowed across
tasks without runtime dispatch or connection pooling overhead.
Previews are generated by Nextcloud’s core preview endpoint at /core/preview.png
(accessed via /index.php/core/preview.png).
Reference:
- Official Nextcloud Preview endpoint:
GET /core/preview.png?fileId={fileId}&x={x}&y={y}&a={a}&mode={mode}orGET /core/preview.png?file={filePath}&x={x}&y={y}
Implementations§
Source§impl<'a, T: Transport, A: AuthProvider> PreviewClient<'a, T, A>
impl<'a, T: Transport, A: AuthProvider> PreviewClient<'a, T, A>
Sourcepub const fn new(transport: &'a T, auth: &'a A) -> Self
pub const fn new(transport: &'a T, auth: &'a A) -> Self
Binds a preview client to a transport and credential provider.
Sourcepub async fn get_by_file_id(
&self,
file_id: u64,
options: &PreviewOptions,
) -> Result<Vec<u8>, Error>
pub async fn get_by_file_id( &self, file_id: u64, options: &PreviewOptions, ) -> Result<Vec<u8>, Error>
Fetches a preview by numeric file cache ID (fileId).
Sends GET /index.php/core/preview.png?fileId={file_id}....
Returns the raw preview image bytes on success.
§Errors
Returns Error::Status if the server responds with a non-2xx status code,
or Error::Transport if the underlying network request fails.
Sourcepub async fn get_by_path(
&self,
path: &str,
options: &PreviewOptions,
) -> Result<Vec<u8>, Error>
pub async fn get_by_path( &self, path: &str, options: &PreviewOptions, ) -> Result<Vec<u8>, Error>
Fetches a preview by file path (file).
Sends GET /index.php/core/preview.png?file={path}....
Returns the raw preview image bytes on success.
§Errors
Returns Error::Status if the server responds with a non-2xx status code,
or Error::Transport if the underlying network request fails.