pub trait Alarm : MutableCallback1<()>
{
#[inline(always)]
fn set(&mut self, toGoOffInHowManyMicroseconds: u64) -> bool
{
let result = unsafe { ::dpdk_sys::rte_eal_alarm_set(toGoOffInHowManyMicroseconds, Self::asFunctionPointer(), self.asFunctionArgument()) };
if likely(result == 0)
{
true
}
else
{
match result
{
valid if valid.is_negative() => false,
_ => panic!("Non-negative return code '{}' from rte_eal_alarm_set()", result),
}
}
}
#[inline(always)]
fn cancel(&mut self) -> (usize, bool)
{
let functionArgument = self.asFunctionArgument();
Self::cancelInternal(functionArgument)
}
#[inline(always)]
fn cancelAll() -> (usize, bool)
{
const functionArgument: *mut c_void = (-1 as isize) as *mut c_void;
Self::cancelInternal(functionArgument)
}
#[inline(always)]
fn cancelInternal(functionArgument: *mut c_void) -> (usize, bool)
{
unsafe { rust_rte_reset_errno() };
match unsafe { ::dpdk_sys::rte_eal_alarm_cancel(Self::asFunctionPointer(), functionArgument) }
{
result if result > 0 =>
{
match unsafe { rust_rte_errno() }
{
0 => (result as usize, false),
E::EINPROGRESS => (result as usize, true),
unexpected @ _ => panic!("Invalid error code '{}' from rte_eal_alarm_cancel() when result was greater than zero '{}'", unexpected, result),
}
},
0 =>
{
match unsafe { rust_rte_errno() }
{
0 => (0, false),
E::EINPROGRESS => (0, true),
E::ENOENT => (0, false),
unexpected @ _ => panic!("Invalid error code '{}' from rte_eal_alarm_cancel() when result was zero", unexpected),
}
}
-1 =>
{
match unsafe { rust_rte_errno() }
{
E::EINVAL => panic!("Invalid parameter - NULL callback"),
unexpected @ _ => panic!("Invalid error code '{}' from rte_eal_alarm_cancel() when return code was -1", unexpected),
}
},
unexpected @ _ => panic!("Invalid return code '{}' from rte_eal_alarm_cancel()", unexpected),
}
}
}