chore: start decoding docs and fix wording for encode docs

This commit is contained in:
Kasey White
2022-06-29 16:28:50 -04:00
committed by Kasey White
parent 3aaec0936d
commit ac3ab5b47a
3 changed files with 81 additions and 22 deletions

View File

@@ -158,10 +158,16 @@ where
impl Encode for &Constant {
fn encode(&self, e: &mut Encoder) -> Result<(), en::Error> {
match self {
// Integers are typically smaller so we save space
// by encoding them in 7 bits and this allows it to be byte alignment agnostic.
Constant::Integer(i) => {
encode_constant(0, e)?;
i.encode(e)?;
}
// Strings and bytestrings span multiple bytes so using bytestring is
// the most effective encoding.
// i.e. A 17 or greater length byte array loses efficiency being encoded as
// a unsigned integer instead of a byte array
Constant::ByteString(bytes) => {
encode_constant(1, e)?;
bytes.encode(e)?;