[−][src]Struct rust_ipv8::serialization::PacketDeserializer
The main deserializer which iterates over a packet to deserialize it.
This provides multipile helper methods for deserializing packets.
Fields
pntr: Packet
The current packet being deserialize
index: usize
The index in the vector keeping track how far along we are deserializing.
Methods
impl PacketDeserializer
[src]
iterates over a packet to extract it's possibly multiple payloads
pub fn next_payload<T>(&mut self) -> Result<T, Box<ErrorKind>> where
T: Deserialize<'de> + Ipv8Payload + Serialize,
[src]
T: Deserialize<'de> + Ipv8Payload + Serialize,
Deserializes a stream of bytes into an ipv8 payload. Which payload is inferred by the type of T which is generic. T has to be deserializable and implement the Ipv8Payload trait.
pub fn peek_header(&self) -> Result<Header, Box<ErrorKind>>
[src]
Returns the header of a packet without removing it
pub fn pop_header(&mut self) -> Result<Header, Box<ErrorKind>>
[src]
Returns the header of a packet and removes it
pub fn skip_header(self) -> Result<Self, Box<ErrorKind>>
[src]
Just skips over the header returning self
pub fn verify(&mut self) -> bool
[src]
This should be in most cases the first method to be called when receiving a packet. It assumes there is a BinMemberAuthenticationPayload at the start of the message (AND DOES NOT CHECK IF IT IS OR NOT). It extracts it and the with the sign put at the end by the sender by calling Packet.sign() verifies that the packet is still inyhtact.
If the public key has been acquired in any other way (i.e. there is no BinMemberAuthenticationPayload at the start) use the Packet.verify_with() function instead.
pub fn verify_with(&mut self, pkey: Ed25519PublicKey) -> bool
[src]
Does the same thing as the Packet. verify method. Takes a public key as second argument instead of extracting it from the packet itself through a BinMemberAuthenticationPayload
Trait Implementations
impl PartialEq<PacketDeserializer> for PacketDeserializer
[src]
fn eq(&self, other: &PacketDeserializer) -> bool
[src]
fn ne(&self, other: &PacketDeserializer) -> bool
[src]
impl Debug for PacketDeserializer
[src]
Auto Trait Implementations
impl Unpin for PacketDeserializer
impl Sync for PacketDeserializer
impl Send for PacketDeserializer
impl RefUnwindSafe for PacketDeserializer
impl UnwindSafe for PacketDeserializer
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,