1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use crate::traits::{Consumer, Producer};

/// Split the ring buffer onto producer and consumer.
pub trait Split {
    /// Producer type.
    type Prod: Producer;
    /// Consumer type.
    type Cons: Consumer;

    /// Perform splitting.
    fn split(self) -> (Self::Prod, Self::Cons);
}

/// Split the ring buffer by reference onto producer and consumer.
pub trait SplitRef {
    /// Ref producer type.
    type RefProd<'a>: Producer + 'a
    where
        Self: 'a;
    /// Ref consumer type.
    type RefCons<'a>: Consumer + 'a
    where
        Self: 'a;

    /// Perform splitting by reference.
    fn split_ref(&mut self) -> (Self::RefProd<'_>, Self::RefCons<'_>);
}