hyperlane/error/impl.rs
1use crate::*;
2
3/// Implementation of `From` trait for converting external errors into `ServerError`.
4///
5/// This allows using the `?` operator to automatically convert `std::io::Error`
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 `std::io::Error`.
9 ///
10 /// # Arguments
11 ///
12 /// - `std::io::Error` - The `std::io::Error` 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}