pub enum StdfRecord {
Show 34 variants
FAR(FAR),
ATR(ATR),
VUR(VUR),
MIR(MIR),
MRR(MRR),
PCR(PCR),
HBR(HBR),
SBR(SBR),
PMR(PMR),
PGR(PGR),
PLR(PLR),
RDR(RDR),
SDR(SDR),
PSR(PSR),
NMR(NMR),
CNR(CNR),
SSR(SSR),
CDR(CDR),
WIR(WIR),
WRR(WRR),
WCR(WCR),
PIR(PIR),
PRR(PRR),
TSR(TSR),
PTR(PTR),
MPR(MPR),
FTR(FTR),
STR(STR),
BPS(BPS),
EPS(EPS),
GDR(GDR),
DTR(DTR),
ReservedRec(ReservedRec),
InvalidRec(RecordHeader),
}
Expand description
StdfRecord
is the data that returned from StdfReader iterator.
it contains the actually structs that contain STDF data.
use match
structure to access the nested data.
§Example
use rust_stdf::{StdfRecord, stdf_record_type::*};
let mut rec = StdfRecord::new(REC_PTR);
if let StdfRecord::PTR(ref mut ptr_data) = rec {
ptr_data.result = 100.0;
}
println!("{:?}", rec);
Variants§
FAR(FAR)
ATR(ATR)
VUR(VUR)
MIR(MIR)
MRR(MRR)
PCR(PCR)
HBR(HBR)
SBR(SBR)
PMR(PMR)
PGR(PGR)
PLR(PLR)
RDR(RDR)
SDR(SDR)
PSR(PSR)
NMR(NMR)
CNR(CNR)
SSR(SSR)
CDR(CDR)
WIR(WIR)
WRR(WRR)
WCR(WCR)
PIR(PIR)
PRR(PRR)
TSR(TSR)
PTR(PTR)
MPR(MPR)
FTR(FTR)
STR(STR)
BPS(BPS)
EPS(EPS)
GDR(GDR)
DTR(DTR)
ReservedRec(ReservedRec)
InvalidRec(RecordHeader)
Implementations§
Source§impl StdfRecord
impl StdfRecord
Sourcepub fn new(rec_type: u64) -> Self
pub fn new(rec_type: u64) -> Self
Create a StdfRecord of a given type with default data
use rust_stdf::{StdfRecord, stdf_record_type::REC_PMR};
// create StdfRecord with a nested PMR
let new_rec = StdfRecord::new(REC_PMR);
if let StdfRecord::PMR(pmr_rec) = new_rec {
assert_eq!(pmr_rec.head_num, 1);
assert_eq!(pmr_rec.site_num, 1);
} else {
// this case will not be hit
}
Sourcepub fn new_from_header(header: RecordHeader) -> Self
pub fn new_from_header(header: RecordHeader) -> Self
Create a StdfRecord
from a RecordHeader
with default data
The difference between new()
is that this method can save
the info of an invalid record header, help the caller to
debug
use rust_stdf::{StdfRecord, RecordHeader, stdf_record_type::REC_PMR};
// create a PMR StdfRecord from header
// (1, 60)
let pmr_header = RecordHeader {typ: 1, sub: 60, len: 0 };
let new_rec = StdfRecord::new_from_header(pmr_header);
if let StdfRecord::PMR(pmr_rec) = new_rec {
assert_eq!(pmr_rec.head_num, 1);
assert_eq!(pmr_rec.site_num, 1);
} else {
// this case will not be hit
}
Sourcepub fn get_type(&self) -> u64
pub fn get_type(&self) -> u64
returns the record type cdoe of the given StdfRecord,
which is defined in rust_stdf::stdf_record_type::*
module.
use rust_stdf::{StdfRecord, stdf_record_type::*};
// `REC_PTR` type code can be used for creating a new StdfRecord
let new_rec = StdfRecord::new(REC_PTR);
let returned_code = new_rec.get_type();
assert_eq!(REC_PTR, returned_code);
// type code can be used in variety of functions
// get record (typ, sub)
assert_eq!((15, 10), get_typ_sub_from_code(returned_code).unwrap());
// get record name
assert_eq!("PTR", get_rec_name_from_code(returned_code));
Sourcepub fn is_type(&self, rec_type: u64) -> bool
pub fn is_type(&self, rec_type: u64) -> bool
check the StdfRecord belongs the given type code(s), it is useful for filtering the records during the parsing iteration.
use rust_stdf::{StdfRecord, stdf_record_type::*};
let new_rec = StdfRecord::new(REC_PTR);
assert!(new_rec.is_type(REC_PTR));
assert!(new_rec.is_type(REC_PTR | REC_FTR | REC_MPR));
assert!(!new_rec.is_type(REC_FTR | REC_MPR));
Sourcepub fn read_from_bytes(&mut self, raw_data: &[u8], order: &ByteOrder)
pub fn read_from_bytes(&mut self, raw_data: &[u8], order: &ByteOrder)
parse StdfRecord from byte data which DOES NOT contain the record header (len, typ, sub),
requires a mutable StdfRecord to store the parsed data
use rust_stdf::{StdfRecord, ByteOrder, stdf_record_type::*};
let raw_with_no_header: [u8; 2] = [1, 4];
let mut new_rec = StdfRecord::new(REC_FAR);
new_rec.read_from_bytes(&raw_with_no_header, &ByteOrder::LittleEndian);
if let StdfRecord::FAR(ref far_rec) = new_rec {
assert_eq!(4, far_rec.stdf_ver);
}
Sourcepub fn read_from_bytes_with_header(
raw_data: &[u8],
order: &ByteOrder,
) -> Result<StdfRecord, StdfError>
pub fn read_from_bytes_with_header( raw_data: &[u8], order: &ByteOrder, ) -> Result<StdfRecord, StdfError>
parse StdfRecord from byte data which contains the record header (len, typ, sub).
§Error
if the input data is not a valid (wrong typ, sub),
incomplete data or incorrect byte order, StdfError
will be
returned instead.
use rust_stdf::{StdfRecord, ByteOrder, stdf_record_type::*};
let raw_with_header: [u8; 6] = [0, 2, 0, 10, 1, 4];
let new_rec = StdfRecord::read_from_bytes_with_header(&raw_with_header, &ByteOrder::BigEndian).unwrap();
if let StdfRecord::FAR(far_rec) = new_rec {
assert_eq!(4, far_rec.stdf_ver);
}
Trait Implementations§
Source§impl Clone for StdfRecord
impl Clone for StdfRecord
Source§fn clone(&self) -> StdfRecord
fn clone(&self) -> StdfRecord
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for StdfRecord
impl Debug for StdfRecord
Source§impl From<&RawDataElement> for StdfRecord
impl From<&RawDataElement> for StdfRecord
Source§fn from(raw_element: &RawDataElement) -> Self
fn from(raw_element: &RawDataElement) -> Self
it will NOT consume the input RawDataElement
Source§impl From<RawDataElement> for StdfRecord
impl From<RawDataElement> for StdfRecord
Source§fn from(raw_element: RawDataElement) -> Self
fn from(raw_element: RawDataElement) -> Self
it will consume the input RawDataElement