Struct ByteFilter
pub struct ByteFilter {
pub mask: u8,
pub value: u8,
}
Expand description
A filter that matches a single byte.
A value b
matches the filter if (b & self.mask) == self.value
.
Fields§
§mask: u8
The mask applied to the byte value.
If a bit is 1, it indicates the bit must be matched to value. If it is 0, the bit can be ignored. In other words: the filter matches if (X & mask) == value
value: u8
The value to which the byte value is compared after masking.
Implementations§
§impl ByteFilter
impl ByteFilter
pub fn new(mask: u8, value: u8) -> Self
pub fn new(mask: u8, value: u8) -> Self
Creates a new ByteFilter
.
pub fn matches(&self, value: u8) -> bool
pub fn matches(&self, value: u8) -> bool
Returns true if value
matches the ByteFilter
.
pub fn max_matching_val(&self) -> u8
pub fn max_matching_val(&self) -> u8
Returns the largest value matched by the filter.
pub fn min_matching_val(&self) -> u8
pub fn min_matching_val(&self) -> u8
Returns the smallest value matched by the filter.
pub fn matches_anything(&self) -> bool
pub fn matches_anything(&self) -> bool
Returns true if all 256 possible values for an u8
match this filter.
pub fn covers(&self, other: &ByteFilter) -> bool
pub fn covers(&self, other: &ByteFilter) -> bool
Returns true if all instructions matched by other are also matched by self
pub fn can_intersect(&self, other: &ByteFilter) -> bool
pub fn can_intersect(&self, other: &ByteFilter) -> bool
Returns true if the filters overlap.
pub fn can_merge(&self, other: &ByteFilter) -> bool
pub fn can_merge(&self, other: &ByteFilter) -> bool
Returns true if the other filter can be merged into self.
pub fn merge(&mut self, other: &ByteFilter)
pub fn merge(&mut self, other: &ByteFilter)
Merges the other filter into self.
pub fn can_exclude(&self, other: &ByteFilter) -> bool
pub fn can_exclude(&self, other: &ByteFilter) -> bool
Returns true if self - other
can be computed.
pub fn exclude(&mut self, other: &ByteFilter)
pub fn exclude(&mut self, other: &ByteFilter)
Computes self - other
.
pub fn intersect(&mut self, other: &ByteFilter)
pub fn intersect(&mut self, other: &ByteFilter)
Intersects self
with other
, storing the result in self
.
pub fn num_wildcard_bits(&self) -> usize
pub fn num_wildcard_bits(&self) -> usize
Returns the number of wildcard bits in the filter.
Trait Implementations§
§impl Clone for ByteFilter
impl Clone for ByteFilter
§fn clone(&self) -> ByteFilter
fn clone(&self) -> ByteFilter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for ByteFilter
impl Debug for ByteFilter
§impl<'de> Deserialize<'de> for ByteFilter
impl<'de> Deserialize<'de> for ByteFilter
§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
§impl Hash for ByteFilter
impl Hash for ByteFilter
§impl JsonSchema for ByteFilter
impl JsonSchema for ByteFilter
§fn schema_name() -> String
fn schema_name() -> String
§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read more§impl Ord for ByteFilter
impl Ord for ByteFilter
§impl PartialEq for ByteFilter
impl PartialEq for ByteFilter
§impl PartialOrd for ByteFilter
impl PartialOrd for ByteFilter
§impl Serialize for ByteFilter
impl Serialize for ByteFilter
impl Eq for ByteFilter
impl StructuralPartialEq for ByteFilter
Auto Trait Implementations§
impl Freeze for ByteFilter
impl RefUnwindSafe for ByteFilter
impl Send for ByteFilter
impl Sync for ByteFilter
impl Unpin for ByteFilter
impl UnwindSafe for ByteFilter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more