Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
XAMPPRocky committed Sep 2, 2023
1 parent 2b2a3bc commit 5e58a9a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
3 changes: 3 additions & 0 deletions src/ber/de.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! # Decoding BER

// TODO: Update chrono functions.
#![allow(deprecated)]

mod config;
mod error;
pub(super) mod parser;
Expand Down
22 changes: 11 additions & 11 deletions src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use snafu::*;

use crate::prelude::*;

pub use self::{enc::EncodeError, de::DecodeError};
pub use self::{de::DecodeError, enc::EncodeError};

/// A set of supported ASN.1 codecs. Can be used to dynamically encode types
/// into different codecs at runtime.
Expand Down Expand Up @@ -58,15 +58,15 @@ mod enc {
#[snafu(visibility(pub(crate)))]
pub enum EncodeError {
#[snafu(display("APER Error: {}", source))]
Aper{ source: crate::aper::enc::Error },
Aper { source: crate::aper::enc::Error },
#[snafu(display("BER Error: {}", source))]
Ber{ source: crate::ber::enc::Error },
Ber { source: crate::ber::enc::Error },
#[snafu(display("CER Error: {}", source))]
Cer{ source: crate::der::enc::Error },
Cer { source: crate::der::enc::Error },
#[snafu(display("DER Error: {}", source))]
Der{ source: crate::der::enc::Error },
Der { source: crate::der::enc::Error },
#[snafu(display("UPER Error: {}", source))]
Uper{ source: crate::uper::enc::Error },
Uper { source: crate::uper::enc::Error },
}
}

Expand All @@ -77,14 +77,14 @@ mod de {
#[snafu(visibility(pub(crate)))]
pub enum DecodeError {
#[snafu(display("APER Error: {}", source))]
Aper{ source: crate::aper::de::Error },
Aper { source: crate::aper::de::Error },
#[snafu(display("BER Error: {}", source))]
Ber{ source: crate::ber::de::Error },
Ber { source: crate::ber::de::Error },
#[snafu(display("CER Error: {}", source))]
Cer{ source: crate::der::de::Error },
Cer { source: crate::der::de::Error },
#[snafu(display("DER Error: {}", source))]
Der{ source: crate::der::de::Error },
Der { source: crate::der::de::Error },
#[snafu(display("UPER Error: {}", source))]
Uper{ source: crate::uper::de::Error },
Uper { source: crate::uper::de::Error },
}
}
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ macro_rules! round_trip_with_constraints {
}};
}

pub mod codec;
pub mod de;
pub mod enc;
pub mod types;
pub mod codec;


// Data Formats

Expand All @@ -51,10 +50,10 @@ pub mod uper;

#[doc(inline)]
pub use self::{
codec::Codec,
de::{Decode, Decoder},
enc::{Encode, Encoder},
types::{AsnType, Tag, TagTree},
codec::Codec,
};

/// A prelude containing the codec traits and all types defined in the [`types`]
Expand Down
6 changes: 4 additions & 2 deletions standards/snmp/src/v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ impl Message {
)) as Box<_>);
}

codec.decode::<T>(&self.security_parameters)
codec
.decode::<T>(&self.security_parameters)
.map_err(|error| Box::new(error) as Box<_>)
}

Expand All @@ -80,7 +81,8 @@ impl Message {
) -> Result<(), alloc::boxed::Box<dyn core::fmt::Display>> {
self.global_data.security_model = T::ID.into();

self.security_parameters = codec.encode::<T>(value)
self.security_parameters = codec
.encode::<T>(value)
.map_err(|error| Box::new(error) as Box<_>)?
.into();
Ok(())
Expand Down

0 comments on commit 5e58a9a

Please sign in to comment.