Struct openssh_sftp_client::ReadEnd
source · [−]pub struct ReadEnd<Buffer, Auxiliary = ()> { /* private fields */ }
Implementations
sourceimpl<Buffer: ToBuffer + 'static + Send + Sync, Auxiliary> ReadEnd<Buffer, Auxiliary>
impl<Buffer: ToBuffer + 'static + Send + Sync, Auxiliary> ReadEnd<Buffer, Auxiliary>
sourcepub async fn read_in_one_packet(&mut self) -> Result<(), Error>
pub async fn read_in_one_packet(&mut self) -> Result<(), Error>
Precondition: ReadEnd::wait_for_new_request
must not be 0.
Restart on Error
Only when the returned error is Error::InvalidResponseId
or
Error::AwaitableError
, can the function be restarted.
Upon other errors Error::IOError
, Error::FormatError
and
Error::RecursiveErrors
, the sftp session has to be discarded.
Example
let readend = ...;
loop {
let new_requests_submit = readend.wait_for_new_request().await;
if new_requests_submit == 0 {
break;
}
// If attempt to read in more than new_requests_submit, then
// `read_in_one_packet` might block forever.
for _ in 0..new_requests_submit {
readend.read_in_one_packet().await.unwrap();
}
}
Cancel Safety
This function is not cancel safe.
Dropping the future might cause the response packet to be partially read, and the next read would treat the partial response as a new response.
sourcepub async fn wait_for_new_request(&self) -> u32
pub async fn wait_for_new_request(&self) -> u32
Return number of requests sent (including requests that are still in the write buffer and not yet flushed) and number of responses to read in. Read 0 if the connection is closed.
You must call this function in a loop, break if this function returns
0, otherwise call ReadEnd::read_in_one_packet
for n
times where n
in the
return value of this function, then repeat.
Cancel Safety
It is perfectly safe to cancel this future.
sourcepub async fn try_flush_write_end_buffer(&self) -> Result<bool, Error>
pub async fn try_flush_write_end_buffer(&self) -> Result<bool, Error>
Forward function call to SharedData::try_flush
.
sourcepub async fn flush_write_end_buffer(&self) -> Result<(), Error>
pub async fn flush_write_end_buffer(&self) -> Result<(), Error>
Forward function call to SharedData::flush
.
sourcepub async fn ready_for_read(&mut self) -> Result<(), Error>
pub async fn ready_for_read(&mut self) -> Result<(), Error>
Wait for next packet to be readable.
Return Ok(())
if next packet is ready and readable, Error::IOError(io_error)
where io_error.kind() == ErrorKind::UnexpectedEof
if EOF
is met.
Cancel Safety
This function is cancel safe and thus can be used with tokio::select!
to implement ReadEnd::flush_write_end_buffer
on timeout.
Forward to SharedData::strong_count
.
Trait Implementations
Auto Trait Implementations
impl<Buffer, Auxiliary = ()> !RefUnwindSafe for ReadEnd<Buffer, Auxiliary>
impl<Buffer, Auxiliary> Send for ReadEnd<Buffer, Auxiliary> where
Auxiliary: Send + Sync,
Buffer: Send,
impl<Buffer, Auxiliary> Sync for ReadEnd<Buffer, Auxiliary> where
Auxiliary: Send + Sync,
Buffer: Send,
impl<Buffer, Auxiliary> Unpin for ReadEnd<Buffer, Auxiliary>
impl<Buffer, Auxiliary = ()> !UnwindSafe for ReadEnd<Buffer, Auxiliary>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more