Trait palmrs_database::record::DatabaseRecord
source · 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§
sourcefn from_bytes(
hdr: &DatabaseHeader,
rdr: &mut Cursor<&[u8]>
) -> Result<Self, Error>
fn from_bytes( hdr: &DatabaseHeader, rdr: &mut Cursor<&[u8]> ) -> Result<Self, Error>
Read the record header from the given byte array
sourcefn attributes(&self) -> Option<RecordAttributes>
fn attributes(&self) -> Option<RecordAttributes>
Return the record’s attributes, if known
sourcefn resource_id(&self) -> Option<u16>
fn resource_id(&self) -> Option<u16>
Return the resource id if the record is a resource
sourcefn construct_record(
attributes: RecordAttributes,
unique_id: u32,
data_offset: u32,
data_len: Option<u32>
) -> Self
fn construct_record( attributes: RecordAttributes, unique_id: u32, data_offset: u32, data_len: Option<u32> ) -> Self
Construct a record with the given parameters