pub struct Decoder;Implementations§
Source§impl Decoder
impl Decoder
Sourcepub fn decode_dictionary(bytes: &[u8]) -> Result<GodotDictionary>
pub fn decode_dictionary(bytes: &[u8]) -> Result<GodotDictionary>
Decodes bytes into a godot dictionary.
§Example
// Typically you would get this from a network request
let bytes = /* Pretend we have valid bytes here */
let Ok(dictionary) = Decoder::decode_dictionary(&bytes) else {
panic!("Invalid bytes");
}
// Assuming the dictionary has a key value pair that has a key of "position"
let key = Box::new(GodotString::new("position")) as Box<dyn GodotVariant>;
// We can get the value now with this key
let value = dictionary.map.get(&key);
Source§impl Decoder
impl Decoder
Sourcepub fn decode_float(bytes: &[u8], flag: &SerializeFlag) -> Result<GodotFloat>
pub fn decode_float(bytes: &[u8], flag: &SerializeFlag) -> Result<GodotFloat>
Decodes a bytes into a Godot float
Sourcepub fn decode_raw_float(
bytes: &[u8],
offset: usize,
flag: &SerializeFlag,
) -> Result<GodotFloat>
pub fn decode_raw_float( bytes: &[u8], offset: usize, flag: &SerializeFlag, ) -> Result<GodotFloat>
Uses a serialization flag and the offset in bytes to decode bytes into a Godot float
Source§impl Decoder
impl Decoder
Sourcepub fn decode_int(bytes: &[u8], flag: &SerializeFlag) -> Result<GodotInteger>
pub fn decode_int(bytes: &[u8], flag: &SerializeFlag) -> Result<GodotInteger>
Decodes bytes into a Godot integer
Sourcepub fn decode_raw_int(
bytes: &[u8],
offset: usize,
flag: &SerializeFlag,
) -> Result<GodotInteger>
pub fn decode_raw_int( bytes: &[u8], offset: usize, flag: &SerializeFlag, ) -> Result<GodotInteger>
Uses a serialization flag and the offset in bytes to decode bytes into a Godot integer
Source§impl Decoder
impl Decoder
Sourcepub fn decode_string(bytes: &[u8]) -> Result<GodotString>
pub fn decode_string(bytes: &[u8]) -> Result<GodotString>
Decodes bytes into a Godot string. This will fail if the bytes do not match Godot’s serialization rules
Source§impl Decoder
impl Decoder
Sourcepub fn decode_vector2(bytes: &[u8]) -> Result<GodotVector2>
pub fn decode_vector2(bytes: &[u8]) -> Result<GodotVector2>
Decodes bytes into a vector 2. This will fail if the inner bytes can’t be decoded into a float
Sourcepub fn decode_vector3(bytes: &[u8]) -> Result<GodotVector3>
pub fn decode_vector3(bytes: &[u8]) -> Result<GodotVector3>
Decodes bytes into a vector 3. This will fail if the inner bytes can’t be decoded into a float
Source§impl Decoder
impl Decoder
Sourcepub fn decode_bool(bytes: &[u8], flag: &SerializeFlag) -> Result<GodotBool>
pub fn decode_bool(bytes: &[u8], flag: &SerializeFlag) -> Result<GodotBool>
Decodes bytes into a Godot bool
Source§impl Decoder
impl Decoder
Sourcepub fn get_type_and_flags(
bytes: &[u8],
) -> Result<(GodotTypeIndex, SerializeFlag)>
pub fn get_type_and_flags( bytes: &[u8], ) -> Result<(GodotTypeIndex, SerializeFlag)>
Gets the type and flags of the bytes passed. The type determines which type we should try and decode it as, and the flag shows how we will decode the type
Sourcepub fn decode_variant(bytes: &[u8]) -> Result<Box<dyn GodotVariant + 'static>>
pub fn decode_variant(bytes: &[u8]) -> Result<Box<dyn GodotVariant + 'static>>
Decodes bytes into it’s respective Godot variant. This can fail if the bytes does not match Godot’s serialization rules or it’s an unsupported type.