Decoder

Struct Decoder 

Source
pub struct Decoder;

Implementations§

Source§

impl Decoder

Source

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

Source

pub fn decode_float(bytes: &[u8], flag: &SerializeFlag) -> Result<GodotFloat>

Decodes a bytes into a Godot float

Source

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

Source

pub fn decode_int(bytes: &[u8], flag: &SerializeFlag) -> Result<GodotInteger>

Decodes bytes into a Godot integer

Source

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

Source

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

Source

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

Source

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

Source

pub fn decode_bool(bytes: &[u8], flag: &SerializeFlag) -> Result<GodotBool>

Decodes bytes into a Godot bool

Source§

impl Decoder

Source

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

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.