Skip to main content

hyperlane_core/error/
impl.rs

1use super::*;
2
3/// Implementation of `From` trait for converting external errors into `ServerError`.
4///
5/// This allows using the `?` operator to automatically convert `IoError`
6/// into `ServerError::TcpBind` when binding to a TCP socket.
7impl From<std::io::Error> for ServerError {
8    /// Creates a new `ServerError::TcpBind` instance from a `IoError`.
9    ///
10    /// # Arguments
11    ///
12    /// - `IoError` - The `IoError` to convert.
13    ///
14    /// # Returns
15    ///
16    /// - `Self` - A new `ServerError::TcpBind` instance.
17    #[inline(always)]
18    fn from(error: std::io::Error) -> Self {
19        ServerError::TcpBind(error.to_string())
20    }
21}