pub struct FileTypeProfile {
pub processor: String,
pub extensions: Vec<String>,
pub fields: Vec<FieldRule>,
pub options: HashMap<String, String>,
}Expand description
Specifies which processor to use and what fields to sanitize.
§Example (serialized as JSON)
{
"processor": "key_value",
"extensions": [".rb", ".conf"],
"fields": [
{ "pattern": "*.password", "category": "custom:password" },
{ "pattern": "*.secret", "category": "custom:secret" },
{ "pattern": "smtp_address", "category": "hostname" }
],
"options": {
"delimiter": "=",
"comment_prefix": "#"
}
}Fields§
§processor: StringName of the processor to use (e.g. "key_value", "json").
extensions: Vec<String>File extensions this profile applies to (e.g. [".rb", ".conf"]).
fields: Vec<FieldRule>Field rules: which keys/paths to sanitize.
options: HashMap<String, String>Free-form options passed to the processor (e.g. delimiter, comment chars).
Implementations§
Source§impl FileTypeProfile
impl FileTypeProfile
Sourcepub fn new(processor: impl Into<String>, fields: Vec<FieldRule>) -> Self
pub fn new(processor: impl Into<String>, fields: Vec<FieldRule>) -> Self
Create a minimal profile for a given processor.
Sourcepub fn with_extension(self, ext: impl Into<String>) -> Self
pub fn with_extension(self, ext: impl Into<String>) -> Self
Add an extension to this profile.
Sourcepub fn with_option(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_option( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add a free-form option.
Sourcepub fn matches_filename(&self, filename: &str) -> bool
pub fn matches_filename(&self, filename: &str) -> bool
Check whether a filename matches this profile’s extensions.
Returns false if the profile has no extensions.
§Examples
use sanitize_engine::processor::profile::FieldRule;
use sanitize_engine::processor::profile::FileTypeProfile;
let profile = FileTypeProfile::new("json", vec![])
.with_extension(".json")
.with_extension(".jsonc");
assert!(profile.matches_filename("config.json"));
assert!(profile.matches_filename("deep/path/app.jsonc"));
assert!(!profile.matches_filename("config.yml"));
assert!(!FileTypeProfile::new("json", vec![]).matches_filename("any.json"));Trait Implementations§
Source§impl Clone for FileTypeProfile
impl Clone for FileTypeProfile
Source§fn clone(&self) -> FileTypeProfile
fn clone(&self) -> FileTypeProfile
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FileTypeProfile
impl Debug for FileTypeProfile
Source§impl<'de> Deserialize<'de> for FileTypeProfile
impl<'de> Deserialize<'de> for FileTypeProfile
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for FileTypeProfile
impl RefUnwindSafe for FileTypeProfile
impl Send for FileTypeProfile
impl Sync for FileTypeProfile
impl Unpin for FileTypeProfile
impl UnsafeUnpin for FileTypeProfile
impl UnwindSafe for FileTypeProfile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more