[][src]Struct rctl::Filter

pub struct Filter { /* fields omitted */ }

A filter can match a set of Rules.

Methods

impl Filter
[src]

Return the filter that matches all rules

Example

let filter = Filter::new();
assert_eq!(filter.to_string(), ":".to_string());

Constrain the filter to a specific [SubjectType]

If the filter is already constrained to a subject, this is a No-Op.

Example

let filter = Filter::new()
    .subject_type(&SubjectType::LoginClass);
assert_eq!(filter.to_string(), "loginclass:".to_string());

Constrain the filter to a specific [Subject]

Resets the subject type.

Example

let filter = Filter::new()
    .subject(&Subject::user_name("nobody").expect("no user 'nobody'"));
assert_eq!(filter.to_string(), "user:nobody".to_string());

Constrain the filter to a specific [Resource]

Example

let filter = Filter::new()
    .resource(&Resource::MemoryLocked);
assert_eq!(filter.to_string(), "::memorylocked".to_string());

Constrain the filter to a specific [Action]

Example

let filter = Filter::new()
    .action(&Action::Deny);
assert_eq!(filter.to_string(), ":::deny".to_string());

Constrain the filter to the Deny [Action]

Example

let filter = Filter::new()
    .deny();
assert_eq!(filter, Filter::new().action(&Action::Deny));

Constrain the filter to the Log [Action]

Example

let filter = Filter::new()
    .log();
assert_eq!(filter, Filter::new().action(&Action::Log));

Constrain the filter to the DevCtl [Action]

Example

let filter = Filter::new()
    .devctl();
assert_eq!(filter, Filter::new().action(&Action::DevCtl));

Constrain the filter to the Signal [Action]

Example

let filter = Filter::new()
    .signal(Signal::SIGTERM);
assert_eq!(filter.to_string(), ":::sigterm".to_string());

Constrain the filter to a particular [Limit]

Resets any limit_per, if the given limit has a per set.

Examples

let filter = Filter::new()
    .limit(&Limit::amount(100*1024*1024));
assert_eq!(filter.to_string(), ":::=100m".to_string());
let filter = Filter::new()
    .limit(&Limit::amount_per(100*1024*1024, SubjectType::Process));
assert_eq!(filter.to_string(), ":::=100m/process".to_string());

Return the string representation of the [Filter].

Return an [IntoIterator] over all Rules matching this [Filter].

Example

List all rules:

use rctl;

let filter = rctl::Filter::new();
for rule in filter.rules() {
    println!("{:?}", rule);
}

Remove all matching Rules from the resource limits database.

Examples

use rctl::{Filter, Subject};
let filter = Filter::new()
    .subject(&Subject::jail_name("testjail_rctl_filter_remove"))
    .remove_rules()
    .expect("Could not remove rules");

Remove all rules, clearing the resource limits database by using the default (':') [Filter]:

use rctl;

rctl::Filter::new().remove_rules().expect("Could not remove all rules");

Trait Implementations

impl<'a> Into<String> for &'a Filter
[src]

Performs the conversion.

impl PartialEq<Filter> for Filter
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl From<Rule> for Filter
[src]

Performs the conversion.

impl<'a> From<&'a Rule> for Filter
[src]

Performs the conversion.

impl<'a> From<&'a Subject> for Filter
[src]

Performs the conversion.

impl From<Subject> for Filter
[src]

Performs the conversion.

impl<'a> From<&'a SubjectType> for Filter
[src]

Performs the conversion.

impl From<SubjectType> for Filter
[src]

Performs the conversion.

impl<'a> From<&'a Action> for Filter
[src]

Performs the conversion.

impl From<Action> for Filter
[src]

Performs the conversion.

impl<'a> From<&'a Limit> for Filter
[src]

Performs the conversion.

impl From<Limit> for Filter
[src]

Performs the conversion.

impl Clone for Filter
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Display for Filter
[src]

Formats the value using the given formatter. Read more

impl Debug for Filter
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Filter

impl Sync for Filter

Blanket Implementations

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

Performs the conversion.

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

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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

Converts the given value to a String. Read more

impl<T> From for T
[src]

Performs the conversion.

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

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

Immutably borrows from an owned value. Read more

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

Mutably borrows from an owned value. Read more

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more