[−][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]
type Err = ParseError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl Hash for Rule
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
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,
fn borrow_mut(&mut self) -> &mut T
[src]
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,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,