lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README

error.rs (1809B)


      1 use thiserror::Error;
      2 
      3 /// Errors produced while validating public identity values.
      4 #[non_exhaustive]
      5 #[derive(Clone, Debug, Error, PartialEq, Eq)]
      6 pub enum Error {
      7     #[error("identifier byte representation must contain {expected} bytes, but contained {actual}")]
      8     InvalidByteLength { expected: usize, actual: usize },
      9 
     10     #[error(
     11         "identifier hexadecimal representation must contain {expected} bytes, but contained {actual}"
     12     )]
     13     InvalidHexLength { expected: usize, actual: usize },
     14 
     15     #[error("identifier contains non-hexadecimal data at byte {index}")]
     16     InvalidHexCharacter { index: usize },
     17 
     18     #[error("public key bytes are not a valid secp256k1 x-only public key")]
     19     InvalidPublicKeyBytes,
     20 
     21     #[error("public identity identifier does not match its public key")]
     22     IdentityIdMismatch,
     23 
     24     #[error("account identifier does not match its public identity")]
     25     AccountIdMismatch,
     26 
     27     #[error(
     28         "account updated timestamp {updated_at_unix} precedes created timestamp {created_at_unix}"
     29     )]
     30     AccountUpdatedBeforeCreated {
     31         created_at_unix: u64,
     32         updated_at_unix: u64,
     33     },
     34 
     35     #[error(
     36         "account update timestamp {proposed_updated_at_unix} precedes current timestamp {current_updated_at_unix}"
     37     )]
     38     AccountUpdateRegressed {
     39         current_updated_at_unix: u64,
     40         proposed_updated_at_unix: u64,
     41     },
     42 
     43     #[error("username length must be between {min} and {max} ASCII bytes, but was {actual}")]
     44     InvalidUsernameLength {
     45         min: usize,
     46         max: usize,
     47         actual: usize,
     48     },
     49 
     50     #[error("username contains an invalid character at byte {index}")]
     51     InvalidUsernameCharacter { index: usize },
     52 
     53     #[error("username dots cannot be leading, trailing, or consecutive")]
     54     InvalidUsernameDotPlacement,
     55 }