pub trait Decode<'s>:
Sized
+ Debug
+ PartialEq {
// Required method
fn decode<'input, I>(
input: I,
) -> Result<Decoded<Self>, DecodeError<&'input [u8]>>
where 'input: 's,
I: Into<&'input [u8]>;
}Required Methods§
Sourcefn decode<'input, I>(
input: I,
) -> Result<Decoded<Self>, DecodeError<&'input [u8]>>
fn decode<'input, I>( input: I, ) -> Result<Decoded<Self>, DecodeError<&'input [u8]>>
Decoder trait for decoding the individual fields of the GeoNetworking header
Takes binary data as input.
The Decoder trait is implemented for all higher-order fields of the
GeoNetworking header:
PacketBasicHeaderCommonHeaderIeee1609Dot2Data(a.k.a. Secured Header)GeoUnicastTopologicallyScopedBroadcastSingleHopBroadcastGeoBroadcastGeoAnycastBeaconLSRequestLSReply
§Usage
let data: &'static [u8] = &[
0x12, 0x00, 0x15, 0x01, 0x03, 0x81, 0x00, 0x40, 0x03, 0x80, 0x82, 0x02, 0x7c, 0x20,
0x51, 0x01, 0x00, 0x02, 0x58, 0x01, 0x00, 0x12, 0x52, 0x00, 0x00, 0x3c, 0x00, 0x04,
0xe5, 0x48, 0x10, 0xc7, 0x2e, 0x71, 0x25, 0xab, 0x00, 0x1f, 0xeb, 0xef, 0x74, 0x05,
0xf2, 0xaf, 0x27, 0x80, 0x00, 0x00, 0x00,
];
result = BasicHeader::decode(data).unwrap();
assert_eq!(
result,
Decoded {
bytes_consumed: 4,
decoded: BasicHeader {
version: 1,
next_header: NextAfterBasic::SecuredPacket,
reserved: crate::bits!(0;8),
lifetime: Lifetime(21),
remaining_hop_limit: 1
}
}
);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.