#[repr(C)]pub struct FileHeader {
pub magic: [u8; 4],
pub version: FileVersion,
pub checksum_algorithm: ChecksumAlgorithm,
pub compression_algorithm: CompressionAlgorithm,
pub flags: FileFlags,
pub created_at: u64,
pub modified_at: u64,
pub schema_version: u64,
pub reserved: [u8; 24],
}Expand description
ファイルヘッダー(64バイト固定)。
フィールド配置(リトルエンディアン):
- 0..4: magic
- 4..6: version.major
- 6..8: version.minor
- 8..10: version.patch
- 10: checksum_algorithm
- 11: compression_algorithm
- 12..16: flags
- 16..24: created_at (µs)
- 24..32: modified_at (µs)
- 32..40: schema_version
- 40..64: reserved (ゼロ埋め)
Fields§
§magic: [u8; 4]マジックナンバー。
version: FileVersionファイルバージョン。
checksum_algorithm: ChecksumAlgorithmチェックサムアルゴリズム。
compression_algorithm: CompressionAlgorithm圧縮アルゴリズム(デフォルト)。
flags: FileFlagsグローバルフラグ。
created_at: u64作成タイムスタンプ(µs)。
modified_at: u64最終更新タイムスタンプ(µs)。
schema_version: u64スキーマバージョン(アプリケーション依存)。
reserved: [u8; 24]将来拡張のための予約領域。
Implementations§
Source§impl FileHeader
impl FileHeader
Sourcepub fn new(version: FileVersion, flags: FileFlags) -> Self
pub fn new(version: FileVersion, flags: FileFlags) -> Self
新規ヘッダーを生成する。
タイムスタンプは現在時刻のマイクロ秒、圧縮アルゴリズムはSnappy、 チェックサムはCRC32をデフォルトとする。
Sourcepub fn from_bytes(bytes: &[u8; 64]) -> Result<Self, FormatError>
pub fn from_bytes(bytes: &[u8; 64]) -> Result<Self, FormatError>
バイト列からヘッダーを復元する。
Sourcepub fn validate_magic(&self) -> Result<(), FormatError>
pub fn validate_magic(&self) -> Result<(), FormatError>
マジックナンバーを検証する。
Sourcepub fn check_compatibility(
&self,
reader_version: &FileVersion,
) -> Result<(), FormatError>
pub fn check_compatibility( &self, reader_version: &FileVersion, ) -> Result<(), FormatError>
リーダーバージョンとの互換性を検証する。
ファイルのバージョンがリーダーより新しい場合に FormatError::IncompatibleVersion を返す。
Trait Implementations§
Source§impl Clone for FileHeader
impl Clone for FileHeader
Source§fn clone(&self) -> FileHeader
fn clone(&self) -> FileHeader
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for FileHeader
Source§impl Debug for FileHeader
impl Debug for FileHeader
impl Eq for FileHeader
Source§impl PartialEq for FileHeader
impl PartialEq for FileHeader
impl StructuralPartialEq for FileHeader
Auto Trait Implementations§
impl Freeze for FileHeader
impl RefUnwindSafe for FileHeader
impl Send for FileHeader
impl Sync for FileHeader
impl Unpin for FileHeader
impl UnsafeUnpin for FileHeader
impl UnwindSafe for FileHeader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more