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: RecordFormatRecord format
codepage: CodepageCharacter encoding
preferred_zoned_encoding: ZonedEncodingFormatFallback zoned decimal encoding format when no override or metadata applies
use_raw: boolWhether to use raw data when available
bwz_encode: boolBLANK WHEN ZERO encoding policy
strict_mode: boolError handling mode
max_errors: Option<u64>Maximum errors before stopping
threads: usizeNumber of threads for parallel processing
coerce_numbers: boolWhether to coerce non-string JSON numbers to strings before encoding
on_encode_unmappable: UnmappablePolicyPolicy for unmappable characters during encoding
json_number_mode: JsonNumberModeJSON 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:
- Explicit override (this field)
- Preserved format from decode metadata
- EBCDIC default for mainframe compatibility
float_format: FloatFormatFloating-point representation for COMP-1/COMP-2 fields.
Implementations§
Source§impl EncodeOptions
impl EncodeOptions
Sourcepub fn new() -> EncodeOptions
pub fn new() -> EncodeOptions
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);Sourcepub fn with_format(self, format: RecordFormat) -> EncodeOptions
pub fn with_format(self, format: RecordFormat) -> EncodeOptions
Set the record format
Sourcepub fn with_codepage(self, codepage: Codepage) -> EncodeOptions
pub fn with_codepage(self, codepage: Codepage) -> EncodeOptions
Set the codepage
Sourcepub fn with_use_raw(self, use_raw: bool) -> EncodeOptions
pub fn with_use_raw(self, use_raw: bool) -> EncodeOptions
Enable or disable raw data usage
Sourcepub fn with_bwz_encode(self, bwz_encode: bool) -> EncodeOptions
pub fn with_bwz_encode(self, bwz_encode: bool) -> EncodeOptions
Enable or disable BLANK WHEN ZERO encoding
Sourcepub fn with_preferred_zoned_encoding(
self,
preferred_zoned_encoding: ZonedEncodingFormat,
) -> EncodeOptions
pub fn with_preferred_zoned_encoding( self, preferred_zoned_encoding: ZonedEncodingFormat, ) -> EncodeOptions
Set the preferred zoned encoding fallback when overrides and preserved formats are absent
Sourcepub fn with_strict_mode(self, strict_mode: bool) -> EncodeOptions
pub fn with_strict_mode(self, strict_mode: bool) -> EncodeOptions
Enable or disable strict mode
Sourcepub fn with_max_errors(self, max_errors: Option<u64>) -> EncodeOptions
pub fn with_max_errors(self, max_errors: Option<u64>) -> EncodeOptions
Set the maximum number of errors before stopping
Sourcepub fn with_threads(self, threads: usize) -> EncodeOptions
pub fn with_threads(self, threads: usize) -> EncodeOptions
Set the number of threads for parallel processing
Sourcepub fn with_coerce_numbers(self, coerce_numbers: bool) -> EncodeOptions
pub fn with_coerce_numbers(self, coerce_numbers: bool) -> EncodeOptions
Enable or disable number coercion
Sourcepub fn with_unmappable_policy(self, policy: UnmappablePolicy) -> EncodeOptions
pub fn with_unmappable_policy(self, policy: UnmappablePolicy) -> EncodeOptions
Set the policy for unmappable characters during encoding
Sourcepub fn with_json_number_mode(self, mode: JsonNumberMode) -> EncodeOptions
pub fn with_json_number_mode(self, mode: JsonNumberMode) -> EncodeOptions
Set the JSON number mode
Sourcepub fn with_zoned_encoding_override(
self,
zoned_encoding_override: Option<ZonedEncodingFormat>,
) -> EncodeOptions
pub fn with_zoned_encoding_override( self, zoned_encoding_override: Option<ZonedEncodingFormat>, ) -> EncodeOptions
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.
Sourcepub fn with_zoned_encoding_format(
self,
format: ZonedEncodingFormat,
) -> EncodeOptions
pub fn with_zoned_encoding_format( self, format: ZonedEncodingFormat, ) -> EncodeOptions
Convenience method to set explicit zoned encoding format
Equivalent to with_zoned_encoding_override(Some(format)).
Sourcepub fn with_float_format(self, float_format: FloatFormat) -> EncodeOptions
pub fn with_float_format(self, float_format: FloatFormat) -> EncodeOptions
Set floating-point representation for COMP-1/COMP-2 fields
Trait Implementations§
Source§impl Clone for EncodeOptions
impl Clone for EncodeOptions
Source§fn clone(&self) -> EncodeOptions
fn clone(&self) -> EncodeOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more