asn1_rs/asn1_types/real/
f32.rs

1use crate::{Any, CheckDerConstraints, DerAutoDerive, Error, Real, Result, Tag, Tagged};
2use core::convert::{TryFrom, TryInto};
3
4impl<'a> TryFrom<Any<'a>> for f32 {
5    type Error = Error;
6
7    fn try_from(any: Any<'a>) -> Result<f32> {
8        any.tag().assert_eq(Self::TAG)?;
9        any.header.assert_primitive()?;
10        let real: Real = any.try_into()?;
11        Ok(real.f32())
12    }
13}
14
15impl CheckDerConstraints for f32 {
16    fn check_constraints(any: &Any) -> Result<()> {
17        any.header.assert_primitive()?;
18        any.header.length.assert_definite()?;
19        Ok(())
20    }
21}
22
23impl DerAutoDerive for f32 {}
24
25impl Tagged for f32 {
26    const TAG: Tag = Tag::RealType;
27}