FileTransferService

Trait FileTransferService 

Source
pub trait FileTransferService: Send + Sync {
    // Required methods
    fn send_file<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        target: NodeId,
        source_path: &'life1 Path,
        dest_path: &'life2 Path,
        options: TransferOptions,
    ) -> Pin<Box<dyn Future<Output = Result<TransferHandle, FileTransferError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;
    fn broadcast_file<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        source_path: &'life1 Path,
        dest_path: &'life2 Path,
        options: TransferOptions,
    ) -> Pin<Box<dyn Future<Output = Result<BroadcastHandle, FileTransferError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;
    fn sync_file<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        local_path: &'life1 Path,
        remote_path: &'life2 Path,
        targets: Option<Vec<NodeId>>,
        options: SyncOptions,
    ) -> Pin<Box<dyn Future<Output = Result<SyncHandle, FileTransferError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;
    fn exists<'life0, 'life1, 'async_trait>(
        &'life0 self,
        target: NodeId,
        path: &'life1 Path,
    ) -> Pin<Box<dyn Future<Output = Result<bool, FileTransferError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn remove<'life0, 'life1, 'async_trait>(
        &'life0 self,
        target: NodeId,
        path: &'life1 Path,
        options: RemoveOptions,
    ) -> Pin<Box<dyn Future<Output = Result<(), FileTransferError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn metadata<'life0, 'life1, 'async_trait>(
        &'life0 self,
        target: NodeId,
        path: &'life1 Path,
    ) -> Pin<Box<dyn Future<Output = Result<FileMetadata, FileTransferError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn list_files<'life0, 'life1, 'async_trait>(
        &'life0 self,
        target: NodeId,
        dir_path: &'life1 Path,
        options: ListOptions,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<FileInfo>, FileTransferError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn cancel_transfer<'life0, 'async_trait>(
        &'life0 self,
        session_id: TransferSessionId,
    ) -> Pin<Box<dyn Future<Output = Result<(), FileTransferError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn pause_transfer<'life0, 'async_trait>(
        &'life0 self,
        session_id: TransferSessionId,
    ) -> Pin<Box<dyn Future<Output = Result<(), FileTransferError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn resume_transfer<'life0, 'async_trait>(
        &'life0 self,
        session_id: TransferSessionId,
    ) -> Pin<Box<dyn Future<Output = Result<TransferHandle, FileTransferError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn active_transfers(&self) -> Vec<TransferSessionInfo>;
}
Expand description

High-level file transfer service API.

Required Methods§

Source

fn send_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, target: NodeId, source_path: &'life1 Path, dest_path: &'life2 Path, options: TransferOptions, ) -> Pin<Box<dyn Future<Output = Result<TransferHandle, FileTransferError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Sends a file to a target node.

§Errors

Returns FileTransferError for validation, I/O, or transport failures.

§Panics

This method does not panic.

§Examples
use alopex_chirps_file_transfer::{FileTransferService, TransferOptions};
use alopex_chirps_wire::node_id::NodeId;
use std::path::Path;

async fn send(
    service: &dyn FileTransferService,
) -> Result<(), alopex_chirps_file_transfer::FileTransferError> {
    let target = NodeId::new();
    service
        .send_file(
            target,
            Path::new("source.bin"),
            Path::new("dest.bin"),
            TransferOptions::default(),
        )
        .await?;
    Ok(())
}
Source

fn broadcast_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, source_path: &'life1 Path, dest_path: &'life2 Path, options: TransferOptions, ) -> Pin<Box<dyn Future<Output = Result<BroadcastHandle, FileTransferError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Sends a file to all connected peers.

§Errors

Returns FileTransferError for validation, I/O, or transport failures.

§Panics

This method does not panic.

§Examples
use alopex_chirps_file_transfer::{FileTransferService, TransferOptions};
use std::path::Path;

async fn broadcast(
    service: &dyn FileTransferService,
) -> Result<(), alopex_chirps_file_transfer::FileTransferError> {
    service
        .broadcast_file(
            Path::new("source.bin"),
            Path::new("dest.bin"),
            TransferOptions::default(),
        )
        .await?;
    Ok(())
}
Source

fn sync_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, local_path: &'life1 Path, remote_path: &'life2 Path, targets: Option<Vec<NodeId>>, options: SyncOptions, ) -> Pin<Box<dyn Future<Output = Result<SyncHandle, FileTransferError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Synchronizes a local path with a remote path.

§Errors

Returns FileTransferError for validation, I/O, or transport failures.

§Panics

This method does not panic.

§Examples
use alopex_chirps_file_transfer::{FileTransferService, SyncOptions};
use alopex_chirps_wire::node_id::NodeId;
use std::path::Path;

async fn sync(
    service: &dyn FileTransferService,
) -> Result<(), alopex_chirps_file_transfer::FileTransferError> {
    let target = NodeId::new();
    service
        .sync_file(
            Path::new("local.db"),
            Path::new("remote.db"),
            Some(vec![target]),
            SyncOptions::default(),
        )
        .await?;
    Ok(())
}
Source

fn exists<'life0, 'life1, 'async_trait>( &'life0 self, target: NodeId, path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<bool, FileTransferError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Checks if a path exists on a target node.

§Errors

Returns FileTransferError for validation or transport failures.

