Skip to main content

Sender

Struct Sender 

Source
pub struct Sender { /* private fields */ }
Expand description

The data-carrying half of a transfer: what a Sender may send next, and when.

Whether this node is the Initiator or the Responder does not change any rule here — only Parameters::control does, by saying which end drives.

Implementations§

Source§

impl Sender

Source

pub const fn new(params: Parameters) -> Self

A Sender that has agreed params and sent nothing.

Source

pub const fn parameters(&self) -> &Parameters

The negotiated parameters.

Source

pub const fn cursor(&self) -> u64

The offset in the file the next block should be read from.

Source

pub const fn sent(&self) -> u64

How many octets have been put into blocks so far.

Source

pub const fn is_complete(&self) -> bool

Whether the Receiver has acknowledged the BlockEOF, ending the session.

Source

pub const fn may_send(&self) -> bool

Whether a block may be sent right now.

In Sender drive, always, until the end. In Receiver drive, only while a BlockQuery is outstanding — which is the whole point of the mode: a sleepy Receiver is not woken by blocks it did not ask for.

Source

pub fn room(&self) -> usize

The largest block that may be sent next: the negotiated size, or what is left of a definite length if that is smaller.

Source

pub fn on_query(&mut self, counter: u32) -> Rejected<()>

Takes a BlockQuery from a driving Receiver (§11.22.6.2).

Source

pub fn on_query_with_skip( &mut self, counter: u32, bytes_to_skip: u64, ) -> Rejected<u64>

Takes a BlockQueryWithSkip (§11.22.6.3) and returns the cursor it moved to.

Skipping past the end of the file is explicitly not an error: “there SHALL be no error indicated when receiving a request to skip past the end of the transferable data”, and the answer is an empty BlockEOF.

Source

pub fn block(&mut self, len: usize, eof: bool) -> Rejected<u32>

Registers a block of len octets, and returns the Block Counter to put in it.

eof chooses between a Block and a BlockEOF, and the difference is not only the opcode: §11.22.6.4 requires a Block to carry at least one octet, while §11.22.6.5 allows an empty BlockEOF “to indicate an empty file”.

Source

pub fn on_ack(&mut self, counter: u32, eof: bool) -> Rejected<()>

Takes a BlockAck or BlockAckEOF (§11.22.6.6, §11.22.6.7).

Trait Implementations§

Source§

impl Debug for Sender

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Sender

§

impl Freeze for Sender

§

impl Move for Sender

§

impl RefUnwindSafe for Sender

§

impl Send for Sender

§

impl Sync for Sender

§

impl Unpin for Sender

§

impl UnsafeUnpin for Sender

§

impl UnwindSafe for Sender

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, 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.