pub struct Encoder;Expand description
Encodes a variant from its type into bytes
Implementations§
Source§impl Encoder
impl Encoder
Sourcepub fn encode_dictionary(dictionary: &GodotDictionary) -> Result<Vec<u8>>
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
impl Encoder
Sourcepub fn encode_float(float: &GodotFloat) -> Result<Vec<u8>>
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
Sourcepub fn encode_f32(i: f32) -> Vec<u8>
pub fn encode_f32(i: f32) -> Vec<u8>
Encodes a 32 bit float into bytes
Sourcepub fn encode_f64(i: f64) -> Vec<u8>
pub fn encode_f64(i: f64) -> Vec<u8>
Encodes a 64 bit float into bytes
Source§impl Encoder
impl Encoder
Sourcepub fn encode_int(int: &GodotInteger) -> Result<Vec<u8>>
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
Sourcepub fn encode_int32(i: i32) -> Vec<u8>
pub fn encode_int32(i: i32) -> Vec<u8>
Encodes a 32 bit integer into bytes
Sourcepub fn encode_int64(i: i64) -> Vec<u8>
pub fn encode_int64(i: i64) -> Vec<u8>
Encodes a 64 bit integer into bytes
Source§impl Encoder
impl Encoder
Sourcepub fn encode_string(string: &GodotString) -> Result<Vec<u8>>
pub fn encode_string(string: &GodotString) -> Result<Vec<u8>>
Encodes a Godot String into bytes
Sourcepub fn encode_owned_string(string: String) -> Vec<u8>
pub fn encode_owned_string(string: String) -> Vec<u8>
Encodes an owned String into bytes
Sourcepub fn encode_str(string: &str) -> Vec<u8>
pub fn encode_str(string: &str) -> Vec<u8>
Encodes a str into bytes
Source§impl Encoder
impl Encoder
Sourcepub fn encode_vector2(vec2: &GodotVector2) -> Result<Vec<u8>>
pub fn encode_vector2(vec2: &GodotVector2) -> Result<Vec<u8>>
Encodes a Vector2 into bytes
Sourcepub fn encode_vector3(vec3: &GodotVector3) -> Result<Vec<u8>>
pub fn encode_vector3(vec3: &GodotVector3) -> Result<Vec<u8>>
Encodes a Vector3 into bytes
Source§impl Encoder
impl Encoder
Sourcepub fn encode_variant(variant: &dyn GodotVariant) -> Result<Vec<u8>>
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