Struct ftp::FtpStream
[−]
[src]
pub struct FtpStream { /* fields omitted */ }
Stream to interface with the FTP server. This interface is only for the command stream.
Methods
impl FtpStream
[src]
pub fn connect<A: ToSocketAddrs>(addr: A) -> Result<FtpStream>
[src]
Creates an FTP Stream.
ⓘImportant traits for &'a TcpStreampub fn get_ref(&self) -> &TcpStream
[src]
Returns a reference to the underlying TcpStream.
Example:
use std::net::TcpStream; let stream = FtpStream::connect("127.0.0.1:21") .expect("Couldn't connect to the server..."); stream.get_ref().set_read_timeout(Duration::from_secs(10)) .expect("set_read_timeout call failed");
pub fn login(&mut self, user: &str, password: &str) -> Result<()>
[src]
Log in to the FTP server.
pub fn cwd(&mut self, path: &str) -> Result<()>
[src]
Change the current directory to the path specified.
pub fn cdup(&mut self) -> Result<()>
[src]
Move the current directory to the parent directory.
pub fn pwd(&mut self) -> Result<String>
[src]
Gets the current directory
pub fn noop(&mut self) -> Result<()>
[src]
This does nothing. This is usually just used to keep the connection open.
pub fn mkdir(&mut self, pathname: &str) -> Result<()>
[src]
This creates a new directory on the server.
pub fn transfer_type(&mut self, file_type: FileType) -> Result<()>
[src]
Sets the type of file to be transferred. That is the implementation
of TYPE
command.
pub fn quit(&mut self) -> Result<()>
[src]
Quits the current FTP session.
pub fn get(&mut self, file_name: &str) -> Result<BufReader<DataStream>>
[src]
Retrieves the file name specified from the server. This method is a more complicated way to retrieve a file. The reader returned should be dropped. Also you will have to read the response to make sure it has the correct value.
pub fn rename(&mut self, from_name: &str, to_name: &str) -> Result<()>
[src]
Renames the file from_name to to_name
pub fn retr<F, T>(&mut self, filename: &str, reader: F) -> Result<T> where
F: Fn(&mut Read) -> Result<T>,
[src]
F: Fn(&mut Read) -> Result<T>,
The implementation of RETR
command where filename
is the name of the file
to download from FTP and reader
is the function which operates with the
data stream opened.
assert!(conn.retr("retr.txt", |stream| { let mut buf = Vec::new(); stream.read_to_end(&mut buf).map(|_| assert_eq!(buf, "hello, world!".as_bytes()) ).map_err(|e| FtpError::ConnectionError(e)) }).is_ok());
pub fn simple_retr(&mut self, file_name: &str) -> Result<Cursor<Vec<u8>>>
[src]
Simple way to retr a file from the server. This stores the file in memory.
let cursor = conn.simple_retr("simple_retr.txt").unwrap(); // do something with bytes assert_eq!(cursor.into_inner(), "hello, world!".as_bytes());
pub fn rmdir(&mut self, pathname: &str) -> Result<()>
[src]
Removes the remote pathname from the server.
pub fn rm(&mut self, filename: &str) -> Result<()>
[src]
Remove the remote file from the server.
pub fn put<R: Read>(&mut self, filename: &str, r: &mut R) -> Result<()>
[src]
This stores a file on the server.
pub fn list(&mut self, pathname: Option<&str>) -> Result<Vec<String>>
[src]
Execute LIST
command which returns the detailed file listing in human readable format.
If pathname
is omited then the list of files in the current directory will be
returned otherwise it will the list of files on pathname
.
pub fn nlst(&mut self, pathname: Option<&str>) -> Result<Vec<String>>
[src]
Execute NLST
command which returns the list of file names only.
If pathname
is omited then the list of files in the current directory will be
returned otherwise it will the list of files on pathname
.
pub fn mdtm(&mut self, pathname: &str) -> Result<Option<DateTime<UTC>>>
[src]
Retrieves the modification time of the file at pathname
if it exists.
In case the file does not exist None
is returned.
pub fn size(&mut self, pathname: &str) -> Result<Option<usize>>
[src]
Retrieves the size of the file in bytes at pathname
if it exists.
In case the file does not exist None
is returned.
pub fn read_response(&mut self, expected_code: u32) -> Result<Line>
[src]
pub fn read_response_in(&mut self, expected_code: &[u32]) -> Result<Line>
[src]
Retrieve single line response