pub trait CustomSender:
Debug
+ Send
+ Sync
+ 'static {
// Required methods
fn is_valid_send_addr(&self, addr: &CustomAddr) -> bool;
fn poll_send(
&self,
cx: &mut Context<'_>,
dst: &CustomAddr,
src: Option<&CustomAddr>,
transmit: &Transmit<'_>,
) -> Poll<Result<()>>;
}Available on crate feature
unstable-custom-transports only.Expand description
Custom sender
A sender provides a poll based interface to send packets to custom addresses. It can decide whether it wants to send to a given custom address type.
This is not enforced at type level, but CustomSender::poll_send should only be called with addresses for which CustomSender::is_valid_send_addr returns true.
Required Methods§
Sourcefn is_valid_send_addr(&self, addr: &CustomAddr) -> bool
fn is_valid_send_addr(&self, addr: &CustomAddr) -> bool
True if this sender can send to the given address.
Sourcefn poll_send(
&self,
cx: &mut Context<'_>,
dst: &CustomAddr,
src: Option<&CustomAddr>,
transmit: &Transmit<'_>,
) -> Poll<Result<()>>
fn poll_send( &self, cx: &mut Context<'_>, dst: &CustomAddr, src: Option<&CustomAddr>, transmit: &Transmit<'_>, ) -> Poll<Result<()>>
poll sending a packet on this sender.
This will only be called from iroh with addresses for which CustomSender::is_valid_send_addr returns true.
You should handle invalid addresses by returning an error.