Skip to main content

read_bytes_header_solidity

Function read_bytes_header_solidity 

Source
pub fn read_bytes_header_solidity<B: ByteOrder, const ALIGN: usize>(
    buf: &impl Buf,
    offset: usize,
) -> Result<(usize, usize), CodecError>
Expand description

Reads the header of a Solidiof the data

Given the original data:

let original: Vec<Vec<u32>> = vec![vec![1, 2, 3], vec![4, 5]];

The Solidity encoding would look like this:

000 000 : 00 00 00 20 || 032 | 032 000 : 00 00 00 02 || 002 |

064 000 : 00 00 00 40 || 064 | <–– buf should start here 096 032 : 00 00 00 c0 || 192 | 128 064 : 00 00 00 03 || 003 | 160 096 : 00 00 00 01 || 001 | 192 128 : 00 00 00 02 || 002 | 224 160 : 00 00 00 03 || 003 | 256 192 : 00 00 00 02 || 002 | 288 224 : 00 00 00 04 || 004 | 320 256 : 00 00 00 05 || 005 |

§Parameters

  • buf: The buffer containing the encoded data.
  • offset: The offset from which to start reading.

§Returns

A tuple containing the data offset and the data length.

§Errors

Returns a CodecError if reading from the buffer fails.