Add optional serde support; Remove Clone
from most error types;
This commit is contained in:
parent
73375abec3
commit
ac5f2c21eb
11 changed files with 34 additions and 6 deletions
|
@ -14,3 +14,8 @@ x509-parser = "0.15.0"
|
|||
version = "0.21.1"
|
||||
features = [ "dangerous_configuration" ]
|
||||
|
||||
[dependencies.serde]
|
||||
version = "1.0"
|
||||
features = ["derive"]
|
||||
optional = true
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use {std::fmt, x509_parser::prelude::X509Error};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Debug)]
|
||||
/// Errors which can occur when fingerprinting a certificate
|
||||
pub enum Error {
|
||||
Fmt,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
/// Errors which can occur when parsing a host from a string
|
||||
pub enum Error {
|
||||
MissingSeparator,
|
||||
|
|
|
@ -2,7 +2,11 @@ use std::{fmt, str::FromStr};
|
|||
mod error;
|
||||
pub use error::Error;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
/// Represents the fully qualified domain name for this host
|
||||
pub struct Host {
|
||||
pub subdomain: Option<String>,
|
||||
|
|
|
@ -5,5 +5,8 @@ pub use super::{
|
|||
request::{Error as ParseRequestError, Request},
|
||||
response::{Error as ParseResponseError, Response},
|
||||
sender::{CertificateStore, Error as SenderError, Sender, Verifier},
|
||||
status::{Error as ParseStatusError, Status, Redirect, TemporaryFailure, PermanentFailure, AuthenticationFailure},
|
||||
status::{
|
||||
AuthenticationFailure, Error as ParseStatusError, PermanentFailure, Redirect, Status,
|
||||
TemporaryFailure,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use {crate::prelude::ParseHostError, std::fmt};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
/// Errors which can occur when parsing a request
|
||||
pub enum Error {
|
||||
MissingSeparator,
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
use crate::prelude::Host;
|
||||
use std::{fmt, str::FromStr};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
mod error;
|
||||
pub use error::Error;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
/// The full request as sent by the `Sender` and received by the `Receiver`
|
||||
pub struct Request {
|
||||
/// The username of the sender
|
||||
|
|
|
@ -3,7 +3,7 @@ use {
|
|||
std::{fmt, num::ParseIntError},
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
/// Errors which can occur when parsing the response sent by the receving server
|
||||
/// back to the sender
|
||||
pub enum Error {
|
||||
|
|
|
@ -4,7 +4,11 @@ use std::{fmt, str::FromStr};
|
|||
mod error;
|
||||
pub use error::Error;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
/// Sent from the receiving server back to the sending server
|
||||
pub struct Response {
|
||||
pub status: Status,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::fmt;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug)]
|
||||
/// The receiving server sent an unrecognized or invalid status code
|
||||
pub struct Error;
|
||||
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
mod error;
|
||||
pub use error::Error;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[repr(u8)]
|
||||
/// Status codes sent back to the sender representing how a receiving server has
|
||||
/// processed a message.
|
||||
|
@ -54,6 +58,7 @@ impl TryFrom<u8> for Status {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
/// Status codes representing that a redirect is required
|
||||
pub enum Redirect {
|
||||
/// The mailbox has moved to a different address, and this message
|
||||
|
@ -79,6 +84,7 @@ impl TryFrom<u8> for Redirect {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
/// Status codes representing that a temporary failure has occurred. The sending server should
|
||||
/// retry sending the message.
|
||||
pub enum TemporaryFailure {
|
||||
|
@ -117,6 +123,7 @@ impl TryFrom<u8> for TemporaryFailure {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
/// Status codes representing that a permanent failure has occurred and the sending
|
||||
/// server should not resend the message.
|
||||
pub enum PermanentFailure {
|
||||
|
@ -152,6 +159,7 @@ impl TryFrom<u8> for PermanentFailure {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
/// Status codes representing an authentication failure
|
||||
pub enum AuthenticationFailure {
|
||||
/// This mailserver doesn't accept anonymous mail, and you need to repeat your
|
||||
|
|
Loading…
Add table
Reference in a new issue