core::encoding::base64
API 参考只有英文版,由标准库源代码中的英文文档注释生成。
base64 (RFC 4648 sections 4 and 5). A
Codec picks the alphabet and the padding policy; STANDARD is the
default argument everywhere. Whitespace is not skipped.
Structs
CodecSource
pub struct CodecAn alphabet and a padding policy.
A codec over
alphabet, withpadding.The alphabet.
The padding rule.
Enums
AlphabetSource
pub enum AlphabetThe 64 characters a codec writes.
A-Z a-z 0-9 + /(RFC 4648 section 4).A-Z a-z 0-9 - _, for URLs and file names (RFC 4648 section 5).
PaddingSource
pub enum PaddingThe = padding policy: what encode writes and what decode takes.
Encode pads; decode requires padding.
Encode does not pad; decode rejects padding.
Encode pads; decode takes padded and unpadded text.
Encode does not pad; decode takes padded and unpadded text.
Functions
encoded_lenSource
pub const fn encoded_len(n: usize, codec: Codec = STANDARD) -> usize The length of the text encode makes of n bytes.
decoded_len_maxSource
pub const fn decoded_len_max(n: usize) -> usize The most bytes decode makes of n characters: enough room for
decode_into.
encodeSource
pub fn encode<B: AsBytes>(data: B, codec: Codec = STANDARD) -> str data in base64.
encode_intoSource
pub fn encode_into<B: AsBytes>(data: B, out: SliceMut<u8>, codec: Codec = STANDARD) -> usize data in base64, written to the front of out; returns how many
bytes it wrote. Panics if out is shorter than encoded_len.
decodeSource
pub fn decode<B: AsBytes>(text: B, codec: Codec = STANDARD) throws (DecodeError) -> List<u8> The bytes text spells in base64.
decode_intoSource
pub fn decode_into<B: AsBytes>(text: B, out: SliceMut<u8>, codec: Codec = STANDARD) throws (DecodeError) -> usize The bytes text spells in base64, written to the front of out;
returns how many it wrote. Panics if out is shorter than
decoded_len_max(text.len()) less what the padding saves.
Constants
STANDARDSource
pub const STANDARD: Codec = Codec { alphabet: Alphabet::Standard, padding: Padding::PresentOptional }The standard alphabet; encode pads, decode takes either.
STANDARD_NO_PADSource
pub const STANDARD_NO_PAD: Codec = Codec { alphabet: Alphabet::Standard, padding: Padding::Absent }The standard alphabet without padding.
URL_SAFESource
pub const URL_SAFE: Codec = Codec { alphabet: Alphabet::UrlSafe, padding: Padding::PresentOptional }The URL-safe alphabet; encode pads, decode takes either.
URL_SAFE_NO_PADSource
pub const URL_SAFE_NO_PAD: Codec = Codec { alphabet: Alphabet::UrlSafe, padding: Padding::Absent }The URL-safe alphabet without padding.