Skip to main content

select_sinkhole_roles

Function select_sinkhole_roles 

Source
pub fn select_sinkhole_roles(
    list: &SinkholeList,
    selector: &SinkholeRoleSelector,
) -> Result<Vec<SinkholeRole>>
Expand description

Picks rules of list without changing anything. Each rule is returned once, even if its pattern is given more than once.

A pattern matches a regex rule only if it is exactly the same text, and a name rule if it is the same name (case and a trailing dot do not matter).

§Errors

  • Error::InvalidInput if list was read without its rules, or a pattern matches more than one rule (e.g. the same text as Exact and as Regex); the message lists their uuids.
  • Error::NotFound if a pattern or the uuid matches no rule. Nothing is returned then, so a typo cannot lead to removing only part of the selection.

§Examples

use dinio_sdk::ops::{self, SinkholeRoleSelector};

let list = client.sinkhole_lists().get(list_id, true).await?;
let selector = SinkholeRoleSelector::Patterns(vec!["Ads.Example.com.".into()]);
for role in ops::select_sinkhole_roles(&list, &selector)? {
    client.sinkhole_roles().delete(role.uuid).await?;
}