Skip to main content

EncodeOptions

Struct EncodeOptions 

Source
pub struct EncodeOptions {
Show 13 fields pub format: RecordFormat, pub codepage: Codepage, pub preferred_zoned_encoding: ZonedEncodingFormat, pub use_raw: bool, pub bwz_encode: bool, pub strict_mode: bool, pub max_errors: Option<u64>, pub threads: usize, pub coerce_numbers: bool, pub on_encode_unmappable: UnmappablePolicy, pub json_number_mode: JsonNumberMode, pub zoned_encoding_override: Option<ZonedEncodingFormat>, pub float_format: FloatFormat,
}
Expand description

Options for encoding operations

Fields§

§format: RecordFormat

Record format

§codepage: Codepage

Character encoding

§preferred_zoned_encoding: ZonedEncodingFormat

Fallback zoned decimal encoding format when no override or metadata applies

§use_raw: bool

Whether to use raw data when available

§bwz_encode: bool

BLANK WHEN ZERO encoding policy

§strict_mode: bool

Error handling mode

§max_errors: Option<u64>

Maximum errors before stopping

§threads: usize

Number of threads for parallel processing

§coerce_numbers: bool

Whether to coerce non-string JSON numbers to strings before encoding

§on_encode_unmappable: UnmappablePolicy

Policy for unmappable characters during encoding

§json_number_mode: JsonNumberMode

JSON number representation mode (used when round-tripping)

§zoned_encoding_override: Option<ZonedEncodingFormat>

Explicit zoned decimal encoding format override

When specified, forces all zoned decimal fields to use this encoding format, overriding any preserved format from decode operations. This provides the highest precedence in the format selection hierarchy:

  1. Explicit override (this field)
  2. Preserved format from decode metadata
  3. EBCDIC default for mainframe compatibility
§float_format: FloatFormat

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

Implementations§

Source§

impl EncodeOptions

Source

pub fn new() -> Self

Create new encode options with default values

Returns options configured for:

  • Fixed record format
  • CP037 EBCDIC codepage
  • Single-threaded processing
  • BLANK WHEN ZERO disabled

Use the builder methods to customize:

§Examples
use copybook_options::{EncodeOptions, Codepage, RecordFormat};

let opts = EncodeOptions::new()
    .with_codepage(Codepage::CP037)
    .with_format(RecordFormat::Fixed)
    .with_bwz_encode(true)
    .with_coerce_numbers(true)
    .with_threads(4);

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

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

Set the record format

Source

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

Set the codepage

Source

pub fn with_use_raw(self, use_raw: bool) -> Self

Enable or disable raw data usage

Source

pub fn with_bwz_encode(self, bwz_encode: bool) -> Self

Enable or disable BLANK WHEN ZERO encoding

Source

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

Set the preferred zoned encoding fallback when overrides and preserved formats are absent

Source

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

Enable or disable strict mode

Source

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

Set the maximum number of errors before stopping

Source

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

Set the number of threads for parallel processing

Source

pub fn with_coerce_numbers(self, coerce_numbers: bool) -> Self

Enable or disable number coercion

Source

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

Set the policy for unmappable characters during encoding

Source

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

Set the JSON number mode

Source

pub fn with_zoned_encoding_override( self, zoned_encoding_override: Option<ZonedEncodingFormat>, ) -> Self

Set explicit zoned decimal encoding format override

Forces all zoned decimal fields to use the specified encoding format, overriding any preserved format from decode operations. Use None to disable override and respect preserved formats.

Source

pub fn with_zoned_encoding_format(self, format: ZonedEncodingFormat) -> Self

Convenience method to set explicit zoned encoding format

Equivalent to with_zoned_encoding_override(Some(format)).

Source

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

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

Trait Implementations§

Source§

impl Clone for EncodeOptions

Source§

fn clone(&self) -> EncodeOptions

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 EncodeOptions

Source§

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

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

impl Default for EncodeOptions

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for EncodeOptions

Source§

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

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

impl Serialize for EncodeOptions

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::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> 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>,