#[non_exhaustive]pub enum Filter {
Uncgi,
Iso8859_1,
Utf8,
Safe {
replacement: u8,
unsafe_chars: Vec<u8>,
},
Wipeup {
separator: u8,
remove_trailing: bool,
},
MaxLength {
limit: usize,
},
SafePlatform,
}Expand description
One transformation step in the Sequence pipeline.
#[non_exhaustive] is required (FR-039) so SemVer-minor releases can add
new variants such as a future --transliterate=deunicode opt-in.
§Construction shortcut
For Filter::Safe with the default unsafe-character set, prefer
Filter::safe_default() over enumerating the byte set manually.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Uncgi
Decode CGI percent-escapes (%XX → single byte). FR-001.
Iso8859_1
Translate Latin-1 high bytes (0x80–0xFF) to ASCII via the vendored
Table.iso8859_1. FR-002.
Utf8
Translate UTF-8 codepoints to ASCII via the vendored Table.utf_8.
Unmapped codepoints pass through. FR-003.
Safe
Replace each unsafe-set byte with replacement. FR-004.
Fields
unsafe_chars: Vec<u8>Bytes considered unsafe. See DEFAULT_UNSAFE_CHARS for the
v0.1.0 default; callers MAY pass any byte set.
Wipeup
Collapse runs of separator into one occurrence; when
remove_trailing is true, also trim leading/trailing runs. FR-005.
Fields
separator: u8Separator byte (default DEFAULT_SEPARATOR).
MaxLength
Truncate to limit bytes while preserving the final extension token
(everything after the last .). FR-006.
SafePlatform
Rewrite Windows-reserved device names (CON, PRN, AUX, NUL, COM1–9,
LPT1–9) by suffixing the basename with _, and rewrite Windows-
reserved characters (< > : " | ? *) and ASCII control bytes using
the same replacement as Filter::Safe. FR-007.
Auto-enabled on Windows builds; opt-in elsewhere via a sequence entry.
Implementations§
Source§impl Filter
impl Filter
Sourcepub fn safe_default() -> Self
pub fn safe_default() -> Self
Construct a Filter::Safe with the v0.1.0 default unsafe-character
set and b'_' replacement (FR-004 + clarification Q10). Convenience
constructor for callers who want the upstream-compatible default
without enumerating the byte set.
§Examples
use rusty_detox::Filter;
let safe = Filter::safe_default();
assert!(matches!(safe, Filter::Safe { replacement: b'_', .. }));Sourcepub fn wipeup_default() -> Self
pub fn wipeup_default() -> Self
Construct a Filter::Wipeup with b'_' separator and trailing
trimming enabled (matches upstream’s default sequence).