pub struct SemanticBlocklist<'a> { /* private fields */ }Expand description
Runtime-neutral semantic-family blocklist helper.
Implementations§
Source§impl<'a> SemanticBlocklist<'a>
impl<'a> SemanticBlocklist<'a>
Sourcepub const fn new(families: &'a [SemanticFamily]) -> Self
pub const fn new(families: &'a [SemanticFamily]) -> Self
Creates a blocklist over caller-owned semantic-family storage.
Examples found in repository?
examples/service_toolkit.rs (line 14)
10fn main() -> Result<(), libaprs_engine::ParseError> {
11 let mut engine = Engine::default();
12 let mut duplicates = DuplicateWindow::new(128);
13 let mut rate = PacketRateBudget::new(100);
14 let blocked = SemanticBlocklist::new(&[SemanticFamily::Unsupported, SemanticFamily::Malformed]);
15
16 for packet_bytes in [b"N0CALL>APRS:>service".as_slice()] {
17 if rate.try_consume() == RateLimitDecision::Limited {
18 continue;
19 }
20 if duplicates.observe(packet_bytes) == DuplicateDecision::Duplicate {
21 continue;
22 }
23
24 let packet = parse_packet(packet_bytes)?;
25 if blocked.rejects(&packet.aprs_data()) {
26 continue;
27 }
28
29 let _event = engine.process_event(packet.raw().as_bytes());
30 }
31
32 Ok(())
33}Sourcepub fn rejects(&self, data: &AprsData<'_>) -> bool
pub fn rejects(&self, data: &AprsData<'_>) -> bool
Returns true when the semantic packet family is blocklisted.
Examples found in repository?
examples/service_toolkit.rs (line 25)
10fn main() -> Result<(), libaprs_engine::ParseError> {
11 let mut engine = Engine::default();
12 let mut duplicates = DuplicateWindow::new(128);
13 let mut rate = PacketRateBudget::new(100);
14 let blocked = SemanticBlocklist::new(&[SemanticFamily::Unsupported, SemanticFamily::Malformed]);
15
16 for packet_bytes in [b"N0CALL>APRS:>service".as_slice()] {
17 if rate.try_consume() == RateLimitDecision::Limited {
18 continue;
19 }
20 if duplicates.observe(packet_bytes) == DuplicateDecision::Duplicate {
21 continue;
22 }
23
24 let packet = parse_packet(packet_bytes)?;
25 if blocked.rejects(&packet.aprs_data()) {
26 continue;
27 }
28
29 let _event = engine.process_event(packet.raw().as_bytes());
30 }
31
32 Ok(())
33}Sourcepub const fn families(&self) -> &'a [SemanticFamily]
pub const fn families(&self) -> &'a [SemanticFamily]
Returns the caller-owned blocked families.
Trait Implementations§
Source§impl<'a> Clone for SemanticBlocklist<'a>
impl<'a> Clone for SemanticBlocklist<'a>
Source§fn clone(&self) -> SemanticBlocklist<'a>
fn clone(&self) -> SemanticBlocklist<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a> Debug for SemanticBlocklist<'a>
impl<'a> Debug for SemanticBlocklist<'a>
Source§impl<'a> PartialEq for SemanticBlocklist<'a>
impl<'a> PartialEq for SemanticBlocklist<'a>
impl<'a> Copy for SemanticBlocklist<'a>
impl<'a> Eq for SemanticBlocklist<'a>
impl<'a> StructuralPartialEq for SemanticBlocklist<'a>
Auto Trait Implementations§
impl<'a> Freeze for SemanticBlocklist<'a>
impl<'a> RefUnwindSafe for SemanticBlocklist<'a>
impl<'a> Send for SemanticBlocklist<'a>
impl<'a> Sync for SemanticBlocklist<'a>
impl<'a> Unpin for SemanticBlocklist<'a>
impl<'a> UnsafeUnpin for SemanticBlocklist<'a>
impl<'a> UnwindSafe for SemanticBlocklist<'a>
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
Mutably borrows from an owned value. Read more