pub struct FtpConnection {
pub stream: BufReader<TcpStream>,
pub options: FtpOptions,
pub host: String,
pub port: u16,
}Expand description
FTP control connection state.
Fields§
§stream: BufReader<TcpStream>§options: FtpOptions§host: String§port: u16Implementations§
Source§impl FtpConnection
impl FtpConnection
pub async fn login(&mut self) -> Result<(), String>
pub async fn cwd(&mut self, path: &str) -> Result<(), String>
pub async fn size(&mut self, filename: &str) -> Result<u64, String>
pub async fn mdtm(&mut self, filename: &str) -> Result<String, String>
pub async fn rest(&mut self, offset: u64) -> Result<(), String>
pub async fn retr(&mut self, filename: &str) -> Result<(), String>
pub async fn type_image(&mut self) -> Result<(), String>
pub async fn quit(self) -> Result<(), String>
Sourcepub async fn abor(&mut self) -> Result<(), String>
pub async fn abor(&mut self) -> Result<(), String>
Send ABOR command to abort a transfer in progress.
Sourcepub async fn type_ascii(&mut self) -> Result<(), String>
pub async fn type_ascii(&mut self) -> Result<(), String>
Send TYPE A command for ASCII mode transfer.
Sourcepub async fn noop(&mut self) -> Result<(), String>
pub async fn noop(&mut self) -> Result<(), String>
Send NOOP command for keep-alive / connection test.
Sourcepub async fn run_keepalive(&mut self) -> Result<(), String>
pub async fn run_keepalive(&mut self) -> Result<(), String>
Run the control-channel keep-alive loop.
The caller must dedicate this mutable connection to the loop while it
is running. A shared background task cannot safely write NOOP through
the same stream that another operation is using.
Sourcepub fn start_keepalive(&self) -> Option<JoinHandle<()>>
👎Deprecated: use run_keepalive with an exclusively owned connection
pub fn start_keepalive(&self) -> Option<JoinHandle<()>>
use run_keepalive with an exclusively owned connection
Start the legacy placeholder keep-alive task.
This method only emits a tick and never sends NOOP. Use
Self::run_keepalive when the caller owns the connection exclusively.
Source§impl FtpConnection
impl FtpConnection
pub async fn pasv(&mut self) -> Result<(String, u16), String>
pub async fn epsv(&mut self) -> Result<u16, String>
Sourcepub async fn prepare_port_active(
&mut self,
) -> Result<FtpActiveDataListener, String>
pub async fn prepare_port_active( &mut self, ) -> Result<FtpActiveDataListener, String>
Prepare active mode using the IPv4 PORT command.
Sourcepub async fn port_active(&mut self) -> Result<u16, String>
pub async fn port_active(&mut self) -> Result<u16, String>
Enter active mode using PORT command (IPv4).
This legacy method returns only the port. Call
Self::prepare_port_active when the listener must remain alive until
the server opens the data connection.
Sourcepub async fn prepare_eprt_active(
&mut self,
) -> Result<FtpActiveDataListener, String>
pub async fn prepare_eprt_active( &mut self, ) -> Result<FtpActiveDataListener, String>
Prepare active mode using the extended EPRT command.
Sourcepub async fn eprt_active(&mut self) -> Result<(String, u16), String>
pub async fn eprt_active(&mut self) -> Result<(String, u16), String>
Enter active mode using EPRT and return the advertised endpoint.
This legacy method returns only the endpoint. Call
Self::prepare_eprt_active when the listener must remain alive until
the server opens the data connection.
Sourcepub async fn list(&mut self, path: Option<&str>) -> Result<FtpResponse, String>
pub async fn list(&mut self, path: Option<&str>) -> Result<FtpResponse, String>
Send LIST command to get directory listing (detailed format).
Sourcepub async fn nlst(&mut self, path: Option<&str>) -> Result<FtpResponse, String>
pub async fn nlst(&mut self, path: Option<&str>) -> Result<FtpResponse, String>
Send NLST command to get directory listing (names only).
Sourcepub fn control_stream(&mut self) -> &mut BufReader<TcpStream>
pub fn control_stream(&mut self) -> &mut BufReader<TcpStream>
Borrow the FTP control stream.
Sourcepub fn get_data_stream(&mut self) -> &mut BufReader<TcpStream>
👎Deprecated: this returns the control stream; use control_stream
pub fn get_data_stream(&mut self) -> &mut BufReader<TcpStream>
this returns the control stream; use control_stream
Legacy misnamed accessor that returns the control stream, not a data
connection. Use Self::control_stream or the data-channel methods.
Source§impl FtpConnection
impl FtpConnection
Sourcepub async fn connect(
host: &str,
port: u16,
options: Option<FtpOptions>,
) -> Result<Self, String>
pub async fn connect( host: &str, port: u16, options: Option<FtpOptions>, ) -> Result<Self, String>
Establish a control connection and consume the server welcome response.
Sourcepub async fn read_response(&mut self) -> Result<FtpResponse, String>
pub async fn read_response(&mut self) -> Result<FtpResponse, String>
Read one FTP response, including multiline responses.