-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
547 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use crate::UserCondition; | ||
use std::fmt::{Display, Formatter}; | ||
|
||
enum ConditionResult { | ||
Ok(bool), | ||
NoUser, | ||
AttrMissing(UserCondition), | ||
AttrInvalid(String, UserCondition), | ||
CompValInvalid(Option<String>), | ||
Fatal(String), | ||
} | ||
|
||
impl Display for ConditionResult { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
ConditionResult::Ok(_) => f.write_str(""), | ||
ConditionResult::NoUser => f.write_str("cannot evaluate, User Object is missing"), | ||
ConditionResult::AttrMissing(cond) => write!( | ||
f, | ||
"cannot evaluate, the User.{} attribute is missing", | ||
cond.fmt_comp_attr() | ||
), | ||
ConditionResult::AttrInvalid(reason, cond) => write!( | ||
f, | ||
"cannot evaluate, the User.{} attribute is invalid ({})", | ||
cond.fmt_comp_attr(), | ||
reason | ||
), | ||
ConditionResult::CompValInvalid(err) => write!( | ||
f, | ||
"cannot evaluate, ({})", | ||
err.as_ref() | ||
.unwrap_or(&"comparison value is missing or invalid".to_owned()) | ||
), | ||
ConditionResult::Fatal(err) => write!(f, "cannot evaluate ({})", err), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod evaluator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.