russh_sftp/protocol/
status.rs

1use thiserror::Error;
2
3use super::{impl_packet_for, impl_request_id, Packet, RequestId};
4
5/// Error Codes for SSH_FXP_STATUS
6#[derive(Debug, Error, Clone, Copy, PartialEq, Serialize, Deserialize)]
7pub enum StatusCode {
8    /// Indicates successful completion of the operation.
9    #[error("Ok")]
10    Ok = 0,
11    /// Indicates end-of-file condition; for SSH_FX_READ it means that no more data is available in the file,
12    /// and for SSH_FX_READDIR it indicates that no more files are contained in the directory.
13    #[error("Eof")]
14    Eof = 1,
15    /// A reference is made to a file which should exist but doesn't.
16    #[error("No such file")]
17    NoSuchFile = 2,
18    /// Authenticated user does not have sufficient permissions to perform the operation.
19    #[error("Permission denied")]
20    PermissionDenied = 3,
21    /// A generic catch-all error message;
22    /// it should be returned if an error occurs for which there is no more specific error code defined.
23    #[error("Failure")]
24    Failure = 4,
25    /// May be returned if a badly formatted packet or protocol incompatibility is detected.
26    #[error("Bad message")]
27    BadMessage = 5,
28    /// A pseudo-error which indicates that the client has no connection to the server
29    /// (it can only be generated locally by the client, and MUST NOT be returned by servers).
30    #[error("No connection")]
31    NoConnection = 6,
32    /// A pseudo-error which indicates that the connection to the server has been lost
33    /// (it can only be generated locally by the client, and MUST NOT be returned by servers).
34    #[error("Connection lost")]
35    ConnectionLost = 7,
36    /// Indicates that an attempt was made to perform an operation which is not supported for the server
37    /// (it may be generated locally by the client if e.g. the version number exchange indicates that a required feature is not supported by the server,
38    /// or it may be returned by the server if the server does not implement an operation).
39    #[error("Operation unsupported")]
40    OpUnsupported = 8,
41}
42
43/// Implementation for SSH_FXP_STATUS as defined in the specification draft
44/// <https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-7>
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct Status {
47    pub id: u32,
48    pub status_code: StatusCode,
49    pub error_message: String,
50    pub language_tag: String,
51}
52
53impl_request_id!(Status);
54impl_packet_for!(Status);