pub struct FileTransferProtocol {
pub path: PathBuf,
pub chunk_size: u64,
}Expand description
Defines the file transfer protocol, allowing files and directories to be transferred.
Fields§
§path: PathBufThe path of the file or directory to transfer.
chunk_size: u64The chunk size in bytes for data transfer.
Implementations§
Source§impl FileTransferProtocol
impl FileTransferProtocol
Sourcepub fn new(path: &Path, chunk_size: u64) -> Self
pub fn new(path: &Path, chunk_size: u64) -> Self
Creates a new instance of FileTransferProtocol.
Sourcepub async fn init_send(
&self,
connection: &mut Connection<'_>,
) -> Result<(), TransferError>
pub async fn init_send( &self, connection: &mut Connection<'_>, ) -> Result<(), TransferError>
Initiates sending a file or directory based on the path provided.
Sourcepub async fn init_receive(
&self,
connection: &mut Connection<'_>,
path_type: &PathType,
) -> Result<(), TransferError>
pub async fn init_receive( &self, connection: &mut Connection<'_>, path_type: &PathType, ) -> Result<(), TransferError>
Initiates receiving a file or directory based on the path_type provided.
Sourcepub async fn send_file(
&self,
connection: &mut Connection<'_>,
) -> Result<(), TransferError>
pub async fn send_file( &self, connection: &mut Connection<'_>, ) -> Result<(), TransferError>
Sends a file in chunks over the TCP connection.
Sourcepub async fn receive_file(
&self,
connection: &mut Connection<'_>,
) -> Result<(), TransferError>
pub async fn receive_file( &self, connection: &mut Connection<'_>, ) -> Result<(), TransferError>
Receives a file in chunks and writes it to disk.
Sourcepub fn send_directory<'a>(
&'a self,
connection: &'a mut Connection<'_>,
) -> BoxFuture<'a, Result<(), TransferError>>
pub fn send_directory<'a>( &'a self, connection: &'a mut Connection<'_>, ) -> BoxFuture<'a, Result<(), TransferError>>
Sends a directory and its contents recursively over the TCP connection.
Sourcepub async fn receive_directory(
&self,
connection: &mut Connection<'_>,
) -> Result<(), TransferError>
pub async fn receive_directory( &self, connection: &mut Connection<'_>, ) -> Result<(), TransferError>
Receives a directory and its contents recursively from the TCP connection.
Auto Trait Implementations§
impl Freeze for FileTransferProtocol
impl RefUnwindSafe for FileTransferProtocol
impl Send for FileTransferProtocol
impl Sync for FileTransferProtocol
impl Unpin for FileTransferProtocol
impl UnwindSafe for FileTransferProtocol
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