Skip to main content

FtpConnection

Struct FtpConnection 

Source
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: u16

Implementations§

Source§

impl FtpConnection

Source

pub async fn login(&mut self) -> Result<(), String>

Source

pub async fn cwd(&mut self, path: &str) -> Result<(), String>

Source

pub async fn size(&mut self, filename: &str) -> Result<u64, String>

Source

pub async fn mdtm(&mut self, filename: &str) -> Result<String, String>

Source

pub async fn rest(&mut self, offset: u64) -> Result<(), String>

Source

pub async fn retr(&mut self, filename: &str) -> Result<(), String>

Source

pub async fn type_image(&mut self) -> Result<(), String>

Source

pub async fn quit(self) -> Result<(), String>

Source

pub async fn abor(&mut self) -> Result<(), String>

Send ABOR command to abort a transfer in progress.

Source

pub async fn type_ascii(&mut self) -> Result<(), String>

Send TYPE A command for ASCII mode transfer.

Source

pub async fn noop(&mut self) -> Result<(), String>

Send NOOP command for keep-alive / connection test.

Source

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.

Source

pub fn start_keepalive(&self) -> Option<JoinHandle<()>>

👎Deprecated:

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

Source

pub async fn pasv(&mut self) -> Result<(String, u16), String>

Source

pub async fn epsv(&mut self) -> Result<u16, String>

Source

pub async fn prepare_port_active( &mut self, ) -> Result<FtpActiveDataListener, String>

Prepare active mode using the IPv4 PORT command.

Source

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.

Source

pub async fn prepare_eprt_active( &mut self, ) -> Result<FtpActiveDataListener, String>

Prepare active mode using the extended EPRT command.

Source

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.

Source

pub async fn list(&mut self, path: Option<&str>) -> Result<FtpResponse, String>

Send LIST command to get directory listing (detailed format).

Source

pub async fn nlst(&mut self, path: Option<&str>) -> Result<FtpResponse, String>

Send NLST command to get directory listing (names only).

Source

pub fn control_stream(&mut self) -> &mut BufReader<TcpStream>

Borrow the FTP control stream.

Source

pub fn get_data_stream(&mut self) -> &mut BufReader<TcpStream>

👎Deprecated:

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

Source

pub async fn connect( host: &str, port: u16, options: Option<FtpOptions>, ) -> Result<Self, String>

Establish a control connection and consume the server welcome response.

Source

pub async fn read_response(&mut self) -> Result<FtpResponse, String>

Read one FTP response, including multiline responses.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more