Skip to main content

Config

Struct Config 

Source
#[non_exhaustive]
pub struct Config {
Show 15 fields pub check: Check, pub crc_attempts: u32, pub crc_interval: Duration, pub block_size: BlockSize, pub checksum_1k: bool, pub short_tail: bool, pub pad: u8, pub start_timeout: Duration, pub timeout: Duration, pub byte_timeout: Duration, pub purge: Duration, pub retries: u32, pub recv_start_timeout: Option<Duration>, pub linger: Duration, pub max_size: Option<usize>,
}
Expand description

Tunables of a Transfer.

Non-exhaustive: start from Config::default and set the fields you need.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§check: Check

Receiver: the check asked for first. Check::HpCrc (default) sends D, Check::Crc16 sends C; both fall back to NAK (checksum) after Config::crc_attempts unanswered start characters. Check::Checksum sends NAK from the start. The sender ignores this and uses whatever the receiver asks for (NAK, C or D). Before the first ACK the sender follows a later C or D, and a NAK after D (the 49G’s fallback); a NAK in CRC-16 mode only resends block 1 in CRC-16, since a standard receiver NAKs a damaged block that way.

D is the default because no HP calculator answers C: the 49G’s XSEND answers D with HP-CRC blocks (1k blocks when the object is big enough) and ignores C; the 48GX’s XSEND ignores both and answers the NAK. Verified on the emulated 49G and 48GX (traces 49g-xsend*, 48gx-xsend*).

§crc_attempts: u32

Receiver: Cs (or Ds) sent before falling back to checksum (default 3).

§crc_interval: Duration

Receiver: wait after each C or D before the next start character (default 3 s).

§block_size: BlockSize

Sender: block size for full blocks (default 128). 1k blocks go out only when the receiver asked for a CRC (C or D), unless Config::checksum_1k is set: a receiver that opens with NAK gets 128-byte blocks.

§checksum_1k: bool

Sender: also send 1k blocks when the receiver asked for checksum mode (default false). The 48GX, which knows only checksum mode, NAKs every 1k block and cancels after nine (trace 48gx-xrecv-1k); XModem-1K is classically used with CRC only.

§short_tail: bool

Sender with 1k blocks: send the tail of the file in 128-byte blocks once no more than 896 bytes (7 x 128) remain, so no block carries 128 or more bytes of padding (default true). The 49G does not convert a received object with more than about 255 bytes of padding (as HP’s Conn4x source notes).

§pad: u8

Sender: padding byte for the last block (default 0x1A, SUB).

§start_timeout: Duration

Sender: how long to wait for the receiver’s first start character (default 60 s). Receiver: the overall wait for the first block is bounded by the start-character retries instead, or by Config::recv_start_timeout.

§timeout: Duration

Wait for an ACK/NAK (sender) or for the next block (receiver) (default 10 s).

§byte_timeout: Duration

Receiver: longest gap between two bytes of one block (default 1 s).

§purge: Duration

Receiver: after a bad block, input must be silent this long before we NAK, so the sender hears the NAK (default 1 s).

§retries: u32

Retries per block (or per EOT, or NAKs while starting) before giving up (default 10).

§recv_start_timeout: Option<Duration>

Receiver: keep sending start characters until this much time has passed since Transfer::start, instead of stopping after crc_attempts + retries of them (default None: count only). For a transfer a human starts on the calculator keyboard. The switch from C/D to NAK still happens after Config::crc_attempts.

§linger: Duration

Receiver: after we ACK the EOT, keep answering a retransmitted EOT with ACK for this long (default 1 s), in case our ACK was damaged or lost. FileEnd and Done are emitted when the ACK is queued; the linger emits nothing. Transfer::is_idle is false while it lasts; Transfer::start ends it early. Duration::ZERO turns it off. A sender that only retransmits after its reply timeout is caught only by a linger that long.

§max_size: Option<usize>

Receiver: most data bytes (padding included) accepted; a block that would go beyond fails the transfer with Error::TooLarge and CANs. Default 4 MiB, well above the largest HP object; None means no limit. XModem has no length field and block numbers wrap, so without a limit a peer can grow the buffer without bound.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for Config

§

impl Freeze for Config

§

impl Move for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnsafeUnpin for Config

§

impl UnwindSafe for Config

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.