openssh_sftp_client_lowlevel

Struct ReadEnd

Source
pub struct ReadEnd<R, Buffer, Q, Auxiliary = ()> { /* private fields */ }
Expand description

The ReadEnd for the lowlevel API.

Implementations§

Source§

impl<R, Buffer, Q, Auxiliary> ReadEnd<R, Buffer, Q, Auxiliary>
where R: AsyncRead, Buffer: ToBuffer + 'static + Send + Sync,

Source

pub fn new( reader: R, reader_buffer_len: NonZeroUsize, shared_data: SharedData<Buffer, Q, Auxiliary>, ) -> Self

Source

pub async fn receive_server_hello_pinned( self: Pin<&mut Self>, ) -> Result<Extensions, Error>

Must be called once right after ReadEnd::new to receive the hello message from the server.

Source

pub async fn read_in_one_packet_pinned( self: Pin<&mut Self>, ) -> Result<(), Error>

§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.

Source

pub async fn ready_for_read_pinned(self: Pin<&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.

Source§

impl<R, Buffer, Q, Auxiliary> ReadEnd<R, Buffer, Q, Auxiliary>
where Self: Unpin, R: AsyncRead, Buffer: ToBuffer + 'static + Send + Sync,

Source

pub async fn receive_server_hello(&mut self) -> Result<Extensions, Error>

Must be called once right after super::connect to receive the hello message from the server.

Source

pub async fn read_in_one_packet(&mut self) -> Result<(), Error>

§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.

§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.

Source

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.

Source§

impl<R, Buffer, Q, Auxiliary> ReadEnd<R, Buffer, Q, Auxiliary>

Source

pub fn get_shared_data(&self) -> &SharedData<Buffer, Q, Auxiliary>

Return the SharedData held by ReadEnd.

Trait Implementations§

Source§

impl<R: Debug, Buffer: Debug, Q: Debug, Auxiliary: Debug> Debug for ReadEnd<R, Buffer, Q, Auxiliary>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'pin, R, Buffer, Q, Auxiliary> Unpin for ReadEnd<R, Buffer, Q, Auxiliary>
where PinnedFieldsOf<__ReadEnd<'pin, R, Buffer, Q, Auxiliary>>: Unpin,

Auto Trait Implementations§

§

impl<R, Buffer, Q, Auxiliary> Freeze for ReadEnd<R, Buffer, Q, Auxiliary>
where R: Freeze,

§

impl<R, Buffer, Q, Auxiliary = ()> !RefUnwindSafe for ReadEnd<R, Buffer, Q, Auxiliary>

§

impl<R, Buffer, Q, Auxiliary> Send for ReadEnd<R, Buffer, Q, Auxiliary>
where R: Send, Q: Sync + Send, Auxiliary: Sync + Send, Buffer: Send,

§

impl<R, Buffer, Q, Auxiliary> Sync for ReadEnd<R, Buffer, Q, Auxiliary>
where R: Sync, Q: Sync + Send, Auxiliary: Sync + Send, Buffer: Send,

§

impl<R, Buffer, Q, Auxiliary = ()> !UnwindSafe for ReadEnd<R, Buffer, Q, Auxiliary>

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.