(
credentials: &FtpCredentials,
file_path: Option<&str>,
)
| 39 | } |
| 40 | |
| 41 | pub async fn list_objects( |
| 42 | credentials: &FtpCredentials, |
| 43 | file_path: Option<&str>, |
| 44 | ) -> Result<Vec<String>, String> { |
| 45 | if credentials.is_secure { |
| 46 | match secure_connect(credentials).await { |
| 47 | Ok(mut ftp_stream) => match ftp_stream.nlst(file_path).await { |
| 48 | Ok(files) => { |
| 49 | disconnect(None, Some(&mut ftp_stream)).await; |
| 50 | Ok(files) |
| 51 | } |
| 52 | Err(err) => { |
| 53 | disconnect(None, Some(&mut ftp_stream)).await; |
| 54 | Err(format!("Unable to list objects: {}", err)) |
| 55 | } |
| 56 | }, |
| 57 | Err(err) => Err(format!("Unable to list objects: {}", err)), |
| 58 | } |
| 59 | } else { |
| 60 | match insecure_connect(credentials).await { |
| 61 | Ok(mut ftp_stream) => match ftp_stream.nlst(file_path).await { |
| 62 | Ok(files) => { |
| 63 | disconnect(Some(&mut ftp_stream), None).await; |
| 64 | Ok(files) |
| 65 | } |
| 66 | Err(err) => { |
| 67 | disconnect(Some(&mut ftp_stream), None).await; |
| 68 | Err(format!("Unable to list objects: {}", err)) |
| 69 | } |
| 70 | }, |
| 71 | Err(err) => Err(format!("Unable to list objects: {}", err)), |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | pub async fn fetch_object( |
| 77 | credentials: &FtpCredentials, |
no test coverage detected