pub struct PacketHandler { /* private fields */ }
Expand description
Tool that handles the serialization, encryption and authentication of packets
Implementations§
Source§impl PacketHandler
impl PacketHandler
Sourcepub fn new(
options: HandlerOptions,
bucket_keys: Option<HashMap<BucketId, [u8; 32]>>,
session_key: Option<[u8; 32]>,
) -> Self
pub fn new( options: HandlerOptions, bucket_keys: Option<HashMap<BucketId, [u8; 32]>>, session_key: Option<[u8; 32]>, ) -> Self
Creates a new PacketHandler
§Arguments
options
- Options for the handler. SeeHandlerOptions
for more informationbucket_keys
- Keys for the buckets. IfNone
, the handler will use an empty mapsession_key
- The session key. IfNone
, the handler will not be able to encrypt or authenticate packets
Sourcepub fn parse_request(
&mut self,
data: &[u8],
) -> Result<RequestPacket, SerializationError>
pub fn parse_request( &mut self, data: &[u8], ) -> Result<RequestPacket, SerializationError>
Sourcepub fn parse_response(
&mut self,
data: &[u8],
) -> Result<ResponsePacket, SerializationError>
pub fn parse_response( &mut self, data: &[u8], ) -> Result<ResponsePacket, SerializationError>
Sourcepub fn serialize_request(
&mut self,
packet: RequestPacket,
with_len: bool,
) -> Result<Vec<u8>, SerializationError>
pub fn serialize_request( &mut self, packet: RequestPacket, with_len: bool, ) -> Result<Vec<u8>, SerializationError>
Sourcepub fn serialize_response(
&mut self,
packet: ResponsePacket,
with_len: bool,
) -> Result<Vec<u8>, SerializationError>
pub fn serialize_response( &mut self, packet: ResponsePacket, with_len: bool, ) -> Result<Vec<u8>, SerializationError>
Auto Trait Implementations§
impl Freeze for PacketHandler
impl RefUnwindSafe for PacketHandler
impl Send for PacketHandler
impl Sync for PacketHandler
impl Unpin for PacketHandler
impl UnwindSafe for PacketHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more