Enum oc_wasm_opencomputers::modem::PacketPart  
source · pub enum PacketPart<'a> {
    Null,
    Bool(bool),
    I32(i32),
    I64(i64),
    F32(f32),
    F64(f64),
    Str(&'a str),
    Bytes(&'a [u8]),
}Expand description
A data type that can be sent as part of a network packet.
The 'a lifetime is the lifetime of the data, if the part contains a string or byte array.
Variants§
Null
The packet part is a null.
A null is preserved end-to-end. In OpenComputers 1.7, a null costs six bytes of space in the packet. In OpenComputers 1.8+, it costs 3 bytes.
Bool(bool)
The packet part is a boolean.
A boolean is preserved end-to-end. In OpenComputers 1.7, a boolean costs six bytes of space in the packet. In OpenComputers 1.8+, it costs 3 bytes.
I32(i32)
The packet part is a 32-bit integer.
In OpenComputers 1.7, an i32 is converted to an F64 on the receiver; therefore,
this enumeration element can never appear in a received message. It costs six bytes of
space in the packet and is therefore still useful on the sending end as it is cheaper to
send an i32 than an f64 (ten bytes).
In OpenComputers 1.8+, an i32 is preserved end-to-end. It costs four bytes if its value
is between −32,768 and +32,767, and six bytes otherwise.
I64(i64)
The packet part is a 64-bit integer.
In OpenComputers 1.7, an i64 is not permitted.
In OpenComputers 1.8+, an i64 is converted to an I32 and costs the same as that
type if its value fits within that type’s range; otherwise, it is preserved end-to-end and
costs ten bytes of space in the packet.
F32(f32)
The packet part is a 32-bit floating-point number.
In OpenComputers 1.7, an f32 is converted to an F64 on the receiver; therefore,
this enumeration element can never appear in a received message. It also costs the same as
an F64, ten bytes.
In OpenComputers 1.8+, an f32 is converted to an F64 on the receiver;
therefore, this enumeration element can never appear in a received message. It costs six
bytes of space in the packet and is therefore still useful on the sending end as it is
cheaper to send an f32 than an f64 (ten bytes).
F64(f64)
The packet part is a 64-bit floating-point number.
An f64 costs ten bytes of space in the packet and is preserved end-to-end.
Str(&'a str)
The packet part is a text string.
An empty str costs three byte of space in the packet. A non-empty str costs two plus
the length of its UTF-8-encoded form bytes of space in the packet. It is preserved
end-to-end.
Bytes(&'a [u8])
The packet part is an array of bytes.
An empty byte array costs three bytes of space in the packet. A non-empty byte array costs two plus its length bytes of space in the packet. It is preserved end-to-end.
Trait Implementations§
source§impl<'a> Clone for PacketPart<'a>
 
impl<'a> Clone for PacketPart<'a>
source§fn clone(&self) -> PacketPart<'a>
 
fn clone(&self) -> PacketPart<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl<'a> Debug for PacketPart<'a>
 
impl<'a> Debug for PacketPart<'a>
source§impl<'buffer, Context> Decode<'buffer, Context> for PacketPart<'buffer>
 
impl<'buffer, Context> Decode<'buffer, Context> for PacketPart<'buffer>
source§impl<Context> Encode<Context> for PacketPart<'_>
 
impl<Context> Encode<Context> for PacketPart<'_>
source§impl<'a> From<&'a [u8]> for PacketPart<'a>
 
impl<'a> From<&'a [u8]> for PacketPart<'a>
source§impl<'a> From<&'a ByteSlice> for PacketPart<'a>
 
impl<'a> From<&'a ByteSlice> for PacketPart<'a>
source§impl<'a> From<&'a ByteVec> for PacketPart<'a>
 
impl<'a> From<&'a ByteVec> for PacketPart<'a>
source§impl<'a> From<&'a str> for PacketPart<'a>
 
impl<'a> From<&'a str> for PacketPart<'a>
source§impl From<()> for PacketPart<'_>
 
impl From<()> for PacketPart<'_>
source§impl From<bool> for PacketPart<'_>
 
impl From<bool> for PacketPart<'_>
source§impl From<f32> for PacketPart<'_>
 
impl From<f32> for PacketPart<'_>
source§impl From<f64> for PacketPart<'_>
 
impl From<f64> for PacketPart<'_>
source§impl From<i16> for PacketPart<'_>
 
impl From<i16> for PacketPart<'_>
source§impl From<i32> for PacketPart<'_>
 
impl From<i32> for PacketPart<'_>
source§impl From<i64> for PacketPart<'_>
 
impl From<i64> for PacketPart<'_>
source§impl From<i8> for PacketPart<'_>
 
impl From<i8> for PacketPart<'_>
source§impl From<u16> for PacketPart<'_>
 
impl From<u16> for PacketPart<'_>
source§impl From<u32> for PacketPart<'_>
 
impl From<u32> for PacketPart<'_>
source§impl From<u8> for PacketPart<'_>
 
impl From<u8> for PacketPart<'_>
source§impl<'a> PartialEq for PacketPart<'a>
 
impl<'a> PartialEq for PacketPart<'a>
source§fn eq(&self, other: &PacketPart<'a>) -> bool
 
fn eq(&self, other: &PacketPart<'a>) -> bool
self and other values to be equal, and is used
by ==.source§impl<'a> PartialOrd for PacketPart<'a>
 
impl<'a> PartialOrd for PacketPart<'a>
source§fn partial_cmp(&self, other: &PacketPart<'a>) -> Option<Ordering>
 
fn partial_cmp(&self, other: &PacketPart<'a>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
 
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more