[][src]Struct amethyst_network::NetPacket

pub struct NetPacket<T> { /* fields omitted */ }

Represents a packet which could have any serializable payload.

A packet could have reliability guarantees to specify how it should be delivered and processed.

Reliability TypePacket DropPacket DuplicationPacket OrderPacket FragmentationPacket Delivery
Unreliable UnorderedYesYesNoNoNo
Unreliable SequencedYesNoSequencedNoNo
Reliable UnorderedNoNoNoYesYes
Reliable OrderedNoNoOrderedYesYes
Reliable SequencedNoNoSequencedYesYes

You are able to send packets with any the above guarantees.

For more information please have a look at: https://amethyst.github.io/laminar/docs/reliability/reliability.html

Methods

impl<T> NetPacket<T>[src]

pub fn unreliable(content: T) -> NetPacket<T>[src]

Create a new unreliable packet with the given content.

Unreliable: Packets can be dropped, duplicated or arrive without order.

Details

Packet DropPacket DuplicationPacket OrderPacket FragmentationPacket Delivery
YesYesNoNoNo

Basically just bare UDP. The packet may or may not be delivered.

pub fn unreliable_sequenced(content: T, stream_id: Option<u8>) -> NetPacket<T>[src]

Create a new unreliable sequenced packet with the given content.

Unreliable Sequenced; Packets can be dropped, but could not be duplicated and arrive in sequence.

Details

Packet DropPacket DuplicationPacket OrderPacket FragmentationPacket Delivery
YesYesSequencedNoNo

Basically just bare UDP, free to be dropped, but has some sequencing to it so that only the newest packets are kept.

pub fn reliable_unordered(content: T) -> NetPacket<T>[src]

Create a new packet with the given content. Reliable; All packets will be sent and received, but without order.

Details

Packet DropPacket DuplicationPacket OrderPacket FragmentationPacket Delivery
NoNoNoYesYes

Basically this is almost TCP without ordering of packets.

pub fn reliable_ordered(content: T, stream_id: Option<u8>) -> NetPacket<T>[src]

Create a new packet with the given content and optional stream on which the ordering will be done.

Reliable; All packets will be sent and received, with order.

Details

Packet DropPacket DuplicationPacket OrderPacket FragmentationPacket Delivery
NoNoOrderedYesYes

Basically this is almost TCP-like with ordering of packets.

Remark

  • When stream_id is specified as None the default stream will be used; if you are not sure what this is you can leave it at None.

pub fn reliable_sequenced(content: T, stream_id: Option<u8>) -> NetPacket<T>[src]

Create a new packet with the given content and optional stream on which the sequencing will be done.

Reliable; All packets will be sent and received, but arranged in sequence. Which means that only the newest packets will be let through, older packets will be received but they won't get to the user.

Details

Packet DropPacket DuplicationPacket OrderPacket FragmentationPacket Delivery
YesNoSequencedYesYes

Basically this is almost TCP-like but then sequencing instead of ordering.

Remark

  • When stream_id is specified as None the default stream will be used; if you are not sure what this is you can leave it at None.

pub fn is_reliable(&self) -> bool[src]

Returns if this event is reliable.

Each net event type is either reliable or unreliable. Reliable events always reach their destination, unreliable events may be lost.

pub fn is_unreliable(&self) -> bool[src]

Returns if this event is unreliable.

Each net event type is either reliable or unreliable. Reliable events always reach their destination, unreliable events may be lost.

pub fn is_ordered(&self) -> bool[src]

Returns whether this event is an ordered event.

pub fn is_sequenced(&self) -> bool[src]

Returns whether this event is an sequenced event.

pub fn is_unordered(&self) -> bool[src]

Return if this event is neither ordered or sequenced.

pub fn content(&self) -> &T[src]

Returns a immutable reference to the content.

pub fn content_mut(&mut self) -> &mut T[src]

Returns a immutable reference to the content.

Trait Implementations

impl<T: Clone> Clone for NetPacket<T>[src]

impl<T: PartialEq> PartialEq<NetPacket<T>> for NetPacket<T>[src]

impl<T: Debug> Debug for NetPacket<T>[src]

impl<T> Serialize for NetPacket<T> where
    T: Serialize
[src]

impl<'de, T> Deserialize<'de> for NetPacket<T> where
    T: Deserialize<'de>, 
[src]

Auto Trait Implementations

impl<T> Send for NetPacket<T> where
    T: Send

impl<T> Sync for NetPacket<T> where
    T: Sync

impl<T> Unpin for NetPacket<T> where
    T: Unpin

impl<T> UnwindSafe for NetPacket<T> where
    T: UnwindSafe

impl<T> RefUnwindSafe for NetPacket<T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T> Any for T where
    T: Any

impl<T> Resource for T where
    T: Any + Send + Sync
[src]

impl<T> Event for T where
    T: Send + Sync + 'static, 
[src]