Encoder

Struct Encoder 

Source
pub struct Encoder;
Expand description

Encodes a variant from its type into bytes

Implementations§

Source§

impl Encoder

Source

pub fn encode_dictionary(dictionary: &GodotDictionary) -> Result<Vec<u8>>

Encodes a Godot dictionary into bytes. A godot dictionary consists of key value pairs.

§Example

Due to the nature of Godot’s type system, key’s and value’s can be different types. Due to the nature of Rust, this adds quite a bit of overhead to creating a Dictionary

{ "key": "value", "key2": 42, Vector3(45, 2, 9): 9529 }
Source§

impl Encoder

Source

pub fn encode_float(float: &GodotFloat) -> Result<Vec<u8>>

Encodes a Godot float into bytes. A Godot float will be encoded into its respective sizes based on the float. If the byte length of the float is over the 32 bit size

Source

pub fn encode_f32(i: f32) -> Vec<u8>

Encodes a 32 bit float into bytes

Source

pub fn encode_f64(i: f64) -> Vec<u8>

Encodes a 64 bit float into bytes

Source§

impl Encoder

Source

pub fn encode_int(int: &GodotInteger) -> Result<Vec<u8>>

Encodes a Godot integer into bytes. A Godot integer will be encoded into its respective sizes based on the integer. If the value is over the 32 bit max value it will be encoded as a 64 bit integer

Source

pub fn encode_int32(i: i32) -> Vec<u8>

Encodes a 32 bit integer into bytes

Source

pub fn encode_int64(i: i64) -> Vec<u8>

Encodes a 64 bit integer into bytes

Source§

impl Encoder

Source

pub fn encode_string(string: &GodotString) -> Result<Vec<u8>>

Encodes a Godot String into bytes

Source

pub fn encode_owned_string(string: String) -> Vec<u8>

Encodes an owned String into bytes

Source

pub fn encode_str(string: &str) -> Vec<u8>

Encodes a str into bytes

Source§

impl Encoder

Source

pub fn encode_vector2(vec2: &GodotVector2) -> Result<Vec<u8>>

Encodes a Vector2 into bytes

Source

pub fn encode_vector3(vec3: &GodotVector3) -> Result<Vec<u8>>

Encodes a Vector3 into bytes

Source§

impl Encoder

Source

pub fn encode_bool(bool: &GodotBool) -> Result<Vec<u8>>

Encodes a Godot bool into bytes

Source

pub fn encode_raw_bool(bool: bool) -> Vec<u8>

Encodes a bool into bytes

Source§

impl Encoder

Source

pub fn encode_variant(variant: &dyn GodotVariant) -> Result<Vec<u8>>

Takes in a Godot variant and determines how to encode it based on its 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.