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 more