pub enum SegbRecord {
V1(SegbV1Record),
V2(SegbV2Record),
}Expand description
A version-neutral SEGB record, produced by read_segb.
Variants§
Implementations§
Source§impl SegbRecord
impl SegbRecord
Sourcepub fn state(&self) -> EntryState
pub fn state(&self) -> EntryState
The logical state of this record.
Examples found in repository?
examples/dump_structure.rs (line 22)
9fn main() {
10 let path = std::env::args()
11 .nth(1)
12 .expect("usage: dump_structure <segb-file>");
13 let data = std::fs::read(&path).expect("read file");
14 let mut cur = std::io::Cursor::new(data);
15 let records = segb::read_segb(&mut cur).expect("parse SEGB");
16 println!("records: {}", records.len());
17 for (i, r) in records.iter().enumerate() {
18 // `crc_ok` is emitted so the differential harness can reconcile our
19 // CRC verdict against ccl-segb's `crc_passed` (Written records only).
20 println!(
21 " [{i}] state={:?} ts_unix={:?} crc_ok={} payload_len={}",
22 r.state(),
23 r.timestamp_unix(),
24 r.crc_ok(),
25 r.payload().len()
26 );
27 }
28}More examples
examples/dump_menuitems.rs (line 30)
21fn main() {
22 let path = std::env::args()
23 .nth(1)
24 .expect("usage: dump_menuitems <segb-file>");
25 let data = std::fs::read(&path).expect("read file");
26 let mut cur = std::io::Cursor::new(data);
27 let records = segb::read_segb(&mut cur).expect("parse SEGB");
28 let mut decoded = 0usize;
29 for (i, r) in records.iter().enumerate() {
30 if r.state() != EntryState::Written {
31 continue;
32 }
33 match segb::menuitem::decode_app_menu_item(r.payload(), r.timestamp_unix()) {
34 Ok(m) => {
35 println!(
36 " [{i}] application={:?} menu_item={:?} ts_unix={:?}",
37 m.application, m.menu_item, m.timestamp_unix
38 );
39 decoded += 1;
40 }
41 Err(e) => println!(" [{i}] decode_error={e}"),
42 }
43 }
44 println!("menu_items: {decoded}");
45}Sourcepub fn timestamp_unix(&self) -> Option<f64>
pub fn timestamp_unix(&self) -> Option<f64>
The primary timestamp as Unix seconds (seconds since 1970-01-01T00:00:00Z).
- For v1:
timestamp1. - For v2: the trailer
creationtimestamp.
Returns None if the stored f64 is not finite.
Examples found in repository?
examples/dump_structure.rs (line 23)
9fn main() {
10 let path = std::env::args()
11 .nth(1)
12 .expect("usage: dump_structure <segb-file>");
13 let data = std::fs::read(&path).expect("read file");
14 let mut cur = std::io::Cursor::new(data);
15 let records = segb::read_segb(&mut cur).expect("parse SEGB");
16 println!("records: {}", records.len());
17 for (i, r) in records.iter().enumerate() {
18 // `crc_ok` is emitted so the differential harness can reconcile our
19 // CRC verdict against ccl-segb's `crc_passed` (Written records only).
20 println!(
21 " [{i}] state={:?} ts_unix={:?} crc_ok={} payload_len={}",
22 r.state(),
23 r.timestamp_unix(),
24 r.crc_ok(),
25 r.payload().len()
26 );
27 }
28}More examples
examples/dump_menuitems.rs (line 33)
21fn main() {
22 let path = std::env::args()
23 .nth(1)
24 .expect("usage: dump_menuitems <segb-file>");
25 let data = std::fs::read(&path).expect("read file");
26 let mut cur = std::io::Cursor::new(data);
27 let records = segb::read_segb(&mut cur).expect("parse SEGB");
28 let mut decoded = 0usize;
29 for (i, r) in records.iter().enumerate() {
30 if r.state() != EntryState::Written {
31 continue;
32 }
33 match segb::menuitem::decode_app_menu_item(r.payload(), r.timestamp_unix()) {
34 Ok(m) => {
35 println!(
36 " [{i}] application={:?} menu_item={:?} ts_unix={:?}",
37 m.application, m.menu_item, m.timestamp_unix
38 );
39 decoded += 1;
40 }
41 Err(e) => println!(" [{i}] decode_error={e}"),
42 }
43 }
44 println!("menu_items: {decoded}");
45}Sourcepub fn payload(&self) -> &[u8] ⓘ
pub fn payload(&self) -> &[u8] ⓘ
The raw protobuf (or other format) payload bytes.
Examples found in repository?
examples/dump_structure.rs (line 25)
9fn main() {
10 let path = std::env::args()
11 .nth(1)
12 .expect("usage: dump_structure <segb-file>");
13 let data = std::fs::read(&path).expect("read file");
14 let mut cur = std::io::Cursor::new(data);
15 let records = segb::read_segb(&mut cur).expect("parse SEGB");
16 println!("records: {}", records.len());
17 for (i, r) in records.iter().enumerate() {
18 // `crc_ok` is emitted so the differential harness can reconcile our
19 // CRC verdict against ccl-segb's `crc_passed` (Written records only).
20 println!(
21 " [{i}] state={:?} ts_unix={:?} crc_ok={} payload_len={}",
22 r.state(),
23 r.timestamp_unix(),
24 r.crc_ok(),
25 r.payload().len()
26 );
27 }
28}More examples
examples/dump_menuitems.rs (line 33)
21fn main() {
22 let path = std::env::args()
23 .nth(1)
24 .expect("usage: dump_menuitems <segb-file>");
25 let data = std::fs::read(&path).expect("read file");
26 let mut cur = std::io::Cursor::new(data);
27 let records = segb::read_segb(&mut cur).expect("parse SEGB");
28 let mut decoded = 0usize;
29 for (i, r) in records.iter().enumerate() {
30 if r.state() != EntryState::Written {
31 continue;
32 }
33 match segb::menuitem::decode_app_menu_item(r.payload(), r.timestamp_unix()) {
34 Ok(m) => {
35 println!(
36 " [{i}] application={:?} menu_item={:?} ts_unix={:?}",
37 m.application, m.menu_item, m.timestamp_unix
38 );
39 decoded += 1;
40 }
41 Err(e) => println!(" [{i}] decode_error={e}"),
42 }
43 }
44 println!("menu_items: {decoded}");
45}Sourcepub fn data_offset(&self) -> u64
pub fn data_offset(&self) -> u64
File offset of the first byte of Self::payload.
Sourcepub fn stored_crc32(&self) -> u32
pub fn stored_crc32(&self) -> u32
The CRC-32 stored in the record header.
Sourcepub fn computed_crc32(&self) -> u32
pub fn computed_crc32(&self) -> u32
The CRC-32 computed over the payload bytes as read.
Sourcepub fn crc_ok(&self) -> bool
pub fn crc_ok(&self) -> bool
Returns true if stored and computed CRC-32 values match.
Examples found in repository?
examples/dump_structure.rs (line 24)
9fn main() {
10 let path = std::env::args()
11 .nth(1)
12 .expect("usage: dump_structure <segb-file>");
13 let data = std::fs::read(&path).expect("read file");
14 let mut cur = std::io::Cursor::new(data);
15 let records = segb::read_segb(&mut cur).expect("parse SEGB");
16 println!("records: {}", records.len());
17 for (i, r) in records.iter().enumerate() {
18 // `crc_ok` is emitted so the differential harness can reconcile our
19 // CRC verdict against ccl-segb's `crc_passed` (Written records only).
20 println!(
21 " [{i}] state={:?} ts_unix={:?} crc_ok={} payload_len={}",
22 r.state(),
23 r.timestamp_unix(),
24 r.crc_ok(),
25 r.payload().len()
26 );
27 }
28}Trait Implementations§
Source§impl Clone for SegbRecord
impl Clone for SegbRecord
Source§fn clone(&self) -> SegbRecord
fn clone(&self) -> SegbRecord
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 moreAuto Trait Implementations§
impl Freeze for SegbRecord
impl RefUnwindSafe for SegbRecord
impl Send for SegbRecord
impl Sync for SegbRecord
impl Unpin for SegbRecord
impl UnsafeUnpin for SegbRecord
impl UnwindSafe for SegbRecord
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