expose Error type as AnyError

This commit is contained in:
Cadey Ratio 2020-07-25 17:51:37 -04:00
parent bfa8226e11
commit a0c8ea4f90
2 changed files with 10 additions and 3 deletions

View File

@ -14,4 +14,4 @@ pub use client::{get, Error as ClientError};
#[cfg(feature = "server")] #[cfg(feature = "server")]
mod server; mod server;
#[cfg(feature = "server")] #[cfg(feature = "server")]
pub use server::{Handler, serve, serve_plain}; pub use server::{serve, serve_plain, Error as AnyError, Handler};

View File

@ -1,13 +1,20 @@
use crate::Response; use crate::Response;
use std::{error::Error, io}; use std::{error::Error as StdError, io};
use url::Url; use url::Url;
/// A Gemini request and its associated metadata.
pub struct Request {
url: Url,
}
pub type Error = Box<dyn StdError + Sync + Send>;
#[allow(dead_code, unused_assignments, unused_mut, unused_variables)] #[allow(dead_code, unused_assignments, unused_mut, unused_variables)]
mod routes; mod routes;
pub use routes::*; pub use routes::*;
pub trait Handler { pub trait Handler {
fn handle(u: Url) -> Result<Response, Box<dyn Error + Sync + Send>>; fn handle(r: Request) -> Result<Response, Error>;
} }
pub fn serve(_h: impl Handler, _port: u16) -> io::Result<()> { pub fn serve(_h: impl Handler, _port: u16) -> io::Result<()> {