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