pub trait DatabaseRecord: Sized + Debug + DatabaseRecordHelpers {
    // Required methods
    fn from_bytes(
        hdr: &DatabaseHeader,
        rdr: &mut Cursor<&[u8]>
    ) -> Result<Self, Error>;
    fn to_bytes(&self) -> Result<Vec<u8>, Error>;
    fn name_str(&self) -> Option<&str>;
    fn attributes(&self) -> Option<RecordAttributes>;
    fn data_len(&self) -> Option<u32>;
    fn unique_id(&self) -> Option<u32>;
    fn resource_id(&self) -> Option<u16>;
    fn construct_record(
        attributes: RecordAttributes,
        unique_id: u32,
        data_offset: u32,
        data_len: Option<u32>
    ) -> Self;
    fn construct_resource(
        name: &[u8; 4],
        record_id: u16,
        data_offset: u32,
        data_len: Option<u32>
    ) -> Self;
}
Expand description

Helper trait for database record types

Required Methods§

source

fn from_bytes( hdr: &DatabaseHeader, rdr: &mut Cursor<&[u8]> ) -> Result<Self, Error>

Read the record header from the given byte array

source

fn to_bytes(&self) -> Result<Vec<u8>, Error>

Write the record header to a new Vec<u8>

source

fn name_str(&self) -> Option<&str>

Return the record’s name, if known

source

fn attributes(&self) -> Option<RecordAttributes>

Return the record’s attributes, if known

source

fn data_len(&self) -> Option<u32>

Return the length of the record’s data, if known

source

fn unique_id(&self) -> Option<u32>

Return the unique id if the record is not a resource

source

fn resource_id(&self) -> Option<u16>

Return the resource id if the record is a resource

source

fn construct_record( attributes: RecordAttributes, unique_id: u32, data_offset: u32, data_len: Option<u32> ) -> Self

Construct a record with the given parameters

source

fn construct_resource( name: &[u8; 4], record_id: u16, data_offset: u32, data_len: Option<u32> ) -> Self

Construct a resource with the given parameters

Implementors§