Struct EditorConfigHandle

Source
pub struct EditorConfigHandle { /* private fields */ }
Expand description

EditorConfig handle

Implementations§

Source§

impl EditorConfigHandle

Source

pub fn new() -> Result<Self, &'static str>

Creates a new EditorConfigHandle

§Example
let handle = editorconfig_rs::EditorConfigHandle::new();
Source

pub fn get_version(&self) -> Version<c_int>

TODO: Add comment

§Example
let handle = editorconfig_rs::EditorConfigHandle::new().unwrap();
let version = handle.get_version();
Source

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));
Source

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

Source

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")
Source

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);
Source

pub fn get_error_file(&self) -> Option<PathBuf>

Returns the path of the invalid configuration file when parse returned an error

§Returns

The path of the invalid configuration file or None if there was no error

Source

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();
Source

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§

Source§

impl Drop for EditorConfigHandle

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.