//! FTP request, response, and session models. #![forbid(unsafe_code)] use crate::{ auth::AuthCredentialModel, http::{HttpHeader, ProxyConfig, RetryStrategy, TlsConfig}, }; /// Transfer mode used by an FTP session. #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum FtpMode { /// Passive mode where the server accepts the data connection. Passive, /// Active mode where the client accepts the data connection. Active, } /// Connection and retry settings for an FTP endpoint. #[derive(Clone, Debug, Eq, PartialEq)] pub struct FtpConfigModel { /// Remote host name or IP. pub host: String, /// Remote control-port number. pub port: u16, /// Optional username for login. pub username: Option, /// Optional password for login. pub password: Option, /// Whether FTPS or other secure transport is expected. pub secure: bool, /// Active or passive data-channel mode. pub mode: FtpMode, /// Initial working directory after login. pub initial_cwd: Option, /// Optional proxy configuration. pub proxy: Option, /// Optional TLS tuning parameters. pub tls: Option, /// Retry strategy for failed requests. pub retry: RetryStrategy, } /// FTP command issued within a request. #[derive(Clone, Debug, Eq, PartialEq)] pub enum FtpCommandModel { /// `USER `. User(String), /// `PASS `. Pass(String), /// `PWD`. Pwd, /// `CWD `. Cwd(String), /// `LIST [path]`. List(Option), /// `SIZE `. Size(String), /// `REST `. Rest(u64), /// `RETR `. Retr(String), /// `QUIT`. Quit, /// Caller-supplied custom FTP command text. Custom(String), } /// FTP session state captured by the protocol layer. #[derive(Clone, Debug, Eq, PartialEq)] pub struct FtpSessionModel { /// Stable session identifier. pub session_id: String, /// Resolved endpoint configuration. pub config: FtpConfigModel, /// Optional authenticated credential. pub auth: Option, /// Default headers propagated into requests. pub default_headers: Vec, } /// FTP request envelope passed into a connector. #[derive(Clone, Debug, Eq, PartialEq)] pub struct FtpRequestModel { /// Command to execute. pub command: FtpCommandModel, /// Optional path or target associated with the command. pub path: Option, /// Additional logical headers attached to the request. pub headers: Vec, } /// FTP response material returned by a connector. #[derive(Clone, Debug, Eq, PartialEq)] pub struct FtpResponseModel { /// Numeric FTP status code. pub code: u16, /// Human-readable server message. pub message: String, /// Optional payload bytes such as directory listings or file contents. pub data: Option>, /// Optional path associated with the response. pub path: Option, /// Whether the response can carry transferable data. pub transferable: bool, }