pub struct MainHeaderBuilder { /* private fields */ }Expand description
Utility to easily generate a MainHeader.
Implementations§
Source§impl MainHeaderBuilder
impl MainHeaderBuilder
Sourcepub fn new() -> MainHeaderBuilder
pub fn new() -> MainHeaderBuilder
Creates a new main header builder.
Sourcepub fn with_type_ext(self, type_ext: [u8; 16]) -> Self
pub fn with_type_ext(self, type_ext: [u8; 16]) -> Self
Defines the Extended Type Information field of the BPX.
By default Extended Type Information is filled with zeros.
§Arguments
type_ext: the Extended Type Information block.
returns: MainHeaderBuilder
§Examples
use bpx::builder::MainHeaderBuilder;
let header = MainHeaderBuilder::new()
.with_type_ext([1; 16])
.build();
assert_eq!(header.type_ext, [1; 16]);Sourcepub fn with_version(self, version: u32) -> Self
pub fn with_version(self, version: u32) -> Self
Defines the version of the BPX.
The default value of the version int is given by BPX_CURRENT_VERSION.
Note: A version which is not specified in KNOWN_VERSIONS will cause the decoder to fail loading the file, complaining that the file is corrupted.
§Arguments
version: the new version of the BPX.
returns: MainHeaderBuilder
§Examples
use bpx::builder::MainHeaderBuilder;
let header = MainHeaderBuilder::new()
.with_version(1)
.build();
assert_eq!(header.version, 1);Sourcepub fn build(self) -> MainHeader
pub fn build(self) -> MainHeader
Consumes self and returns the generated MainHeader.
§Examples
use bpx::builder::MainHeaderBuilder;
let header = MainHeaderBuilder::new()
.with_type('M' as u8)
.with_type_ext([1; 16])
.with_version(1)
.build();
assert_eq!(header.btype, 'M' as u8);
assert_eq!(header.type_ext, [1; 16]);
assert_eq!(header.version, 1);Auto Trait Implementations§
impl Freeze for MainHeaderBuilder
impl RefUnwindSafe for MainHeaderBuilder
impl Send for MainHeaderBuilder
impl Sync for MainHeaderBuilder
impl Unpin for MainHeaderBuilder
impl UnsafeUnpin for MainHeaderBuilder
impl UnwindSafe for MainHeaderBuilder
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