Crates.io | gdvariants |
lib.rs | gdvariants |
version | 1.1.0 |
source | src |
created_at | 2022-04-02 18:05:09.137596 |
updated_at | 2022-04-19 14:52:03.414146 |
description | Rust std library collections wrapper that implements the godot-rust variant traits. |
homepage | |
repository | https://github.com/ironpeak/gdvariants |
max_upload_size | |
id | 561012 |
size | 187,808 |
Rust std library collections wrapper that implements the godot-rust variant traits for convenience when using godot-rust.
Traits implemented on top of the standard library implementation:
Add this to your Cargo.toml
:
gdvariants = "*"
Read the godot-rust book for information on how to setup a Godot project that uses Rust.
use gdnative::api::*;
use gdnative::prelude::*;
use gdvariants::collections::HashMap;
#[derive(NativeClass, Default)]
#[inherit(Node)]
pub struct ExampleHashMapProperty {
#[property]
players: HashMap<i64, String>,
}
use gdnative::api::*;
use gdnative::prelude::*;
use gdvariants::collections::HashMap;
...
fn send_data(&mut self, owner: &Node) {
let mut data: HashMap<i64, i64> = HashMap::new();
data.insert(1, 0);
for player in self.players.keys() {
owner.rpc_id(*player, "data", &[data.to_variant()]);
}
}
use gdnative::api::*;
use gdnative::prelude::*;
use gdvariants::collections::HashMap;
...
fn receive_data(&mut self, owner: &Node, data: HashMap<i64, i64>) {
let mut data: HashMap<i64, i64> = HashMap::new();
data.insert(1, 0);
for player in self.players.keys() {
owner.rpc_id(*player, "data", &[data.to_variant()]);
}
}