[−][src]Struct rust_ipv8::serialization::Packet
The packet struct containing the bytes of a packet in a Vec<u8>
.
Methods
impl Packet
[src]
pub fn new(header: Header) -> Result<Self, Box<dyn Error>>
[src]
Creates a new packet with a given header.
pub fn raw(&self) -> &[u8]
[src]
Extracts the raw byte contents from a packet.
pub fn sign(self, keypair: &KeyPair) -> Result<Self, Box<dyn Error>>
[src]
Signs a packet. After this, new payloads must under no circumstances be added as this will break the verification process on the receiving end. There is no check for this by design for a speed boost (though this may or may not be revisited later). Sign deliberately consumes self and returns it again so it can be assigned to a new, immutable variable to never be changed again.
Verification of this signature can only happen when a public key is known at the receiving end. The user of the rust-ipv8 library is responsible for this to already have been packed into the final packet or alternatively already known by the receiver.
To verify signatures first transform the Packet into a PacketIterator with Packet.deserialize_multiple and then use the PacketIterator.verify() or PacketIterator.verify_with() method.
pub fn start_deserialize(self) -> PacketDeserializer
[src]
Deserializes a stream of bytes into ipv8 payloads.
pub fn add<T>(&mut self, obj: &T) -> Result<(), Box<ErrorKind>> where
T: Ipv8Payload + Serialize,
[src]
T: Ipv8Payload + Serialize,
Adds a payload to a packet. This serializes payloads.
Trait Implementations
impl PartialEq<Packet> for Packet
[src]
impl Clone for Packet
[src]
fn clone(&self) -> Packet
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Packet
[src]
impl Serialize for Packet
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de> Deserialize<'de> for Packet
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl Unpin for Packet
impl Sync for Packet
impl Send for Packet
impl RefUnwindSafe for Packet
impl UnwindSafe for Packet
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut 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,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,