Remove unneeded trait methods

This commit is contained in:
asonix 2019-05-27 20:49:46 -05:00
parent 89eb549c44
commit 267ffa81b0
3 changed files with 12 additions and 20 deletions

View file

@ -93,11 +93,12 @@ where
}
}
pub fn register(
mut self,
processor: impl Processor<Job = impl Job<State = State> + Send + 'static> + Send + 'static,
) -> Self {
self.queues.insert(processor.queue().to_owned(), 4);
pub fn register<P, J>(mut self, processor: P) -> Self
where
P: Processor<Job = J> + Send + 'static,
J: Job<State = State>,
{
self.queues.insert(P::QUEUE.to_owned(), 4);
self.processors.register_processor(processor);
self
}

View file

@ -183,16 +183,6 @@ pub trait Processor: Clone {
Box::new(fut)
}
/// Hack to access Associated Constant from impl type
fn name(&self) -> &'static str {
Self::NAME
}
/// Hack to access Associated Constant from impl type
fn queue(&self) -> &'static str {
Self::QUEUE
}
}
#[derive(Clone, Debug, Fail)]

View file

@ -72,12 +72,13 @@ where
///
/// `ProcessorMap`s are useless if no processors are registerd before workers are spawned, so
/// make sure to register all your processors up-front.
pub fn register_processor(
&mut self,
processor: impl Processor<Job = impl Job<State = S> + 'static> + Send + 'static,
) {
pub fn register_processor<P, J>(&mut self, processor: P)
where
P: Processor<Job = J> + Send + 'static,
J: Job<State = S>,
{
self.inner.insert(
processor.name().to_owned(),
P::NAME.to_owned(),
Box::new(move |value, state| processor.process(value, state)),
);
}