Struct btmsg::Transmitter

source ·
pub struct Transmitter { /* private fields */ }
Expand description

A type which can be used to transmit messages over the network to a crate::Receiver.

Implementations§

source§

impl Transmitter

source

pub async fn new<C: 'static + Creds + Send + Sync>( addr: Arc<BlockAddr>, creds: Arc<C> ) -> Result<Transmitter>

source

pub fn addr(&self) -> &Arc<BlockAddr>

Returns the address that this instance is transmitting to.

source

pub async fn send<'ser, 'de, T>(&self, msg: T) -> Result<()>where T: 'ser + SendMsg<'de>,

Transmit a message to the connected crate::Receiver without waiting for a reply.

source

pub async fn call<'ser, 'de, T, F>( &self, msg: T, callback: F ) -> Result<F::Return>where T: 'ser + CallMsg<'de>, F: 'static + Send + DeserCallback,

Transmit a message to the connected crate::Receiver, waits for a reply, then calls the given DeserCallback with the deserialized reply.

WARNING

The callback must be such that F::Arg<'a> = T::Reply<'a> for any 'a. If this is violated, then a deserilization error will occur at runtime.

TODO

This issue needs to be fixed. Due to the fact that F::Arg is a Generic Associated Type (GAT) I have been unable to express this constraint in the where clause of this method. I’m not sure if the errors I’ve encountered are due to a lack of understanding on my part or due to the current limitations of the borrow checker in its handling of GATs.

source

pub async fn call_through<'ser, T>(&self, msg: T) -> Result<T::Reply<'static>>where T: 'ser + CallMsg<'static>, T::Reply<'static>: 'static + Send + Sync + DeserializeOwned,

Transmits a message to the connected crate::Receiver, waits for a reply, then passes back the the reply to the caller. This only works for messages whose reply doesn’t borrow any data, otherwise the call method must be used.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Free for T

§

unsafe default fn free(ptr_ref: NonNull<T>)

Drops the content pointed by this pointer and frees it. 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 Twhere 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 Twhere 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 Twhere 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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

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