pub struct FilesApi<'a> { /* private fields */ }Expand description
Files API façade.
Implementations§
Source§impl<'a> FilesApi<'a>
impl<'a> FilesApi<'a>
Sourcepub fn new(client: &'a DriveClient) -> Self
pub fn new(client: &'a DriveClient) -> Self
Wraps an existing DriveClient for file operations.
Sourcepub async fn search(
&self,
query: Option<&str>,
limit: usize,
page_token: Option<&str>,
) -> Result<FileListResponse>
pub async fn search( &self, query: Option<&str>, limit: usize, page_token: Option<&str>, ) -> Result<FileListResponse>
Searches files matching query, returning a single page.
limit is rejected client-side when it exceeds MAX_PAGE_LIMIT;
use Self::search_all to auto-paginate across pages.
Sourcepub async fn search_all(
&self,
query: Option<&str>,
limit: usize,
) -> Result<FileListResponse>
pub async fn search_all( &self, query: Option<&str>, limit: usize, ) -> Result<FileListResponse>
Searches files, auto-paginating via cursor as needed.
limit == 0 means “fetch every match up to HARD_CAP” — a
deliberate safety limit for this interactive surface.
Sourcepub async fn get_metadata(&self, file_id: &str) -> Result<DriveFile>
pub async fn get_metadata(&self, file_id: &str) -> Result<DriveFile>
Fetches a single file’s metadata (files.get), including
exportLinks.
Sourcepub async fn export(
&self,
file_id: &str,
export_mime_type: &str,
) -> Result<Vec<u8>>
pub async fn export( &self, file_id: &str, export_mime_type: &str, ) -> Result<Vec<u8>>
Exports a Google-native file’s content as export_mime_type
(files.export). Drive limits export responses to 10 MB — a larger
document surfaces as an ApiRequestFailed from
DriveClient::response_to_error.
Sourcepub async fn download(&self, file_id: &str) -> Result<Vec<u8>>
pub async fn download(&self, file_id: &str) -> Result<Vec<u8>>
Downloads a non-Google-native file’s raw bytes
(files.get?alt=media).
Sourcepub async fn rename(&self, file_id: &str, new_name: &str) -> Result<DriveFile>
pub async fn rename(&self, file_id: &str, new_name: &str) -> Result<DriveFile>
Renames a file (files.update with a name body, no parents
change — renaming never affects visibility, see ADR-0070). Requires
the drive.metadata scope (drive auth login --write).
Sourcepub async fn move_to(
&self,
file_id: &str,
add_parents: &str,
remove_parents: &str,
) -> Result<DriveFile>
pub async fn move_to( &self, file_id: &str, add_parents: &str, remove_parents: &str, ) -> Result<DriveFile>
Moves a file between folders (files.update with addParents/
removeParents query params, comma-separated file ids — Drive v3 has
no separate move endpoint). Requires the drive.metadata scope
(drive auth login --write).