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

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
}

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
}

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));

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));

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);
}

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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

it will NOT consume the input RawDataElement

it will consume the input RawDataElement

This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.