pub struct MsgBase {
pub payload: Vec<u8>,
pub position: u64,
}Expand description
The payload of a client message: a byte buffer with a cursor.
Fields§
§payload: Vec<u8>The raw bytes of the message payload.
position: u64The read/write cursor into MsgBase::payload.
Implementations§
Source§impl MsgBase
impl MsgBase
Sourcepub fn new(payload_reserve: usize) -> Self
pub fn new(payload_reserve: usize) -> Self
Creates an empty payload with the given initial capacity.
Sourcepub fn from_bytes(data: &[u8]) -> Self
pub fn from_bytes(data: &[u8]) -> Self
Creates a payload pre-filled with data, positioned at the start.
Sourcepub fn seek(&mut self, offset: u64) -> u64
pub fn seek(&mut self, offset: u64) -> u64
Seeks to offset from the beginning of the payload.
Returns the new position.
Sourcepub fn seek_from(&mut self, offset: u64, origin: SeekOrigin) -> u64
pub fn seek_from(&mut self, offset: u64, origin: SeekOrigin) -> u64
Seeks to offset relative to origin and returns the new position.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
A copy of the whole payload, not just the part after the cursor.
Sourcepub fn reader(&self) -> Reader<'_>
pub fn reader(&self) -> Reader<'_>
A borrowing reader over the part of the payload after the cursor.
Sourcepub fn write_bytes(&mut self, v: &[u8])
pub fn write_bytes(&mut self, v: &[u8])
Writes v at the cursor and advances it. Writing past the end
zero-fills the gap.
Sourcepub fn write_string(&mut self, v: &str)
pub fn write_string(&mut self, v: &str)
Writes the UTF-8 bytes of v, without a terminator.
Sourcepub fn write_null_term_string(&mut self, v: &str)
pub fn write_null_term_string(&mut self, v: &str)
Writes the UTF-8 bytes of v followed by a null terminator.
Sourcepub fn read_exact(&mut self, count: usize) -> Result<Vec<u8>, SteamError>
pub fn read_exact(&mut self, count: usize) -> Result<Vec<u8>, SteamError>
Reads exactly count bytes and advances the cursor.
Sourcepub fn read_bytes(&mut self, count: usize) -> Vec<u8> ⓘ
pub fn read_bytes(&mut self, count: usize) -> Vec<u8> ⓘ
Reads up to count bytes and advances the cursor. Returns fewer bytes
if the payload runs out instead of failing.
Sourcepub fn read_u8(&mut self) -> Result<u8, SteamError>
pub fn read_u8(&mut self) -> Result<u8, SteamError>
Reads a single unsigned byte.
Sourcepub fn read_i8(&mut self) -> Result<i8, SteamError>
pub fn read_i8(&mut self) -> Result<i8, SteamError>
Reads a single signed byte.
Sourcepub fn read_u16(&mut self) -> Result<u16, SteamError>
pub fn read_u16(&mut self) -> Result<u16, SteamError>
Reads a single unsigned 16 bit short.
Sourcepub fn read_i16(&mut self) -> Result<i16, SteamError>
pub fn read_i16(&mut self) -> Result<i16, SteamError>
Reads a single signed 16 bit short.
Sourcepub fn read_u32(&mut self) -> Result<u32, SteamError>
pub fn read_u32(&mut self) -> Result<u32, SteamError>
Reads a single unsigned 32 bit integer.
Sourcepub fn read_i32(&mut self) -> Result<i32, SteamError>
pub fn read_i32(&mut self) -> Result<i32, SteamError>
Reads a single signed 32 bit integer.
Sourcepub fn read_u64(&mut self) -> Result<u64, SteamError>
pub fn read_u64(&mut self) -> Result<u64, SteamError>
Reads a single unsigned 64 bit integer.
Sourcepub fn read_i64(&mut self) -> Result<i64, SteamError>
pub fn read_i64(&mut self) -> Result<i64, SteamError>
Reads a single signed 64 bit integer.
Sourcepub fn read_f32(&mut self) -> Result<f32, SteamError>
pub fn read_f32(&mut self) -> Result<f32, SteamError>
Reads a single 32 bit float.
Sourcepub fn read_f64(&mut self) -> Result<f64, SteamError>
pub fn read_f64(&mut self) -> Result<f64, SteamError>
Reads a single 64 bit double.
Sourcepub fn read_null_term_string(&mut self) -> Result<String, SteamError>
pub fn read_null_term_string(&mut self) -> Result<String, SteamError>
Reads a null terminated UTF-8 string, consuming the terminator.
Sourcepub fn read_sbyte(&mut self) -> Result<i8, SteamError>
pub fn read_sbyte(&mut self) -> Result<i8, SteamError>
Same as read_i8.
Sourcepub fn read_uint8(&mut self) -> Result<u8, SteamError>
pub fn read_uint8(&mut self) -> Result<u8, SteamError>
Same as read_u8.
Sourcepub fn read_int16(&mut self) -> Result<i16, SteamError>
pub fn read_int16(&mut self) -> Result<i16, SteamError>
Same as read_i16.
Sourcepub fn read_short(&mut self) -> Result<i16, SteamError>
pub fn read_short(&mut self) -> Result<i16, SteamError>
Same as read_i16.
Sourcepub fn read_uint16(&mut self) -> Result<u16, SteamError>
pub fn read_uint16(&mut self) -> Result<u16, SteamError>
Same as read_u16.
Sourcepub fn read_ushort(&mut self) -> Result<u16, SteamError>
pub fn read_ushort(&mut self) -> Result<u16, SteamError>
Same as read_u16.
Sourcepub fn read_int32(&mut self) -> Result<i32, SteamError>
pub fn read_int32(&mut self) -> Result<i32, SteamError>
Same as read_i32.
Sourcepub fn read_uint32(&mut self) -> Result<u32, SteamError>
pub fn read_uint32(&mut self) -> Result<u32, SteamError>
Same as read_u32.
Sourcepub fn read_int64(&mut self) -> Result<i64, SteamError>
pub fn read_int64(&mut self) -> Result<i64, SteamError>
Same as read_i64.
Sourcepub fn read_uint64(&mut self) -> Result<u64, SteamError>
pub fn read_uint64(&mut self) -> Result<u64, SteamError>
Same as read_u64.
Sourcepub fn read_ulong(&mut self) -> Result<u64, SteamError>
pub fn read_ulong(&mut self) -> Result<u64, SteamError>
Same as read_u64.
Sourcepub fn read_single(&mut self) -> Result<f32, SteamError>
pub fn read_single(&mut self) -> Result<f32, SteamError>
Same as read_f32.
Sourcepub fn read_float(&mut self) -> Result<f32, SteamError>
pub fn read_float(&mut self) -> Result<f32, SteamError>
Same as read_f32.
Sourcepub fn read_double(&mut self) -> Result<f64, SteamError>
pub fn read_double(&mut self) -> Result<f64, SteamError>
Same as read_f64.