pub struct Header {
pub list: bool,
pub payload_length: usize,
}
Expand description
The header of an RLP item.
Fields§
§list: bool
True if list, false otherwise.
payload_length: usize
Length of the payload in bytes.
Implementations§
source§impl Header
impl Header
sourcepub fn decode(buf: &mut &[u8]) -> Result<Self>
pub fn decode(buf: &mut &[u8]) -> Result<Self>
Decodes an RLP header from the given buffer.
§Errors
Returns an error if the buffer is too short or the header is invalid.
sourcepub fn decode_bytes<'a>(buf: &mut &'a [u8], is_list: bool) -> Result<&'a [u8]>
pub fn decode_bytes<'a>(buf: &mut &'a [u8], is_list: bool) -> Result<&'a [u8]>
Decodes the next payload from the given buffer, advancing it.
§Errors
Returns an error if the buffer is too short or the header is invalid.
sourcepub fn decode_str<'a>(buf: &mut &'a [u8]) -> Result<&'a str>
pub fn decode_str<'a>(buf: &mut &'a [u8]) -> Result<&'a str>
Decodes a string slice from the given buffer, advancing it.
§Errors
Returns an error if the buffer is too short or the header is invalid.
sourcepub fn decode_raw<'a>(buf: &mut &'a [u8]) -> Result<PayloadView<'a>>
pub fn decode_raw<'a>(buf: &mut &'a [u8]) -> Result<PayloadView<'a>>
Extracts the next payload from the given buffer, advancing it.
§Errors
Returns an error if the buffer is too short, the header is invalid or one of the headers one level deeper is invalid.
sourcepub const fn length_with_payload(&self) -> usize
pub const fn length_with_payload(&self) -> usize
Returns the total length of the encoded header and payload.
Trait Implementations§
impl Eq for Header
impl StructuralPartialEq for Header
Auto Trait Implementations§
impl Freeze for Header
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnwindSafe for Header
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)