File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,17 @@ impl DataStream {
31
31
}
32
32
}
33
33
34
+ impl DataStream {
35
+ /// Returns a reference to the underlying TcpStream.
36
+ pub fn get_ref ( & self ) -> & TcpStream {
37
+ match self {
38
+ & DataStream :: Tcp ( ref stream) => stream,
39
+ #[ cfg( feature = "secure" ) ]
40
+ & DataStream :: Ssl ( ref stream) => stream. get_ref ( ) ,
41
+ }
42
+ }
43
+ }
44
+
34
45
impl Read for DataStream {
35
46
fn read ( & mut self , buf : & mut [ u8 ] ) -> Result < usize > {
36
47
match self {
Original file line number Diff line number Diff line change @@ -164,6 +164,21 @@ impl FtpStream {
164
164
} )
165
165
}
166
166
167
+ /// Returns a reference to the underlying TcpStream.
168
+ ///
169
+ /// Example:
170
+ /// ```no_run
171
+ /// use std::net::TcpStream;
172
+ ///
173
+ /// let stream = FtpStream::connect("127.0.0.1:21")
174
+ /// .expect("Couldn't connect to the server...");
175
+ /// stream.get_ref().set_read_timeout(Duration::from_secs(10))
176
+ /// .expect("set_read_timeout call failed");
177
+ /// ```
178
+ pub fn get_ref ( & self ) -> & TcpStream {
179
+ self . reader . get_ref ( ) . get_ref ( )
180
+ }
181
+
167
182
/// Log in to the FTP server.
168
183
pub fn login ( & mut self , user : & str , password : & str ) -> Result < ( ) > {
169
184
let user_command = format ! ( "USER {}\r \n " , user) ;
You can’t perform that action at this time.
0 commit comments