pub struct FolderHandler { /* private fields */ }
Expand description
Handler for folder operations
Provides methods for listing, creating, and managing folders.
Implementations§
Source§impl FolderHandler
impl FolderHandler
Sourcepub fn new(client: FilesClient) -> Self
pub fn new(client: FilesClient) -> Self
Sourcepub async fn list_folder(
&self,
path: &str,
per_page: Option<i32>,
cursor: Option<String>,
) -> Result<(Vec<FileEntity>, PaginationInfo)>
pub async fn list_folder( &self, path: &str, per_page: Option<i32>, cursor: Option<String>, ) -> Result<(Vec<FileEntity>, PaginationInfo)>
List folder contents
Returns files and subdirectories within the specified folder.
§Arguments
path
- Folder path to list (empty string for root)per_page
- Number of items per page (optional, max 10,000)cursor
- Pagination cursor (optional)
§Returns
Returns a tuple of (files, pagination_info)
§Examples
use files_sdk::{FilesClient, FolderHandler};
let client = FilesClient::builder()
.api_key("your-api-key")
.build()?;
let handler = FolderHandler::new(client);
let (files, pagination) = handler.list_folder("/", None, None).await?;
for file in files {
println!("{}: {}", file.file_type.unwrap_or_default(), file.path.unwrap_or_default());
}
if pagination.has_next() {
println!("More results available");
}
Sourcepub async fn list_folder_all(&self, path: &str) -> Result<Vec<FileEntity>>
pub async fn list_folder_all(&self, path: &str) -> Result<Vec<FileEntity>>
List all folder contents (auto-pagination)
Automatically handles pagination to retrieve all items in a folder.
§Arguments
path
- Folder path to list
§Examples
let handler = FolderHandler::new(client);
let all_files = handler.list_folder_all("/uploads").await?;
println!("Total files: {}", all_files.len());
Sourcepub async fn create_folder(
&self,
path: &str,
mkdir_parents: bool,
) -> Result<FileEntity>
pub async fn create_folder( &self, path: &str, mkdir_parents: bool, ) -> Result<FileEntity>
Create a new folder
Note: In Files.com, folders are created implicitly when uploading files
with mkdir_parents=true
. This method creates an empty folder.
§Arguments
path
- Folder path to createmkdir_parents
- Create parent directories if they don’t exist
§Examples
let handler = FolderHandler::new(client);
handler.create_folder("/new/folder", true).await?;
Sourcepub async fn search_folder(
&self,
path: &str,
search: &str,
per_page: Option<i32>,
) -> Result<(Vec<FileEntity>, PaginationInfo)>
pub async fn search_folder( &self, path: &str, search: &str, per_page: Option<i32>, ) -> Result<(Vec<FileEntity>, PaginationInfo)>
Search for files within a folder
§Arguments
path
- Folder path to search insearch
- Search query stringper_page
- Number of results per page (optional)
§Examples
let handler = FolderHandler::new(client);
let (results, _) = handler.search_folder("/", "report", None).await?;
println!("Found {} files", results.len());
Trait Implementations§
Source§impl Clone for FolderHandler
impl Clone for FolderHandler
Source§fn clone(&self) -> FolderHandler
fn clone(&self) -> FolderHandler
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for FolderHandler
impl !RefUnwindSafe for FolderHandler
impl Send for FolderHandler
impl Sync for FolderHandler
impl Unpin for FolderHandler
impl !UnwindSafe for FolderHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more