pub fn add_rule(
        &mut self,
        action: ScmpAction,
        syscall: i32,
        comparators: Option<&[ScmpArgCompare]>,
    ) -> Result<()> {
        let ret: i32;

        match comparators {
            Some(cmps) => {
                let arg_cmp: Vec<scmp_arg_cmp> = cmps.iter().map(From::from).collect();
                let arg_cmp_len: u32 =
                    arg_cmp
                        .len()
                        .try_into()
                        .map_err(|e: std::num::TryFromIntError| {
                            SeccompError::new(Common(e.to_string()))
                        })?;

                ret = unsafe {
                    seccomp_rule_add_array(
                        self.ctx.as_ptr(),
                        action.to_native(),
                        syscall,
                        arg_cmp_len,
                        arg_cmp.as_ptr(),
                    )
                };
            }
            None => {
                ret =
                    unsafe { seccomp_rule_add(self.ctx.as_ptr(), action.to_native(), syscall, 0) };
            }
        };

        if ret < 0 {
            return Err(SeccompError::new(Errno(ret)));
        }

        Ok(())
    }
/// add_rule adds a single rule for an unconditional or conditional action on a syscall.
///
/// Accepts the number of the syscall the action and the conditions to be taken on the call being made.
/// If the compartors is None, the function adds a single rule for an unconditional action.
/// Returns an error if an issue was encountered adding the rule.
add_rule adds a single rule for an unconditional or conditional action on a syscall.
Accepts the number of the syscall the action and the conditions to be taken on the call being made.
If the compartors is None, the function adds a single rule for an unconditional action.
Returns an error if an issue was encountered adding the rule.
add_rule adds a single rule for an unconditional or conditional action on a syscall . Accepts the number of the syscall the action and the conditions to be taken on the call being made . If the compartors is None the function adds a single rule for an unconditional action . Returns an error if an issue was encountered adding the rule .
pub fn add_rule(
        &mut self,
        action: ScmpAction,
        syscall: i32,
        comparators: Option<&[ScmpArgCompare]>,
    ) -> Result<()> {
        let ret: i32;
        match comparators {
            Some(cmps) => {
                let arg_cmp: Vec<scmp_arg_cmp> = cmps.iter().map(From::from).collect();
                let arg_cmp_len: u32 =
                    arg_cmp
                        .len()
                        .try_into()
                        .map_err(|e: std::num::TryFromIntError| {
                            SeccompError::new(Common(e.to_string()))
                        })?;
                ret = unsafe {
                    seccomp_rule_add_array(
                        self.ctx.as_ptr(),
                        action.to_native(),
                        syscall,
                        arg_cmp_len,
                        arg_cmp.as_ptr(),
                    )
                };
            }
            None => {
                ret =
                    unsafe { seccomp_rule_add(self.ctx.as_ptr(), action.to_native(), syscall, 0) };
            }
        };
        if ret < 0 {
            return Err(SeccompError::new(Errno(ret)));
        }
        Ok(())
    }
pub fn add_rule ( & mut self , action : ScmpAction , syscall : i32 , comparators : Option < & [ ScmpArgCompare ] > , ) -> Result < ( ) > { let ret : i32 ; match comparators { Some ( cmps ) => { let arg_cmp : Vec < scmp_arg_cmp > = cmps . iter ( ) . map ( From :: from ) . collect ( ) ; let arg_cmp_len : u32 = arg_cmp . len ( ) . try_into ( ) . map_err ( | e : std :: num :: TryFromIntError | { SeccompError :: new ( Common ( e . to_string ( ) ) ) } ) ? ; ret = unsafe { seccomp_rule_add_array ( self . ctx . as_ptr ( ) , action . to_native ( ) , syscall , arg_cmp_len , arg_cmp . as_ptr ( ) , ) } ; } None => { ret = unsafe { seccomp_rule_add ( self . ctx . as_ptr ( ) , action . to_native ( ) , syscall , 0 ) } ; } } ; if ret < 0 { return Err ( SeccompError :: new ( Errno ( ret ) ) ) ; } Ok ( ( ) ) }
add_rule adds a single rule for an unconditional or conditional action on a syscall.
add_rule adds a single rule for an unconditional or conditional action on a syscall .
&mut self
action
ScmpAction
syscall
i32
comparators
Option<&[ScmpArgCompare]>