Skip to main content

TransferTrait

Trait TransferTrait 

Source
pub trait TransferTrait: Send + Sync {
    // Required methods
    fn prepare<'life0, 'life1, 'async_trait>(
        &'life0 self,
        task: &'life1 TransferTask,
        local_offset: u64,
    ) -> Pin<Box<dyn Future<Output = Result<PrepareOutcome, MeowError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn transfer_chunk<'life0, 'life1, 'async_trait>(
        &'life0 self,
        task: &'life1 TransferTask,
        offset: u64,
        chunk_size: u64,
        remote_total_size: u64,
    ) -> Pin<Box<dyn Future<Output = Result<ChunkOutcome, MeowError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn cancel<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _task: &'life1 TransferTask,
    ) -> Pin<Box<dyn Future<Output = Result<(), MeowError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Low-level transfer executor abstraction used by scheduler/runtime.

Most users do not implement this trait directly unless they are building a custom transport backend.

§Examples

use async_trait::async_trait;
use rusty_cat::api::{ChunkOutcome, MeowError, PrepareOutcome, TransferTask, TransferTrait};

struct NoopExecutor;

#[async_trait]
impl TransferTrait for NoopExecutor {
    async fn prepare(
        &self,
        _task: &TransferTask,
        local_offset: u64,
    ) -> Result<PrepareOutcome, MeowError> {
        Ok(PrepareOutcome { next_offset: local_offset, total_size: local_offset })
    }

    async fn transfer_chunk(
        &self,
        _task: &TransferTask,
        offset: u64,
        _chunk_size: u64,
        remote_total_size: u64,
    ) -> Result<ChunkOutcome, MeowError> {
        Ok(ChunkOutcome {
            next_offset: offset,
            total_size: remote_total_size,
            done: true,
            completion_payload: None,
        })
    }
}

Required Methods§

Source

fn prepare<'life0, 'life1, 'async_trait>( &'life0 self, task: &'life1 TransferTask, local_offset: u64, ) -> Pin<Box<dyn Future<Output = Result<PrepareOutcome, MeowError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Prepares transfer state and computes the next offset to run.

§Parameters
  • task: Immutable task snapshot.
  • local_offset: Current local persisted offset, in bytes.
§Returns

Returns PrepareOutcome containing next offset and total size.

§Errors

Return MeowError when checkpoint probing, local/remote validation, or protocol initialization fails.

§Examples
use rusty_cat::api::TransferTask;

fn inspect_prepare_input(task: &TransferTask, local_offset: u64) {
    let _ = (task.url(), local_offset);
}
Source

fn transfer_chunk<'life0, 'life1, 'async_trait>( &'life0 self, task: &'life1 TransferTask, offset: u64, chunk_size: u64, remote_total_size: u64, ) -> Pin<Box<dyn Future<Output = Result<ChunkOutcome, MeowError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Transfers one chunk from the given offset.

§Parameters
  • offset: Start byte offset for this chunk.
  • chunk_size: Desired chunk size in bytes (>= 1 recommended).
  • remote_total_size: For download, use prepare.total_size; for upload, usually equals task.total_size().
§Errors

Return MeowError when chunk transfer fails, range validation fails, or local file I/O fails.

§Examples
use rusty_cat::api::TransferTask;

fn inspect_chunk_input(task: &TransferTask, offset: u64, chunk_size: u64, remote_total_size: u64) {
    let _ = (task.file_name(), offset, chunk_size, remote_total_size);
}

Provided Methods§

Source

fn cancel<'life0, 'life1, 'async_trait>( &'life0 self, _task: &'life1 TransferTask, ) -> Pin<Box<dyn Future<Output = Result<(), MeowError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Handles protocol-specific cancel semantics.

Default implementation is a no-op.

§Errors

Implementations should return MeowError if remote abort/cancel actions fail.

Implementors§