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
impl Sender
Sourcepub const fn new(params: Parameters) -> Self
pub const fn new(params: Parameters) -> Self
A Sender that has agreed params and sent nothing.
Sourcepub const fn parameters(&self) -> &Parameters
pub const fn parameters(&self) -> &Parameters
The negotiated parameters.
Sourcepub const fn is_complete(&self) -> bool
pub const fn is_complete(&self) -> bool
Whether the Receiver has acknowledged the BlockEOF, ending the session.
Sourcepub const fn may_send(&self) -> bool
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.
Sourcepub fn room(&self) -> usize
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.
Sourcepub fn on_query(&mut self, counter: u32) -> Rejected<()>
pub fn on_query(&mut self, counter: u32) -> Rejected<()>
Takes a BlockQuery from a driving Receiver (§11.22.6.2).
Sourcepub fn on_query_with_skip(
&mut self,
counter: u32,
bytes_to_skip: u64,
) -> Rejected<u64>
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.
Sourcepub fn block(&mut self, len: usize, eof: bool) -> Rejected<u32>
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”.