[][src]Struct ftp_client::client::Client

pub struct Client { /* fields omitted */ }

The Client is where most of the functionality is, it keeps a control connection open and opens up data connections as commands are issued. This struct is a very thin wrapper over the FTP protocol.

Methods

impl Client[src]

pub fn set_mode(&mut self, mode: ClientMode)[src]

Set the mode for the client.

pub fn connect(
    hostname: &str,
    user: &str,
    password: &str
) -> Result<Self, Error>
[src]

Connect to a new FTP server using plain text (no TLS).

pub fn connect_tls(
    hostname: &str,
    user: &str,
    password: &str
) -> Result<Self, Error>
[src]

Connect to a new FTP server using a secure connection (TLS).

pub fn connect_tls_with_port(
    hostname: &str,
    port: u32,
    user: &str,
    password: &str
) -> Result<Self, Error>
[src]

Connect to a new FTP server using a secure connection (TLS) on a specific port.

pub fn connect_with_port(
    hostname: &str,
    port: u32,
    user: &str,
    password: &str
) -> Result<Self, Error>
[src]

Connect to a new FTP server using plain text (no TLS) on a specific port.

pub fn get_welcome(&self) -> Option<&String>[src]

Get the welcome message sent by the server at the connection establishment.

pub fn login(&mut self, user: &str, password: &str) -> Result<(), Error>[src]

Login using the given user and password. Note that many servers require a login with an anonymous user, such as client.login("anonymous", "anonymous@mail.com").

pub fn logout(&mut self) -> Result<(), Error>[src]

Logout from the current user/password pair.

pub fn cwd(&mut self, dir: &str) -> Result<(), Error>[src]

Change the working directory on the current session.

pub fn cdup(&mut self) -> Result<(), Error>[src]

Go up to the parent directory on the current session.

pub fn help(&mut self) -> Result<(), Error>[src]

Show server information regarding its implementation status to the user.

The help command can also be used with an argument to see detailed information about a single command, this behaviour is not implemented.

pub fn noop(&mut self) -> Result<(), Error>[src]

This command should not do anything other than receiving an OK response from the server.

pub fn status(&mut self) -> Result<String, Error>[src]

Get the current reported status from the server. This can be used during transfer and between them. This command can be used with and argument to get behaviour similar to LIST, this particular behaviour is not implemented.

pub fn list(&mut self, path: &str) -> Result<String, Error>[src]

List the provided path in any way the server desires.

pub fn list_names(&mut self, path: &str) -> Result<Vec<String>, Error>[src]

List the provided path, providing only name information about files and directories.

pub fn store<B: AsRef<[u8]>>(
    &mut self,
    path: &str,
    data: B
) -> Result<(), Error>
[src]

Store a new file on a provided path and name.

pub fn store_unique<B: AsRef<[u8]>>(&mut self, data: B) -> Result<String, Error>[src]

Store a new file on a provided path using a random unique name.

pub fn append<B: AsRef<[u8]>>(
    &mut self,
    path: &str,
    data: B
) -> Result<(), Error>
[src]

Append to a existing file or a create a new one.

pub fn restart(&mut self) -> Result<(), Error>[src]

Restart a file transfer. Unimplemented.

pub fn abort(&mut self) -> Result<(), Error>[src]

Abort a file transfer. Unimplemented.

pub fn allocate(
    &mut self,
    _logical_size: usize,
    _logical_page_size: Option<usize>
) -> Result<(), Error>
[src]

Preallocate space on the server. Unimplemented.

pub fn rename_file(
    &mut self,
    path_from: &str,
    path_to: &str
) -> Result<(), Error>
[src]

Move a file from a path to another, essentially renaming it.

pub fn remove_directory(&mut self, dir_path: &str) -> Result<(), Error>[src]

Remove an existing directory.

pub fn make_directory(&mut self, dir_path: &str) -> Result<(), Error>[src]

Make a new directory.

pub fn pwd(&mut self) -> Result<String, Error>[src]

Get the current working directory.

pub fn site_parameters(&mut self) -> Result<String, Error>[src]

This command is used by the server to provide services specific to his system that are essential to file transfer but not sufficiently universal to be included as commands in the protocol.

The nature of these services and the specification of their syntax can be stated in a reply to the HELP SITE command.

Extracted from RFC959.

pub fn system(&mut self) -> Result<String, Error>[src]

Get the type of operating system on the server.

pub fn delete_file(&mut self, dir_path: &str) -> Result<(), Error>[src]

Delete a file at a path.

pub fn retrieve_file(&mut self, path: &str) -> Result<Vec<u8>, Error>[src]

Download a file at a path into a byte buffer.

pub fn get_data_connection(&mut self) -> Result<BufReader<TcpStream>, Error>[src]

Acquire the data connection using the current ClientMode.

pub fn extended_passive_mode_connection(
    &mut self
) -> Result<BufReader<TcpStream>, Error>
[src]

Create a extended passive mode connection.

pub fn passive_mode_connection(&mut self) -> Result<BufReader<TcpStream>, Error>[src]

Create a passive mode connection.

pub fn write_unary_command_expecting(
    &mut self,
    cmd: &str,
    arg: &str,
    valid_statuses: Vec<StatusCodeKind>
) -> Result<ServerResponse, Error>
[src]

Write a command with one argument to the server expecting a list of positive status codes.

pub fn write_unary_command(&mut self, cmd: &str, arg: &str) -> Result<(), Error>[src]

Write a command with one argument to the server.

pub fn write_command_expecting(
    &mut self,
    cmd: &str,
    valid_statuses: Vec<StatusCodeKind>
) -> Result<ServerResponse, Error>
[src]

Write a command to the server expecting a list of positive status codes.

pub fn write_command(&mut self, cmd: &str) -> Result<(), Error>[src]

Write a command to the server.

pub fn parse_reply_expecting(
    &mut self,
    valid_statuses: Vec<StatusCodeKind>
) -> Result<ServerResponse, Error>
[src]

Parse the server reply into a ServerResponse expecting a list of status codes.

pub fn parse_reply(&mut self) -> Result<ServerResponse, Error>[src]

Parse the server reply into a ServerResponse.

pub fn read_reply(&mut self) -> Result<String, Error>[src]

Read the server reply as a raw string.

Auto Trait Implementations

impl Send for Client

impl Sync for Client

impl Unpin for Client

impl UnwindSafe for Client

impl RefUnwindSafe for Client

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,