http2byond

Function send_byond

Source
pub fn send_byond(target: &SocketAddr, topic: &str) -> Result<ByondTopicValue>
Expand description

Main (and only) function of this library.

§Arguments

  • target - A TCP SocketAddr of a Dream Daemon instance.
  • topic - The string you want sent to Dream Daemon. Make sure to always start this with the character ?.ByondTopicValue

§Examples

use http2byond::{send_byond, ByondTopicValue};
match send_byond(&SocketAddr::from(([127, 0, 0, 1], 1337)), "?status") {
    Err(_) => {}
    Ok(btv_result) => {
        match btv_result {
            ByondTopicValue::None => println!("Byond returned nothing"),
            ByondTopicValue::String(str) => println!("Byond returned string {}", str),
            ByondTopicValue::Number(num) => println!("Byond returned number {}", num),
        }
    }
}