Skip to Content
Справочник APIModule converter

Module converter

CLI tool for converting transaction files between Binary, Text, and CSV formats.

Usage

# Convert text to binary converter --input transactions.txt --input-format text --output-format binary --output transactions.bin # Read from stdin, write to stdout cat transactions.txt | converter --input-format text --output-format csv > transactions.csv # Validate by round-trip conversion converter -i data.bin --input-format binary --output-format binary -o validated.bin

Types

Struct Args

Attributes:

  • Other("#[command(name = \"converter\")]")
  • Other("#[command(version, about)]")

Convert transaction files between Binary, Text, and CSV formats.

Reads transactions from input (file or stdin) and writes them to output (file or stdout) in the specified format.

pub(crate) struct Args { pub(crate) input: Option<std::path::PathBuf>, pub(crate) input_format: FormatArg, pub(crate) output_format: FormatArg, pub(crate) output: Option<std::path::PathBuf>, }

Fields

NameTypeDocumentation
inputOption<std::path::PathBuf>Input file path. If not specified, reads from stdin.
input_formatFormatArgInput format.
output_formatFormatArgOutput format.
outputOption<std::path::PathBuf>Output file path. If not specified, writes to stdout.

Implementations

Trait Implementations
  • Any

    • fn type_id(self: &Self) -> TypeId { /* ... */ }
  • Args

    • fn group_id() -> Option<clap::Id> { /* ... */ }
    • fn augment_args<''b>(__clap_app: clap::Command) -> clap::Command { /* ... */ }
    • fn augment_args_for_update<''b>(__clap_app: clap::Command) -> clap::Command { /* ... */ }
  • Borrow

    • fn borrow(self: &Self) -> &T { /* ... */ }
  • BorrowMut

    • fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
  • CommandFactory

    • fn command<''b>() -> clap::Command { /* ... */ }
    • fn command_for_update<''b>() -> clap::Command { /* ... */ }
  • Debug

    • fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
  • Freeze

  • From

    • fn from(t: T) -> T { /* ... */ }
      Returns the argument unchanged.
  • FromArgMatches

    • fn from_arg_matches(__clap_arg_matches: &clap::ArgMatches) -> ::std::result::Result<Self, clap::Error> { /* ... */ }
    • fn from_arg_matches_mut(__clap_arg_matches: &mut clap::ArgMatches) -> ::std::result::Result<Self, clap::Error> { /* ... */ }
    • fn update_from_arg_matches(self: &mut Self, __clap_arg_matches: &clap::ArgMatches) -> ::std::result::Result<(), clap::Error> { /* ... */ }
    • fn update_from_arg_matches_mut(self: &mut Self, __clap_arg_matches: &mut clap::ArgMatches) -> ::std::result::Result<(), clap::Error> { /* ... */ }
  • Into

    • fn into(self: Self) -> U { /* ... */ }
      Calls U::from(self).
  • Parser

  • RefUnwindSafe

  • Send

  • Sync

  • TryFrom

    • fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
  • TryInto

    • fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
  • Unpin

  • UnwindSafe

Enum FormatArg

Supported transaction formats for CLI arguments.

pub(crate) enum FormatArg { Binary, Text, Csv, }

Variants

Binary

Binary YPBN format (compact, with magic bytes).

Text

Text KEY: VALUE format (human-readable).

Csv

CSV format with header row.

Implementations

Trait Implementations
  • Any

    • fn type_id(self: &Self) -> TypeId { /* ... */ }
  • Borrow

    • fn borrow(self: &Self) -> &T { /* ... */ }
  • BorrowMut

    • fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
  • Clone

    • fn clone(self: &Self) -> FormatArg { /* ... */ }
  • CloneToUninit

    • unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ }
  • Copy

  • Debug

    • fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
  • Freeze

  • From

    • fn from(t: T) -> T { /* ... */ }

      Returns the argument unchanged.

    • fn from(arg: FormatArg) -> Self { /* ... */ }
  • Into

    • fn into(self: Self) -> U { /* ... */ }
      Calls U::from(self).
  • RefUnwindSafe

  • Send

  • Sync

  • ToOwned

    • fn to_owned(self: &Self) -> T { /* ... */ }
    • fn clone_into(self: &Self, target: &mut T) { /* ... */ }
  • TryFrom

    • fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
  • TryInto

    • fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
  • Unpin

  • UnwindSafe

  • ValueEnum

    • fn value_variants<''a>() -> &''a [Self] { /* ... */ }
    • fn to_possible_value<''a>(self: &Self) -> ::std::option::Option<clap::builder::PossibleValue> { /* ... */ }

Functions

Function main

pub(crate) fn main() { /* ... */ }

Function run

pub(crate) fn run() -> anyhow::Result<()> { /* ... */ }

Function convert

Converts transactions from input to output with runtime format selection.

Uses compile-time dispatch through marker types for optimal performance.

pub(crate) fn convert<R: Read, W: Write>(input: R, output: W, input_format: Format, output_format: Format) -> anyhow::Result<usize> { /* ... */ }

Function convert_typed

Type-safe streaming conversion using TransactionReader and TransactionWriter.

Reads transactions one by one from input and writes them to output, ensuring minimal memory usage for large files.

pub(crate) fn convert_typed<R, W, IF, OF>(input: R, output: W) -> anyhow::Result<usize> where R: Read, W: Write, IF: SerdeFormat, OF: SerdeFormat { /* ... */ }