pub struct EncodedReprInfo {
pub frames: usize,
pub remainder: usize,
pub needed_capacity: usize,
}
Expand description
Various details about a slice and it’s encoded output bytes, including number of full frames, remainder, and how much capacity is needed to hold all the encoded bytes
§Safety
All fields on this struct are marked pub
, meaning anyone is allowed to
directly access and modify them. Don’t accept any instances of this struct
from nontrusted sources, nor construct instances from raw data taken from
nontrusted sources.
On the contrary, you can trust and rely on the output directly from the
for_input_len
associated function,
including in unsafe contexts. The body of this function is heavily
documented.
Fields§
§frames: usize
The amount of full frames (eg. amount of full chunks of 4 bytes)
remainder: usize
The amount of remainder bytes, strictly less than 4 (frame size)
needed_capacity: usize
The amount of capacity required to fit all the encoded data into
This is calculated by summing up the following values:
- Space needed for full frames is
frames * 5
, since every frame is a chunk of 4 bytes that gets encoded into a frame of 5 bytes - Space needed for remainder bytes:
- If no remainder, then 0. Simple enough :p
- This also implies that if the input does not need to be padded to a len that is a multiple of 4, no padding is needed. In this case, the numbers/calculations here are compliant with the Z85 spec.
- If there is remainder, it is
5 + 1
. The remainder bytes will be padded to a full frame of 4, then encoded as a full frame, yielding 5. Then, one extra byte is added onto the end to encode the amount of padding we have added (ex. 1 for 3 remainder bytes and 1 padding).
- If no remainder, then 0. Simple enough :p
Implementations§
Source§impl EncodedReprInfo
impl EncodedReprInfo
Sourcepub fn for_input_len(input_len: usize) -> Self
pub fn for_input_len(input_len: usize) -> Self
Calculates the values
See documentation on EncodedReprInfo
and on the individual fields
for more information.