forked from cadey/maj
expose Error type as AnyError
This commit is contained in:
parent
bfa8226e11
commit
a0c8ea4f90
|
@ -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};
|
||||||
|
|
|
@ -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<()> {
|
||||||
|
|
Loading…
Reference in New Issue