FsFile as argument for both recv_file and send_file

This commit is contained in:
ChristianVisintin
2020-12-05 14:52:53 +01:00
parent 54c02cd4e2
commit b45440586b
4 changed files with 62 additions and 19 deletions

View File

@@ -26,7 +26,7 @@
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use crate::fs::FsEntry;
use crate::fs::{FsFile, FsEntry};
// Transfers
pub mod ftp_transfer;
@@ -167,6 +167,7 @@ pub trait FileTransfer {
/// ### mkdir
///
/// Make directory
/// You must return error in case the directory already exists
fn mkdir(&mut self, dir: &Path) -> Result<(), FileTransferError>;
/// ### remove
@@ -190,13 +191,13 @@ pub trait FileTransfer {
/// File name is referred to the name of the file as it will be saved
/// Data contains the file data
/// Returns file and its size
fn send_file(&mut self, file_name: &Path) -> Result<Box<dyn Write>, FileTransferError>;
fn send_file(&mut self, local: &FsFile, file_name: &Path) -> Result<Box<dyn Write>, FileTransferError>;
/// ### recv_file
///
/// Receive file from remote with provided name
/// Returns file and its size
fn recv_file(&mut self, file_name: &Path) -> Result<Box<dyn Read>, FileTransferError>;
fn recv_file(&mut self, file: &FsFile) -> Result<Box<dyn Read>, FileTransferError>;
/// ### on_sent
///