pub struct EditorConfigHandle { /* private fields */ }
Expand description
EditorConfig handle
Implementations§
Source§impl EditorConfigHandle
impl EditorConfigHandle
Sourcepub fn get_version(&self) -> Version<c_int>
pub fn get_version(&self) -> Version<c_int>
TODO: Add comment
§Example
let handle = editorconfig_rs::EditorConfigHandle::new().unwrap();
let version = handle.get_version();
Sourcepub fn set_version<T: Into<c_int>>(&self, version: Version<T>)
pub fn set_version<T: Into<c_int>>(&self, version: Version<T>)
TODO: Add comment
§Example
use editorconfig_rs::Version;
let handle = editorconfig_rs::EditorConfigHandle::new().unwrap();
handle.set_version(Version::new(0, 12, 5));
Sourcepub fn get_config_filename(&self) -> Option<String>
pub fn get_config_filename(&self) -> Option<String>
Returns the configuration filename iff it was previously set by calling
EditorConfigHandle::set_config_filename
; otherwise None
Note: None
just means the default filename ".editorconfig"
is used
Sourcepub fn set_config_filename(&mut self, filename: &str)
pub fn set_config_filename(&mut self, filename: &str)
Sets a custom EditorConfig configuration filename
Allows you to change the default configuration filename “.editorconfig”.
§Example
let mut handle = editorconfig_rs::EditorConfigHandle::new().unwrap();
handle.set_config_filename(".myeditorconfig")
Sourcepub fn parse<P: AsRef<Path>>(&self, absolute_path: P) -> Option<ParseError>
pub fn parse<P: AsRef<Path>>(&self, absolute_path: P) -> Option<ParseError>
Searches an absolute path for the corresponding EditorConfig rules
After parsing, you can get the rules by calling
EditorConfigHandle::get_rules
.
§Example
let handle = editorconfig_rs::EditorConfigHandle::new().unwrap();
let test_file_path = std::fs::canonicalize("tests/🦀🚀").unwrap();
let err = handle.parse(test_file_path);
Sourcepub fn get_error_file(&self) -> Option<PathBuf>
pub fn get_error_file(&self) -> Option<PathBuf>
Sourcepub fn get_rule_count(&self) -> c_int
pub fn get_rule_count(&self) -> c_int
Returns the number of rules found after parsing
§Example
let handle = editorconfig_rs::EditorConfigHandle::new().unwrap();
// Parse a file or directory; otherwise `get_rule_count()` returns 0
let rule_count = handle.get_rule_count();
Sourcepub fn get_rules(&self) -> HashMap<String, String>
pub fn get_rules(&self) -> HashMap<String, String>
Returns a map of all rules found after parsing
§Example
let handle = editorconfig_rs::EditorConfigHandle::new().unwrap();
let test_file_path = std::fs::canonicalize("tests/🦀🚀").unwrap();
let err = handle.parse(test_file_path);
let rules = handle.get_rules();
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EditorConfigHandle
impl RefUnwindSafe for EditorConfigHandle
impl !Send for EditorConfigHandle
impl !Sync for EditorConfigHandle
impl Unpin for EditorConfigHandle
impl UnwindSafe for EditorConfigHandle
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