Enum roles_logic_sv2::handlers::SendTo_

source ·
pub enum SendTo_<Message, Remote> {
    RelayNewMessageToRemote(Arc<Mutex<Remote>>, Message),
    RelaySameMessageToRemote(Arc<Mutex<Remote>>),
    RelayNewMessage(Message),
    Respond(Message),
    Multiple(Vec<SendTo_<Message, Remote>>),
    None(Option<Message>),
}
Expand description

Message is a serializable entity that rapresent the meanings of communication between Remote(s) SendTo_ is used to add context to Message, it say what we need to do with that Message.

Variants§

§

RelayNewMessageToRemote(Arc<Mutex<Remote>>, Message)

Used by proxies when Message must be relayed downstream or upstream and we want to specify to which particular downstream or upstream we want to relay the message.

When the message that we need to relay is the same message that we received should be used RelaySameMessageToRemote in order to save an allocation.

§

RelaySameMessageToRemote(Arc<Mutex<Remote>>)

Used by proxies when Message must be relayed downstream or upstream and we want to specify to which particular downstream or upstream we want to relay the message.

Is used when we need to relay the same message the we received in order to save an allocation.

§

RelayNewMessage(Message)

Used by proxies when Message must be relayed downstream or upstream and we do not want to specify specify to which particular downstream or upstream we want to relay the message.

This is used in proxies that do and Sv1 to Sv2 translation. The upstream is connected via an extended channel that means that

§

Respond(Message)

Used proxies clients and servers to directly respond to a received message.

§

Multiple(Vec<SendTo_<Message, Remote>>)

§

None(Option<Message>)

Used by proxies, clients, and servers, when Message do not have to be used in any of the above way. If Message is still needed to be used in a non conventional way we use SendTo::None(Some(message)) If we just want to discard it we can use SendTo::None(None)

SendTo::None(Some(m)) could be used for example when we do not need to send the message, but we still need it for successive handling/transformation. One of these cases are proxies that are connected to upstream via an extended channel (like the Sv1 <-> Sv2 translator). This because extended channel messages are always general for all the downstream, where standard channel message can be specific for a particular downstream. Another case is when 2 roles are implemented in the same software, like a pool that is both TP client and a Mining server, messages received by the TP client must be sent to the Mining Server than transformed in Mining messages and sent to the downstream.

Implementations§

source§

impl<SubProtocol, Remote> SendTo_<SubProtocol, Remote>

source

pub fn into_message(self) -> Option<SubProtocol>

source

pub fn into_remote(self) -> Option<Arc<Mutex<Remote>>>

Trait Implementations§

source§

impl<Message: Debug, Remote: Debug> Debug for SendTo_<Message, Remote>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Message, Remote> Freeze for SendTo_<Message, Remote>
where Message: Freeze,

§

impl<Message, Remote> RefUnwindSafe for SendTo_<Message, Remote>
where Message: RefUnwindSafe,

§

impl<Message, Remote> Send for SendTo_<Message, Remote>
where Message: Send, Remote: Send,

§

impl<Message, Remote> Sync for SendTo_<Message, Remote>
where Message: Sync, Remote: Send,

§

impl<Message, Remote> Unpin for SendTo_<Message, Remote>
where Message: Unpin,

§

impl<Message, Remote> UnwindSafe for SendTo_<Message, Remote>
where Message: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more