Socketboard Rust SDK
This is the official Rust SDK for Socketboard. It provides a simple way to interact with the Socketboard table.
Installation
Add the following to your Cargo.toml
file:
[]
= "0.1.0"
Usage
Here is a simple example of how to use the SDK:
use exit;
use thread;
use Duration;
// important imports
use Socketboard;
use ;
Documentation
The SDK is split into two main parts: the Socketboard
struct and the types
module.
Socketboard
socketboard::Socketboard
The main struct that is used to interact with the Socketboard table.
Methods
-
new(client_name: &str) -> Socketboard
: Creates a new instance of the Socketboard struct. -
with_host(client_name: &str, address: &str, port: u16) -> Socketboard
: Creates a new instance of the Socketboard struct with a custom host and port. The server software doesn't currently support custom hosts and ports, so this method is not recommended. -
start() -> Result<(), String>
: Connects to the remote table. Returns an error if there is an issue with the connection. -
stop()
: Closes the connection to the remote table. -
put_value(name: &str, value: Data) -> Result<(), String>
: Puts a value into the table. Returns an error if there is an issue with the connection or if there are invalid permissions. -
get_value(name: &str, default: Data) -> Data
: Retrieves a value from the table. If the value does not exist, the default value is returned. -
get_status() -> ConnectionStatus
: Returns the current status of the connection to the remote table. -
print_table()
: Prints the table to the console.
types
socketboard::types
Contains the different types that can be stored in the table.
Enums
-
Data
: Represents the different types that can be stored in the table.Number(f64)
: A floating point number.String(String)
: A string.Boolean(bool)
: A boolean.Array(Vec<Data>)
: An array of Data values.Object(HashMap<String, Data>)
: An object with string keys and Data values.
Importantly, there is no distinction between integers and floating point numbers. All numbers are stored as floating point numbers, as the table is not strongly typed, and shares data between clients with different languages.
-
ConnectionStatus
: Represents the different states of the connection to the table.Connected(String)
: The connection is established.Disconnected(String)
: The connection is closed.Failed(String)
: There was an issue with the connection.Connecting
: The connection is being established.Stopped
: The connection is closed.None
: The connection is not established.
Examples
use Socketboard;
use ;
Roadmap
- Basic functionality
- Documentation
- Support for password authenticated connections