pub struct TransferClient { /* private fields */ }Expand description
Client for sending files to a peer
Implementations§
Source§impl TransferClient
impl TransferClient
Sourcepub fn new(event_handler: Arc<dyn EventHandler>) -> Self
pub fn new(event_handler: Arc<dyn EventHandler>) -> Self
Create a new transfer client with the given event handler
Sourcepub fn new_with_config(
event_handler: Arc<dyn EventHandler>,
config: &EngineConfig,
) -> Self
pub fn new_with_config( event_handler: Arc<dyn EventHandler>, config: &EngineConfig, ) -> Self
Create a new transfer client with config
Sourcepub fn new_with_history(
event_handler: Arc<dyn EventHandler>,
history: Arc<dyn HistoryPersistence>,
) -> Self
pub fn new_with_history( event_handler: Arc<dyn EventHandler>, history: Arc<dyn HistoryPersistence>, ) -> Self
Create a new transfer client with history persistence
Sourcepub fn new_with_history_and_config(
event_handler: Arc<dyn EventHandler>,
history: Arc<dyn HistoryPersistence>,
config: &EngineConfig,
) -> Self
pub fn new_with_history_and_config( event_handler: Arc<dyn EventHandler>, history: Arc<dyn HistoryPersistence>, config: &EngineConfig, ) -> Self
Create a new transfer client with history and config
Sourcepub fn update_config(&mut self, config: &EngineConfig)
pub fn update_config(&mut self, config: &EngineConfig)
Update retry settings from config
Sourcepub fn resolve_address(address: &str) -> ResolveResult
pub fn resolve_address(address: &str) -> ResolveResult
Resolve a hostname or IP to all available addresses
Sourcepub fn resolve_address_or_err(address: &str) -> EngineResult<Vec<String>>
pub fn resolve_address_or_err(address: &str) -> EngineResult<Vec<String>>
Resolve a hostname or IP, returning an error if resolution fails
Sourcepub async fn check_peer(&self, address: &str, port: u16) -> EngineResult<bool>
pub async fn check_peer(&self, address: &str, port: u16) -> EngineResult<bool>
Check if a peer is reachable by hitting the /health endpoint
Sourcepub async fn get_peer_info(
&self,
address: &str,
port: u16,
) -> EngineResult<Value>
pub async fn get_peer_info( &self, address: &str, port: u16, ) -> EngineResult<Value>
Get peer info
Sourcepub async fn request_transfer(
&self,
address: &str,
port: u16,
transfer_id: &str,
files: Vec<TransferFile>,
sender_name: Option<String>,
) -> EngineResult<TransferResponse>
pub async fn request_transfer( &self, address: &str, port: u16, transfer_id: &str, files: Vec<TransferFile>, sender_name: Option<String>, ) -> EngineResult<TransferResponse>
Initiate a transfer request to a peer
Sourcepub async fn send_files(
&self,
address: &str,
port: u16,
file_paths: Vec<PathBuf>,
sender_name: Option<String>,
) -> EngineResult<()>
pub async fn send_files( &self, address: &str, port: u16, file_paths: Vec<PathBuf>, sender_name: Option<String>, ) -> EngineResult<()>
Send multiple files to a peer
Sourcepub async fn send_directory(
&self,
address: &str,
port: u16,
dir_path: impl AsRef<Path>,
sender_name: Option<String>,
) -> EngineResult<()>
pub async fn send_directory( &self, address: &str, port: u16, dir_path: impl AsRef<Path>, sender_name: Option<String>, ) -> EngineResult<()>
Send a directory and all its contents to a peer
Recursively enumerates all files in the directory and sends them with their relative paths preserved.
Auto Trait Implementations§
impl Freeze for TransferClient
impl !RefUnwindSafe for TransferClient
impl Send for TransferClient
impl Sync for TransferClient
impl Unpin for TransferClient
impl !UnwindSafe for TransferClient
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