FolderHandler

Struct FolderHandler 

Source
pub struct FolderHandler { /* private fields */ }
Expand description

Handler for folder operations

Provides methods for listing, creating, searching, and managing folders (directories) in Files.com.

Implementations§

Source§

impl FolderHandler

Source

pub fn new(client: FilesClient) -> Self

Creates a new FolderHandler

§Arguments
  • client - FilesClient instance
Source

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");
}
Source

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());
Source

pub fn list_stream( &self, path: &str, per_page: Option<i32>, ) -> impl Stream<Item = Result<FileEntity>> + '_

Stream folder contents with automatic pagination

Returns a stream that automatically handles pagination, yielding individual files as they are fetched. This is more memory-efficient than list_folder_all() for large directories.

§Arguments
  • path - Folder path to list
  • per_page - Number of items per page (optional, default 1000)
§Examples
let handler = FolderHandler::new(client);
let stream = handler.list_stream("/uploads", Some(100));

tokio::pin!(stream);

while let Some(file) = stream.next().await {
    let file = file?;
    println!("{}", file.path.unwrap_or_default());
}
Source

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 create
  • mkdir_parents - Create parent directories if they don’t exist
§Examples
let handler = FolderHandler::new(client);
handler.create_folder("/new/folder", true).await?;
Source

pub async fn delete_folder(&self, path: &str, recursive: bool) -> Result<()>

Delete a folder

§Arguments
  • path - Folder path to delete
  • recursive - Delete folder and all contents recursively
§Examples
let handler = FolderHandler::new(client);
handler.delete_folder("/old/folder", true).await?;
Source

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 in
  • search - Search query string
  • per_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

Source§

fn clone(&self) -> FolderHandler

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FolderHandler

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,