Skip to main content

Module base64

Module base64 

Source
Expand description

The base64 encoding of RFC 4648, which the protocol carries every radio payload in.

The packet forwarder protocol asks for padded base64 on the way up and allows it to be omitted on the way down, and gateways in the field send both. encode pads, as the protocol’s own examples do for uplinks, and decode accepts a string with or without padding, so a datagram from either side is read the same way.

§Examples

use pamoja_gateway::base64;

assert_eq!(base64::encode(b"foobar"), "Zm9vYmFy");
assert_eq!(base64::encode(b"fo"), "Zm8=");
assert_eq!(base64::decode("Zm8=").as_deref(), Ok(&b"fo"[..]));
assert_eq!(base64::decode("Zm8").as_deref(), Ok(&b"fo"[..]));

Enums§

DecodeError
Why a string is not base64.

Functions§

decode
Decodes base64, with or without its padding.
encode
Encodes bytes as padded base64.