pub struct Policy {
pub allow_unsupported: bool,
pub allow_malformed_semantics: bool,
pub reject_invalid_nmea_checksum: bool,
pub max_path_components: usize,
}Expand description
Policy options applied after parsing.
Fields§
§allow_unsupported: boolAllow semantic packets represented as unsupported.
allow_malformed_semantics: boolAllow semantic packets represented as malformed.
reject_invalid_nmea_checksum: boolReject NMEA sentences when a present checksum does not match.
max_path_components: usizeMaximum allowed path component count including destination.
Implementations§
Source§impl Policy
impl Policy
Sourcepub fn strict() -> Self
pub fn strict() -> Self
Strict policy: reject malformed semantics, unsupported formats, and long paths.
Examples found in repository?
examples/process_file.rs (line 14)
7fn main() -> std::io::Result<()> {
8 let Some(path) = std::env::args().nth(1) else {
9 eprintln!("usage: process_file <packets.aprs>");
10 std::process::exit(2);
11 };
12
13 let input = read_all_with_limit(File::open(path)?, DEFAULT_TRANSPORT_READ_LIMIT)?;
14 let mut engine = Engine::new(Policy::strict());
15
16 for packet_bytes in LineTransport::new(&input).packets() {
17 match engine.process(packet_bytes) {
18 EngineResult::Accepted { packet } => println!("{}", packet.to_json()),
19 EngineResult::Rejected { reason, .. } => eprintln!("rejected: {}", reason.code()),
20 EngineResult::ParseError(error) => eprintln!("malformed: {}", error.code()),
21 }
22 }
23
24 Ok(())
25}Sourcepub fn permissive() -> Self
pub fn permissive() -> Self
Permissive policy: accept unsupported and malformed semantic packets.
Sourcepub fn evaluate(
&self,
packet: &ParsedPacket,
semantic: &AprsData<'_>,
) -> PolicyDecision
pub fn evaluate( &self, packet: &ParsedPacket, semantic: &AprsData<'_>, ) -> PolicyDecision
Evaluates a parsed packet and semantic view.
Trait Implementations§
impl Eq for Policy
impl StructuralPartialEq for Policy
Auto Trait Implementations§
impl Freeze for Policy
impl RefUnwindSafe for Policy
impl Send for Policy
impl Sync for Policy
impl Unpin for Policy
impl UnsafeUnpin for Policy
impl UnwindSafe for Policy
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