pub struct Weirpack {
pub rules: HashMap<String, String>,
pub dictionary: Option<String>,
pub annotations: Option<String>,
pub manifest: WeirpackManifest,
}Expand description
A Weirpack, which carries within itself one or more rules to be used for grammar checking. These rules are written in Weir.
Fields§
§rules: HashMap<String, String>§dictionary: Option<String>The dictionary.dict file, if it exists.
annotations: Option<String>The annotations.json file, if it exists.
manifest: WeirpackManifestImplementations§
Source§impl Weirpack
impl Weirpack
Sourcepub fn new(manifest: WeirpackManifest) -> Self
pub fn new(manifest: WeirpackManifest) -> Self
Create an empty Weirpack.
Sourcepub fn add_rule(
&mut self,
name: impl Into<String>,
rule: impl Into<String>,
) -> Option<String>
pub fn add_rule( &mut self, name: impl Into<String>, rule: impl Into<String>, ) -> Option<String>
Add a rule to this Weirpack. Does not compile to test the rule.
Sourcepub fn remove_rule(&mut self, name: &str) -> Option<String>
pub fn remove_rule(&mut self, name: &str) -> Option<String>
Remove a rule from this Weirpack.
Sourcepub fn run_tests(&self) -> Result<HashMap<String, Vec<TestResult>>, Error>
pub fn run_tests(&self) -> Result<HashMap<String, Vec<TestResult>>, Error>
Run all the tests within all the Weir rules in this Weirpack.
Sourcepub fn to_lint_group(&self) -> Result<LintGroup, Error>
pub fn to_lint_group(&self) -> Result<LintGroup, Error>
Parse and optimize the Weir rules in the pack, converting the set into a single LintGroup.
Does not run tests.
Sourcepub fn from_reader(reader: impl Read) -> Result<Self, Error>
pub fn from_reader(reader: impl Read) -> Result<Self, Error>
Load a Weirpack from bytes.
Sourcepub fn load_dictionary(&self) -> Result<Option<MutableDictionary>, Error>
pub fn load_dictionary(&self) -> Result<Option<MutableDictionary>, Error>
Loads the dictionary that may or may not be contained within the Weirpack.
The dictionary is in the Rune format and thus is composed of two files, annotations.json
and dictionary.dict.
Returns None if the relevant files are not present in the Weirpack.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
Load a Weirpack from bytes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Weirpack
impl RefUnwindSafe for Weirpack
impl Send for Weirpack
impl Sync for Weirpack
impl Unpin for Weirpack
impl UnsafeUnpin for Weirpack
impl UnwindSafe for Weirpack
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more