[−][src]Struct rctl::Rule
A rule represents an [Action] to be taken when a particular [Subject] hits a [Limit] for a [Resource].
Syntax for the string representation of a rule is
subject:subject-id:resource:action=amount/per
.
Examples
use rctl::{Subject, SubjectType, Resource, Action, Limit, Rule}; let rule = Rule { subject: Subject::user_name("nobody").expect("no user 'nobody'"), resource: Resource::VMemoryUse, action: Action::Deny, limit: Limit::amount(1024*1024*1024), }; assert_eq!(rule.to_string(), "user:nobody:vmemoryuse:deny=1g".to_string());
Fields
subject: Subject
resource: Resource
limit: Limit
action: Action
Implementations
impl Rule
[src][−]
pub fn to_string(&self) -> String
[src]
pub fn apply(&self) -> Result<(), Error>
[src][−]
Add this rule to the resource limits database.
Example
use rctl::{Rule, Subject, Resource, Action, Limit}; let rule = Rule { subject: Subject::jail_name("testjail_rctl_rule_apply_method"), resource: Resource::VMemoryUse, action: Action::Log, limit: Limit::amount(100*1024*1024), }; rule.apply();
pub fn remove(&self) -> Result<(), Error>
[src][−]
Attempt to remove this rule from the resource limits database.
Example
use rctl::{Rule, Subject, Resource, Action, Limit}; let rule = Rule { subject: Subject::jail_name("testjail_rctl_rule_remove_method"), resource: Resource::VMemoryUse, action: Action::Log, limit: Limit::amount(100*1024*1024), }; rule.remove();
Trait Implementations
impl Clone for Rule
[src][+]
impl Debug for Rule
[src][+]
impl Display for Rule
[src][+]
impl Eq for Rule
[src]
impl<'a> From<&'a Rule> for Filter
[src][+]
impl From<Rule> for Filter
[src][+]
impl FromStr for Rule
[src][+]
impl Hash for Rule
[src][+]
impl<'a> Into<String> for &'a Rule
[src][+]
impl PartialEq<Rule> for Rule
[src][+]
impl StructuralEq for Rule
[src]
impl StructuralPartialEq for Rule
[src]
Auto Trait Implementations
impl RefUnwindSafe for Rule
impl Send for Rule
impl Sync for Rule
impl Unpin for Rule
impl UnwindSafe for Rule
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> From<T> for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src][+]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src][+]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,