pub struct Header {
pub list: bool,
pub payload_length: usize,
}rlp only.Expand description
The header of an RLP item.
Fields§
§list: boolTrue if list, false otherwise.
payload_length: usizeLength of the payload in bytes.
Implementations§
Source§impl Header
impl Header
Sourcepub fn decode(buf: &mut &[u8]) -> Result<Header, Error>
pub fn decode(buf: &mut &[u8]) -> Result<Header, Error>
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], Error>
pub fn decode_bytes<'a>( buf: &mut &'a [u8], is_list: bool, ) -> Result<&'a [u8], Error>
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, Error>
pub fn decode_str<'a>(buf: &mut &'a [u8]) -> Result<&'a str, Error>
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>, Error>
pub fn decode_raw<'a>(buf: &mut &'a [u8]) -> Result<PayloadView<'a>, Error>
Extracts the next payload from the given buffer, advancing it.
The returned PayloadView provides a structured view of the payload, allowing for efficient
parsing of nested items without unnecessary allocations.
§Errors
Returns an error if:
- The buffer is too short
- The header is invalid
- Any nested headers (for list items) are 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes