Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
saefstroem committed Sep 5, 2024
1 parent 1ec2a52 commit c2254b7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
mod connection;
mod parser;

/**
Contains the SmtpServer struct and its implementation.
*/
pub mod server;

#[cfg(test)]
Expand Down
32 changes: 32 additions & 0 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,50 @@ use tokio::{io, task::JoinError};
use crate::connection::Mail;

#[derive(Error, Debug)]
/**
## Server error
The `ServerError` enum represents an error that can occur while running the SMTP server.
*/
pub enum ServerError {
#[error("Network error: {0}")]
/**
* Occurs when there is a general network error
*/
Network(#[from] io::Error),
#[error("Task error: {0}")]
/**
* Occurs when there is an error with am async task
*/
Task(#[from] JoinError),
#[error("Send error: {0}")]
/**
* Occurs when there is an error transmitting a signal or an email
*/
Send(#[from] SendError<()>),
#[error("Recv error: {0}")]
/**
* Occurs when there is an error receiving a signal or an email
*/
Recv(#[from] RecvError),
#[error("Could not bind to {host}:{port} because {source}")]
/**
* Occurs when the server cannot bind to a host and port
*/
Bind {
host: &'static str,
port: u16,
#[source]
source: io::Error,
},
#[error("Could not confirm shutdown")]
/**
* Occurs when the server cannot confirm a shutdown via signalling
*/
Shutdown,
#[error("Server is already running")]
/**
* Occurs when the server is already running and a start is attempted
*/
Running,
}

Expand Down Expand Up @@ -61,7 +86,14 @@ pub struct Config {
pub shutdown_rx: Receiver<()>,
}

/**
Listening state for the server
*/
pub struct Listening;

/**
Closed state for the server
*/
pub struct Closed;

/**
Expand Down

0 comments on commit c2254b7

Please sign in to comment.