pub struct RDWRecord {
pub header: [u8; 4],
pub payload: Vec<u8>,
}Expand description
An RDW record with header and payload bytes.
Fields§
§header: [u8; 4]4-byte RDW header (length + reserved).
payload: Vec<u8>Record payload bytes.
Implementations§
Source§impl RDWRecord
impl RDWRecord
Sourcepub fn try_new(payload: Vec<u8>) -> Result<RDWRecord, Error>
pub fn try_new(payload: Vec<u8>) -> Result<RDWRecord, Error>
Create a new RDW record from payload (fallible constructor).
Constructs an RDWRecord with a computed header (payload length + zero reserved bytes).
§Examples
use copybook_rdw::RDWRecord;
let record = RDWRecord::try_new(vec![0xC8; 80]).unwrap();
assert_eq!(record.length(), 80);
assert_eq!(record.payload.len(), 80);§Errors
Returns an error when payload length exceeds u16::MAX.
Sourcepub fn try_with_reserved(
payload: Vec<u8>,
reserved: u16,
) -> Result<RDWRecord, Error>
pub fn try_with_reserved( payload: Vec<u8>, reserved: u16, ) -> Result<RDWRecord, Error>
Create an RDW record preserving reserved bytes (fallible constructor).
§Errors
Returns an error when payload length exceeds u16::MAX.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RDWRecord
impl RefUnwindSafe for RDWRecord
impl Send for RDWRecord
impl Sync for RDWRecord
impl Unpin for RDWRecord
impl UnsafeUnpin for RDWRecord
impl UnwindSafe for RDWRecord
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