mirror of
https://github.com/callumio/suck.git
synced 2025-12-17 11:39:20 +00:00
feat: add internal constructor for Sucker/Sourcer
This commit is contained in:
parent
ca4825552f
commit
4dd7df50e1
4 changed files with 46 additions and 52 deletions
|
|
@ -10,10 +10,26 @@ where
|
|||
ST: ChannelSender<Request>,
|
||||
SR: ChannelReceiver<Response<T>>,
|
||||
{
|
||||
pub(crate) request_tx: ST,
|
||||
pub(crate) response_rx: SR,
|
||||
pub(crate) closed: AtomicBool,
|
||||
pub(crate) _phantom: std::marker::PhantomData<T>,
|
||||
request_tx: ST,
|
||||
response_rx: SR,
|
||||
closed: AtomicBool,
|
||||
_phantom: std::marker::PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T, ST, SR> Sucker<T, ST, SR>
|
||||
where
|
||||
ST: ChannelSender<Request>,
|
||||
SR: ChannelReceiver<Response<T>>,
|
||||
{
|
||||
/// Create a new Sucker instance
|
||||
pub(crate) fn new(request_tx: ST, response_rx: SR) -> Self {
|
||||
Self {
|
||||
request_tx,
|
||||
response_rx,
|
||||
closed: AtomicBool::new(false),
|
||||
_phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The producer side of the channel that provides values
|
||||
|
|
@ -22,10 +38,26 @@ where
|
|||
SR: ChannelReceiver<Request>,
|
||||
ST: ChannelSender<Response<T>>,
|
||||
{
|
||||
pub(crate) request_rx: SR,
|
||||
pub(crate) response_tx: ST,
|
||||
pub(crate) state: ChannelState<T>,
|
||||
pub(crate) _phantom: std::marker::PhantomData<T>,
|
||||
request_rx: SR,
|
||||
response_tx: ST,
|
||||
state: ChannelState<T>,
|
||||
_phantom: std::marker::PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T, SR, ST> Sourcer<T, SR, ST>
|
||||
where
|
||||
SR: ChannelReceiver<Request>,
|
||||
ST: ChannelSender<Response<T>>,
|
||||
{
|
||||
/// Create a new Sourcer instance
|
||||
pub(crate) fn new(request_rx: SR, response_tx: ST, state: ChannelState<T>) -> Self {
|
||||
Self {
|
||||
request_rx,
|
||||
response_tx,
|
||||
state,
|
||||
_phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, SR, ST> Sourcer<T, SR, ST>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue