Skip to main content

DecodeOptions

Struct DecodeOptions 

Source
pub struct DecodeOptions {
Show 13 fields pub format: RecordFormat, pub codepage: Codepage, pub json_number_mode: JsonNumberMode, pub emit_filler: bool, pub emit_meta: bool, pub emit_raw: RawMode, pub strict_mode: bool, pub max_errors: Option<u64>, pub on_decode_unmappable: UnmappablePolicy, pub threads: usize, pub preserve_zoned_encoding: bool, pub preferred_zoned_encoding: ZonedEncodingFormat, pub float_format: FloatFormat,
}
Expand description

Options for decoding operations

Fields§

§format: RecordFormat

Record format

§codepage: Codepage

Character encoding

§json_number_mode: JsonNumberMode

JSON number representation

§emit_filler: bool

Whether to emit FILLER fields

§emit_meta: bool

Whether to emit metadata

§emit_raw: RawMode

Raw data capture mode

§strict_mode: bool

Error handling mode

§max_errors: Option<u64>

Maximum errors before stopping

§on_decode_unmappable: UnmappablePolicy

Policy for unmappable characters

§threads: usize

Number of threads for parallel processing

§preserve_zoned_encoding: bool

Enable zoned decimal encoding preservation for binary round-trip consistency

When enabled, the decoder captures the original encoding format (ASCII vs EBCDIC) and includes it in metadata for use during re-encoding to maintain byte-level fidelity in encode/decode cycles.

§preferred_zoned_encoding: ZonedEncodingFormat

Preferred encoding format when auto-detection is ambiguous

Used as fallback when ZonedEncodingFormat::Auto cannot determine the format from the data (e.g., all-zero fields, mixed encodings).

§float_format: FloatFormat

Floating-point representation for COMP-1/COMP-2 fields.

Implementations§

Source§

impl DecodeOptions

Source

pub fn new() -> DecodeOptions

Create new decode options with default values

Returns options configured for:

  • Fixed record format
  • CP037 EBCDIC codepage
  • Lossless JSON number mode
  • Single-threaded processing

Use the builder methods to customize:

§Examples
use copybook_options::{DecodeOptions, Codepage, JsonNumberMode, RecordFormat, RawMode};

let opts = DecodeOptions::new()
    .with_codepage(Codepage::CP037)
    .with_format(RecordFormat::Fixed)
    .with_json_number_mode(JsonNumberMode::Lossless)
    .with_emit_meta(true)
    .with_threads(4);

assert_eq!(opts.threads, 4);
assert!(opts.emit_meta);
Source

pub fn with_format(self, format: RecordFormat) -> DecodeOptions

Set the record format

Source

pub fn with_codepage(self, codepage: Codepage) -> DecodeOptions

Set the codepage

Source

pub fn with_json_number_mode(self, mode: JsonNumberMode) -> DecodeOptions

Set the JSON number mode

Source

pub fn with_emit_filler(self, emit_filler: bool) -> DecodeOptions

Enable or disable FILLER field emission

Source

pub fn with_emit_meta(self, emit_meta: bool) -> DecodeOptions

Enable or disable metadata emission

Source

pub fn with_emit_raw(self, emit_raw: RawMode) -> DecodeOptions

Set the raw data capture mode

Controls whether and how raw binary data is included in decode output:

  • RawMode::Off — no raw data (default)
  • RawMode::Record — record payload in __raw_b64
  • RawMode::RecordRDW — RDW header + payload in __raw_b64
  • RawMode::Field — per-field raw values in <FIELD>__raw_b64
Source

pub fn with_strict_mode(self, strict_mode: bool) -> DecodeOptions

Enable or disable strict mode

Source

pub fn with_max_errors(self, max_errors: Option<u64>) -> DecodeOptions

Set the maximum number of errors before stopping

Source

pub fn with_unmappable_policy(self, policy: UnmappablePolicy) -> DecodeOptions

Set the policy for unmappable characters

Source

pub fn with_threads(self, threads: usize) -> DecodeOptions

Set the number of threads for parallel processing

Source

pub fn with_preserve_zoned_encoding( self, preserve_zoned_encoding: bool, ) -> DecodeOptions

Enable zoned decimal encoding preservation for round-trip fidelity

When enabled, the decoder will detect and preserve the original encoding format (ASCII vs EBCDIC) for use during subsequent encoding operations. This ensures byte-level consistency in encode/decode cycles.

Source

pub fn with_preferred_zoned_encoding( self, preferred_zoned_encoding: ZonedEncodingFormat, ) -> DecodeOptions

Set the preferred zoned encoding format for ambiguous detection

This format is used as a fallback when auto-detection cannot determine the encoding from the data (e.g., all-zero fields, mixed encodings).

Source

pub fn with_float_format(self, float_format: FloatFormat) -> DecodeOptions

Set floating-point representation for COMP-1/COMP-2 fields

Trait Implementations§

Source§

impl Clone for DecodeOptions

Source§

fn clone(&self) -> DecodeOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for DecodeOptions

Source§

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

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

impl Default for DecodeOptions

Source§

fn default() -> DecodeOptions

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

impl<'de> Deserialize<'de> for DecodeOptions

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<DecodeOptions, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for DecodeOptions

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> 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 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> 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 = 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 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.
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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,