Skip to main content

FixedRecord

Trait FixedRecord 

Source
pub trait FixedRecord {
    type Field: Copy + Eq;

    const TOTAL_LEN: usize;

    // Required methods
    fn parse(src: &[u8]) -> Result<Self, Error>
       where Self: Sized;
    fn to_bytes(&self) -> Vec<u8> ⓘ;
    fn field_name(field: Self::Field) -> &'static str;
    fn field_bytes(&self, field: Self::Field) -> &[u8] ⓘ;
}
Expand description

Common interface for types that can be handled as fixed-width records. 固定長レコードとして扱える型の共通インターフェースです。

This is usually implemented by the #[fixed_record] attribute macro. 通常は #[fixed_record] attribute macro によって自動実装されます。

Required Associated Constants§

Source

const TOTAL_LEN: usize

Total byte length of the record. レコード全体のバイト長です。

Required Associated Types§

Source

type Field: Copy + Eq

The field enum type that can be used for sequence checks. シーケンスチェックで指定できるフィールド enum の型です。

Required Methods§

Source

fn parse(src: &[u8]) -> Result<Self, Error>
where Self: Sized,

Creates a record from a byte slice. バイト列からレコードを作成します。

Source

fn to_bytes(&self) -> Vec<u8> ⓘ

Copies the record into its fixed-width byte representation. レコードを固定長バイト列へコピーして返します。

Source

fn field_name(field: Self::Field) -> &'static str

Returns the declaration name of the specified field. 指定フィールドの定義名を返します。

Source

fn field_bytes(&self, field: Self::Field) -> &[u8] ⓘ

Returns the bytes stored in the specified field. 指定フィールドのバイト列を返します。

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§