Module builder

Module builder 

Source
Expand description

Builder pattern for constructing canonically-ordered records

The RecordBuilder provides a fluent API for building LnmpRecord instances with guaranteed canonical field ordering (sorted by FID).

§Example

use lnmp_core::{RecordBuilder, LnmpField, LnmpValue};

let record = RecordBuilder::new()
    .add_field(LnmpField { fid: 23, value: LnmpValue::Int(3) })
    .add_field(LnmpField { fid: 7, value: LnmpValue::Int(1) })
    .add_field(LnmpField { fid: 12, value: LnmpValue::Int(2) })
    .build();

// Fields are automatically sorted by FID
assert_eq!(record.fields()[0].fid, 7);
assert_eq!(record.fields()[1].fid, 12);
assert_eq!(record.fields()[2].fid, 23);

Structs§

RecordBuilder
Builder for creating LnmpRecords with guaranteed canonical field ordering