[][src]Struct rctl::Rule

pub struct Rule {
    pub subject: Subject,
    pub resource: Resource,
    pub limit: Limit,
    pub action: Action,
}

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: Subjectresource: Resourcelimit: Limitaction: 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]

type Err = ParseError

The associated error which can be returned from parsing.

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.