openssh-sftp-protocol-error-0.1.0/.cargo_vcs_info.json0000644000000001710000000000100164500ustar { "git": { "sha1": "9f5c81de544ca001ba6a05280c3fb0bb28fc6eef" }, "path_in_vcs": "openssh-sftp-protocol-error" }openssh-sftp-protocol-error-0.1.0/Cargo.toml0000644000000020240000000000100144450ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "openssh-sftp-protocol-error" version = "0.1.0" description = "Data format used to communicate with openssh mux server." keywords = [ "ssh", "multiplex", "async", "network", "sftp", ] categories = [ "asynchronous", "network-programming", "api-bindings", ] license = "MIT" repository = "https://github.com/openssh-rust/openssh-sftp-client" [dependencies.serde] version = "1.0" features = ["derive"] [dependencies.thiserror] version = "1.0.30" [dependencies.vec-strings] version = "0.4.5" features = ["serde"] openssh-sftp-protocol-error-0.1.0/Cargo.toml.orig000064400000000000000000000010031046102023000201220ustar 00000000000000[package] name = "openssh-sftp-protocol-error" version = "0.1.0" edition = "2018" license = "MIT" description = "Data format used to communicate with openssh mux server." repository = "https://github.com/openssh-rust/openssh-sftp-client" keywords = ["ssh", "multiplex", "async", "network", "sftp"] categories = ["asynchronous", "network-programming", "api-bindings"] [dependencies] thiserror = "1.0.30" serde = { version = "1.0", features = ["derive"] } vec-strings = { version = "0.4.5", features = ["serde"] } openssh-sftp-protocol-error-0.1.0/src/lib.rs000064400000000000000000000002161046102023000171430ustar 00000000000000mod unix_timestamp_error; pub use unix_timestamp_error::UnixTimeStampError; mod response_error; pub use response_error::{ErrMsg, ErrorCode}; openssh-sftp-protocol-error-0.1.0/src/response_error.rs000064400000000000000000000035401046102023000214470ustar 00000000000000use std::fmt; use serde::Deserialize; use vec_strings::TwoStrs; #[derive(Debug, Copy, Clone)] #[non_exhaustive] pub enum ErrorCode { /// is returned when a reference is made to a file which should exist /// but doesn't. NoSuchFile, /// Returned when the authenticated user does not have sufficient /// permissions to perform the operation. PermDenied, /// A generic catch-all error message. /// /// It should be returned if an error occurs for which there is no more /// specific error code defined. Failure, /// May be returned if a badly formatted packet or protocol /// incompatibility is detected. /// /// If the handle is opened read only, but write flag is required, /// then `BadMessage` might be returned, vice versa. BadMessage, /// Indicates that an attempt was made to perform an operation which /// is not supported for the server. OpUnsupported, /// Unknown error code Unknown, } #[derive(Clone, Deserialize)] pub struct ErrMsg(TwoStrs); impl ErrMsg { /// Returns (err_message, language_tag). /// /// Language tag is defined according to specification [RFC-1766]. /// /// It can be parsed by /// [pyfisch/rust-language-tags](https://github.com/pyfisch/rust-language-tags) /// according to /// [this issue](https://github.com/pyfisch/rust-language-tags/issues/39). pub fn get(&self) -> (&str, &str) { self.0.get() } } impl fmt::Display for ErrMsg { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let (err_msg, language_tag) = self.get(); write!( f, "Err Message: {}, Language Tag: {}", err_msg, language_tag ) } } impl fmt::Debug for ErrMsg { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(self, f) } } openssh-sftp-protocol-error-0.1.0/src/unix_timestamp_error.rs000064400000000000000000000010161046102023000226530ustar 00000000000000use std::{num::TryFromIntError, time::SystemTimeError}; use thiserror::Error as ThisError; #[derive(Debug, ThisError)] #[non_exhaustive] pub enum UnixTimeStampError { /// TimeStamp is earlier than 1970-01-01 00:00:00 UTC. #[error("TimeStamp is earlier than 1970-01-01 00:00:00 UTC.")] TooEarly(#[from] SystemTimeError), /// TimeStamp is too large to be represented using u32 in seconds. #[error("TimeStamp is too large to be represented using u32 in seconds.")] TooLarge(#[from] TryFromIntError), }