openssh_sftp_protocol::request

Enum RequestInner

Source
pub enum RequestInner<'a> {
Show 25 variants Open(OpenFileRequest<'a>), Close(Cow<'a, Handle>), Read { handle: Cow<'a, Handle>, offset: u64, len: u32, }, Remove(Cow<'a, Path>), Rename { oldpath: Cow<'a, Path>, newpath: Cow<'a, Path>, }, Mkdir { path: Cow<'a, Path>, attrs: FileAttrs, }, Rmdir(Cow<'a, Path>), Opendir(Cow<'a, Path>), Readdir(Cow<'a, Handle>), Stat(Cow<'a, Path>), Lstat(Cow<'a, Path>), Fstat(Cow<'a, Handle>), Setstat { path: Cow<'a, Path>, attrs: FileAttrs, }, Fsetstat { handle: Cow<'a, Handle>, attrs: FileAttrs, }, Readlink(Cow<'a, Path>), Symlink { linkpath: Cow<'a, Path>, targetpath: Cow<'a, Path>, }, Realpath(Cow<'a, Path>), Limits, ExpandPath(Cow<'a, Path>), Lsetstat(Cow<'a, Path>, FileAttrs), Fsync(Cow<'a, Handle>), HardLink { oldpath: Cow<'a, Path>, newpath: Cow<'a, Path>, }, PosixRename { oldpath: Cow<'a, Path>, newpath: Cow<'a, Path>, }, Cp { read_from_handle: Cow<'a, Handle>, read_from_offset: u64, read_data_length: u64, write_to_handle: Cow<'a, Handle>, write_to_offset: u64, }, Write { handle: Cow<'a, Handle>, offset: u64, data: Cow<'a, [u8]>, },
}

Variants§

§

Open(OpenFileRequest<'a>)

The response to this message will be either crate::response::ResponseInner::Handle (if the operation is successful) or crate::response::ResponseInner::Status (if the operation fails).

§

Close(Cow<'a, Handle>)

§

Read

In response to this request, the server will read as many bytes as it can from the file (up to `len’), and return them in a ResponseInner::Data message.

If an error occurs or EOF is encountered before reading any data, the server will respond with crate::response::ResponseInner::Status.

For normal disk files, it is guaranteed that this will read the specified number of bytes, or up to end of file.

For e.g. device files this may return fewer bytes than requested.

Fields

§handle: Cow<'a, Handle>
§offset: u64
§len: u32
§

Remove(Cow<'a, Path>)

Responds with a crate::response::ResponseInner::Status message.

§

Rename

Responds with a crate::response::ResponseInner::Status message.

Fields

§oldpath: Cow<'a, Path>
§newpath: Cow<'a, Path>
§

Mkdir

Responds with a crate::response::ResponseInner::Status message.

Fields

§path: Cow<'a, Path>
§

Rmdir(Cow<'a, Path>)

Responds with a crate::response::ResponseInner::Status message.

§

Opendir(Cow<'a, Path>)

§

Readdir(Cow<'a, Handle>)

§

Stat(Cow<'a, Path>)

§

Lstat(Cow<'a, Path>)

§

Fstat(Cow<'a, Handle>)

§

Setstat

Responds with a crate::response::ResponseInner::Status message.

Fields

§path: Cow<'a, Path>
§

Fsetstat

Responds with a crate::response::ResponseInner::Status message.

Fields

§handle: Cow<'a, Handle>

Responds with crate::response::ResponseInner::Name with a name and dummy attribute value or crate::response::ResponseInner::Status on error.

Responds with a crate::response::ResponseInner::Status message.

Fields

§linkpath: Cow<'a, Path>
§targetpath: Cow<'a, Path>
§

Realpath(Cow<'a, Path>)

Responds with crate::response::ResponseInner::Name with a name and dummy attribute value or crate::response::ResponseInner::Status on error.

§

Limits

Responds with extended reply, with payload crate::response::Limits.

Extension, only available if it is [crate::response::Extensions::limits] is returned by crate::response::ServerVersion.

§

ExpandPath(Cow<'a, Path>)

Same response as RequestInner::Realpath.

Extension, only available if it is [crate::response::Extensions::expand_path] is returned by crate::response::ServerVersion.

This supports canonicalisation of relative paths and those that need tilde-expansion, i.e. “”, “/…” and “~user/…”.

These paths are expanded using shell-lilke rules and the resultant path is canonicalised similarly to RequestInner::Realpath.

§

Lsetstat(Cow<'a, Path>, FileAttrs)

Same response as RequestInner::Setstat.

Extension, only available if it is [crate::response::Extensions::lsetstat] is returned by crate::response::ServerVersion.

§

Fsync(Cow<'a, Handle>)

Responds with a crate::response::ResponseInner::Status message.

Extension, only available if it is [crate::response::Extensions::fsync] is returned by crate::response::ServerVersion.

Responds with a crate::response::ResponseInner::Status message.

Extension, only available if it is [crate::response::Extensions::hardlink] is returned by crate::response::ServerVersion.

Fields

§oldpath: Cow<'a, Path>
§newpath: Cow<'a, Path>
§

PosixRename

Responds with a crate::response::ResponseInner::Status message.

Extension, only available if it is [crate::response::Extensions::posix_rename] is returned by crate::response::ServerVersion.

Fields

§oldpath: Cow<'a, Path>
§newpath: Cow<'a, Path>
§

Cp

Responds with a crate::response::ResponseInner::Status message.

Extension, only available if it is [crate::response::Extensions::posix_rename] is returned by crate::response::ServerVersion.

For openssh-portable, this is available from V_9_0_P1.

The server MUST copy the data exactly as if the client had issued a series of RequestInner::Read requests on the read_from_handle starting at read_from_offset and totaling read_data_length bytes, and issued a series of RequestInner::Write packets on the write_to_handle, starting at the write_from_offset, and totaling the total number of bytes read by the RequestInner::Read packets.

The server SHOULD allow read_from_handle and write_to_handle to be the same handle as long as the range of data is not overlapping. This allows data to efficiently be moved within a file.

If data_length is 0, this imples data should be read until EOF is encountered.

There are no protocol restictions on this operation; however, the server MUST ensure that the user does not exceed quota, etc. The server is, as always, free to complete this operation out of order if it is too large to complete immediately, or to refuse a request that is too large.

Fields

§read_from_handle: Cow<'a, Handle>
§read_from_offset: u64
§read_data_length: u64
§write_to_handle: Cow<'a, Handle>
§write_to_offset: u64
§

Write

The write will extend the file if writing beyond the end of the file.

It is legal to write way beyond the end of the file, the semantics are to write zeroes from the end of the file to the specified offset and then the data.

On most operating systems, such writes do not allocate disk space but instead leave “holes” in the file.

Responds with a crate::response::ResponseInner::Status message.

The Write also includes any amount of custom data and its size is included in the size of the entire packet sent.

Fields

§handle: Cow<'a, Handle>
§offset: u64
§data: Cow<'a, [u8]>

Trait Implementations§

Source§

impl<'a> Debug for RequestInner<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for RequestInner<'a>

§

impl<'a> RefUnwindSafe for RequestInner<'a>

§

impl<'a> Send for RequestInner<'a>

§

impl<'a> Sync for RequestInner<'a>

§

impl<'a> Unpin for RequestInner<'a>

§

impl<'a> UnwindSafe for RequestInner<'a>

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.