Skip to content

Commit

Permalink
fix: make Cloneable pub crate
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Dec 31, 2023
1 parent be336f6 commit 55356a3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
1 change: 0 additions & 1 deletion viz-core/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use crate::{BoxFuture, Future};

mod cloneable;
pub use cloneable::{BoxCloneable, Cloneable};

mod after;
pub use after::After;
Expand Down
13 changes: 12 additions & 1 deletion viz-core/src/handler/boxed.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
use crate::{handler::BoxCloneable, BoxFuture, Handler, Request, Response, Result};
use std::fmt;

use super::cloneable::BoxCloneable;
use crate::{BoxFuture, Handler, Request, Response, Result};

/// A [`Clone`] + [`Send`] boxed [`Handler`].
pub struct BoxHandler<I = Request, O = Result<Response>>(BoxCloneable<I, O>);

impl<I, O> BoxHandler<I, O> {
/// Creates a new `BoxHandler`.
pub fn new<H>(h: H) -> Self
where
H: Handler<I, Output = O> + Send + Clone + 'static,
Expand Down Expand Up @@ -30,3 +35,9 @@ impl<I, O> From<BoxCloneable<I, O>> for BoxHandler<I, O> {
Self(value)
}
}

impl<I, O> fmt::Debug for BoxHandler<I, O> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BoxHandler").finish()
}
}
4 changes: 2 additions & 2 deletions viz-core/src/handler/cloneable.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::Handler;

pub type BoxCloneable<Input, Output> = Box<dyn Cloneable<Input, Output = Output> + Send>;
pub(crate) type BoxCloneable<Input, Output> = Box<dyn Cloneable<Input, Output = Output> + Send>;

pub trait Cloneable<Input>: Handler<Input> {
pub(crate) trait Cloneable<Input>: Handler<Input> {
fn clone_box(&self) -> BoxCloneable<Input, Self::Output>;
}

Expand Down
2 changes: 1 addition & 1 deletion viz-core/src/handler/try_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ where
}
}

pub trait TryHandlerExt<I>: TryHandler<I> {}
pub(crate) trait TryHandlerExt<I>: TryHandler<I> {}

0 comments on commit 55356a3

Please sign in to comment.