~thatonelutenist/actm

575fb508ee052c7c1d5c57eecce4a08f4fc31aec — Nathan McCarty 1 year, 9 months ago 433f136
feat!: Remove directional event

BREAKING CHANGE: Remove directional event type
1 files changed, 0 insertions(+), 52 deletions(-)

M src/types.rs
M src/types.rs => src/types.rs +0 -52
@@ 28,58 28,6 @@ pub enum Either<A, B> {
    Sad(B),
}

/// Wrapper for a Directional [`Event`]
#[derive(Clone, PartialEq, Eq, Debug, PartialOrd, Ord, Hash)]
pub enum DirectionalEvent<I, O> {
    /// Incoming message, this node is the recipient
    Inbound(I),
    /// Outbound message, this node is the sender
    Outbound(O),
}

/// Wrapper for Directional [`Event`]'s flags
#[derive(PartialEq, Eq, Debug, PartialOrd, Ord, Hash)]
pub enum DirectionalEventFlags<I: Event, O: Event> {
    /// Incoming message, this node is the recipient
    Inbound(I::Flags),
    /// Outbound message, this node is the sender
    Outbound(O::Flags),
}

impl<I: Event, O: Event> Clone for DirectionalEventFlags<I, O> {
    fn clone(&self) -> Self {
        match self {
            Self::Inbound(arg0) => Self::Inbound(arg0.clone()),
            Self::Outbound(arg0) => Self::Outbound(arg0.clone()),
        }
    }
}

impl<I: Event, O: Event> Event for DirectionalEvent<I, O> {
    type Flags = DirectionalEventFlags<I, O>;

    fn flags(&self) -> Self::Flags {
        match self {
            DirectionalEvent::Inbound(e) => DirectionalEventFlags::Inbound(e.flags()),
            DirectionalEvent::Outbound(e) => DirectionalEventFlags::Outbound(e.flags()),
        }
    }

    fn stateless_clone(&self) -> Self {
        match self {
            DirectionalEvent::Inbound(e) => DirectionalEvent::Inbound(e.stateless_clone()),
            DirectionalEvent::Outbound(e) => DirectionalEvent::Outbound(e.stateless_clone()),
        }
    }

    fn token(&mut self) -> Option<CompletionToken> {
        match self {
            DirectionalEvent::Inbound(e) => e.token(),
            DirectionalEvent::Outbound(e) => e.token(),
        }
    }
}

/// Token for listening for responses to requests
///
/// These tokens are always guaranteed, to have at most one equal counterpart, and they are