pub enum PolicyRejection {
PathTooLong,
MalformedSemantics,
UnsupportedSemantics,
InvalidNmeaChecksum,
}Expand description
Policy rejection reason.
Variants§
PathTooLong
Path contains too many components.
MalformedSemantics
Semantic payload is malformed.
UnsupportedSemantics
Semantic payload is unsupported.
InvalidNmeaChecksum
NMEA sentence has a present checksum that does not match.
Implementations§
Source§impl PolicyRejection
impl PolicyRejection
Sourcepub fn code(self) -> &'static str
pub fn code(self) -> &'static str
Returns a stable policy rejection code for logs and external systems.
Examples found in repository?
examples/process_file.rs (line 19)
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}Trait Implementations§
Source§impl Clone for PolicyRejection
impl Clone for PolicyRejection
Source§fn clone(&self) -> PolicyRejection
fn clone(&self) -> PolicyRejection
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 Debug for PolicyRejection
impl Debug for PolicyRejection
Source§impl PartialEq for PolicyRejection
impl PartialEq for PolicyRejection
impl Copy for PolicyRejection
impl Eq for PolicyRejection
impl StructuralPartialEq for PolicyRejection
Auto Trait Implementations§
impl Freeze for PolicyRejection
impl RefUnwindSafe for PolicyRejection
impl Send for PolicyRejection
impl Sync for PolicyRejection
impl Unpin for PolicyRejection
impl UnsafeUnpin for PolicyRejection
impl UnwindSafe for PolicyRejection
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