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 new(payload: Vec<u8>) -> RDWRecord
👎Deprecated since 0.4.3: use try_new() instead for fallible construction
pub fn new(payload: Vec<u8>) -> RDWRecord
use try_new() instead for fallible construction
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.
Sourcepub fn with_reserved(payload: Vec<u8>, reserved: u16) -> RDWRecord
👎Deprecated since 0.4.3: use try_with_reserved() instead for fallible construction
pub fn with_reserved(payload: Vec<u8>, reserved: u16) -> RDWRecord
use try_with_reserved() instead for fallible construction
Create an RDW record preserving reserved bytes.
§Panics
Panics when payload length exceeds u16::MAX.
Sourcepub fn try_recompute_length(&mut self) -> Result<(), Error>
pub fn try_recompute_length(&mut self) -> Result<(), Error>
Recompute the header length field from payload length.
§Errors
Returns an error when payload length exceeds u16::MAX.
Sourcepub fn recompute_length(&mut self)
👎Deprecated since 0.4.3: use try_recompute_length() instead for fallible operation
pub fn recompute_length(&mut self)
use try_recompute_length() instead for fallible operation
Recompute the header length field from payload length.
§Panics
Panics when payload length exceeds u16::MAX.