pub struct LineWrap {
pub line_len: usize,
pub line_ending: LineEnding,
}Expand description
Base64 line wrapping policy.
line_len is measured in encoded Base64 bytes, not source input bytes.
Encoders insert line endings between lines and do not append a trailing line
ending after the final line.
Fields§
§line_len: usizeMaximum encoded bytes per line.
line_ending: LineEndingLine ending inserted between wrapped lines.
Implementations§
Source§impl LineWrap
impl LineWrap
Sourcepub const fn new(line_len: usize, line_ending: LineEnding) -> Self
pub const fn new(line_len: usize, line_ending: LineEnding) -> Self
Creates a wrapping policy.
This constructor is intended for fixed, trusted values such as
compile-time MIME or PEM profile constants. Use Self::checked_new
when the line length comes from configuration, network input, file
metadata, or another untrusted runtime source.
§Panics
Panics when line_len is zero. Base64 wrapping requires a non-zero
encoded line length; accepting zero would make progress impossible for
wrapped encoders. This constructor is callable at runtime, so do not
pass attacker-controlled or externally configured values here; use
Self::checked_new for those cases.
Sourcepub const fn checked_new(
line_len: usize,
line_ending: LineEnding,
) -> Option<Self>
pub const fn checked_new( line_len: usize, line_ending: LineEnding, ) -> Option<Self>
Creates a wrapping policy, returning None when the line length is
invalid.
Base64 line-wrapping requires a non-zero encoded line length. This helper is useful when accepting a wrapping policy from configuration or another untrusted source.
Sourcepub const fn line_ending(self) -> LineEnding
pub const fn line_ending(self) -> LineEnding
Returns the line ending inserted between wrapped lines.