§Panics

This method does not panic.

§Examples
use alopex_chirps_file_transfer::FileTransferService;
use alopex_chirps_wire::node_id::NodeId;
use std::path::Path;

async fn check(
    service: &dyn FileTransferService,
) -> Result<(), alopex_chirps_file_transfer::FileTransferError> {
    let target = NodeId::new();
    let exists = service.exists(target, Path::new("data.bin")).await?;
    let _ = exists;
    Ok(())
}
Source

fn remove<'life0, 'life1, 'async_trait>( &'life0 self, target: NodeId, path: &'life1 Path, options: RemoveOptions, ) -> Pin<Box<dyn Future<Output = Result<(), FileTransferError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Removes a file or directory on a target node.

§Errors

Returns FileTransferError for validation or transport failures.

§Panics

This method does not panic.

§Examples
use alopex_chirps_file_transfer::{FileTransferService, RemoveOptions};
use alopex_chirps_wire::node_id::NodeId;
use std::path::Path;

async fn remove_path(
    service: &dyn FileTransferService,
) -> Result<(), alopex_chirps_file_transfer::FileTransferError> {
    let target = NodeId::new();
    service
        .remove(target, Path::new("data.bin"), RemoveOptions::default())
        .await?;
    Ok(())
}
Source

fn metadata<'life0, 'life1, 'async_trait>( &'life0 self, target: NodeId, path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<FileMetadata, FileTransferError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Fetches metadata for a file or directory on a target node.

§Errors

Returns FileTransferError for validation or transport failures.

§Panics

This method does not panic.

§Examples
use alopex_chirps_file_transfer::FileTransferService;
use alopex_chirps_wire::node_id::NodeId;
use std::path::Path;

async fn read_metadata(
    service: &dyn FileTransferService,
) -> Result<(), alopex_chirps_file_transfer::FileTransferError> {
    let target = NodeId::new();
    let metadata = service.metadata(target, Path::new("data.bin")).await?;
    let _ = metadata;
    Ok(())
}
Source

fn list_files<'life0, 'life1, 'async_trait>( &'life0 self, target: NodeId, dir_path: &'life1 Path, options: ListOptions, ) -> Pin<Box<dyn Future<Output = Result<Vec<FileInfo>, FileTransferError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Lists files within a directory on a target node.

§Errors

Returns FileTransferError for validation or transport failures.

§Panics

This method does not panic.

§Examples
use alopex_chirps_file_transfer::{FileTransferService, ListOptions};
use alopex_chirps_wire::node_id::NodeId;
use std::path::Path;

async fn list(
    service: &dyn FileTransferService,
) -> Result<(), alopex_chirps_file_transfer::FileTransferError> {
    let target = NodeId::new();
    let files = service
        .list_files(target, Path::new("data"), ListOptions::default())
        .await?;
    let _ = files;
    Ok(())
}
Source

fn cancel_transfer<'life0, 'async_trait>( &'life0 self, session_id: TransferSessionId, ) -> Pin<Box<dyn Future<Output = Result<(), FileTransferError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Cancels an active transfer by session id.

§Errors

Returns FileTransferError if the session cannot be cancelled.

§Panics

This method does not panic.

§Examples
use alopex_chirps_file_transfer::{FileTransferService, TransferSessionId};

async fn cancel(
    service: &dyn FileTransferService,
) -> Result<(), alopex_chirps_file_transfer::FileTransferError> {
    let session_id = TransferSessionId::new();
    service.cancel_transfer(session_id).await?;
    Ok(())
}
Source

fn pause_transfer<'life0, 'async_trait>( &'life0 self, session_id: TransferSessionId, ) -> Pin<Box<dyn Future<Output = Result<(), FileTransferError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Pauses an active transfer by session id.

§Errors

Returns FileTransferError if the session cannot be paused.

§Panics

This method does not panic.

§Examples
use alopex_chirps_file_transfer::{FileTransferService, TransferSessionId};

async fn pause(
    service: &dyn FileTransferService,
) -> Result<(), alopex_chirps_file_transfer::FileTransferError> {
    let session_id = TransferSessionId::new();
    service.pause_transfer(session_id).await?;
    Ok(())
}
Source

fn resume_transfer<'life0, 'async_trait>( &'life0 self, session_id: TransferSessionId, ) -> Pin<Box<dyn Future<Output = Result<TransferHandle, FileTransferError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Resumes a paused transfer by session id.

§Errors

Returns FileTransferError if the session cannot be resumed.

§Panics

This method does not panic.

§Examples
use alopex_chirps_file_transfer::{FileTransferService, TransferSessionId};

async fn resume(
    service: &dyn FileTransferService,
) -> Result<(), alopex_chirps_file_transfer::FileTransferError> {
    let session_id = TransferSessionId::new();
    let handle = service.resume_transfer(session_id).await?;
    let _ = handle;
    Ok(())
}
Source

fn active_transfers(&self) -> Vec<TransferSessionInfo>

Returns a snapshot of active transfer sessions.

§Examples
use alopex_chirps_file_transfer::FileTransferService;

fn snapshot(service: &dyn FileTransferService) {
    let sessions = service.active_transfers();
    let _ = sessions;
}
§Panics

This method does not panic.

Implementors§