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§
Required Associated Types§
Required Methods§
Sourcefn parse(src: &[u8]) -> Result<Self, Error>where
Self: Sized,
fn parse(src: &[u8]) -> Result<Self, Error>where
Self: Sized,
Creates a record from a byte slice. バイト列からレコードを作成します。
Sourcefn to_bytes(&self) -> Vec<u8> ⓘ
fn to_bytes(&self) -> Vec<u8> ⓘ
Copies the record into its fixed-width byte representation. レコードを固定長バイト列へコピーして返します。
Sourcefn field_name(field: Self::Field) -> &'static str
fn field_name(field: Self::Field) -> &'static str
Returns the declaration name of the specified field. 指定フィールドの定義名を返します。
Sourcefn field_bytes(&self, field: Self::Field) -> &[u8] ⓘ
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".