Rust & Zig

This commit is contained in:
Johan Maasing 2025-01-17 13:28:30 +01:00
parent ea4ef1d8b3
commit c2e16f5b83
11 changed files with 226 additions and 15 deletions

7
RustUDSClient/Cargo.lock generated Normal file
View file

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "RustUDSClient"
version = "0.1.0"

6
RustUDSClient/Cargo.toml Normal file
View file

@ -0,0 +1,6 @@
[package]
name = "RustUDSClient"
version = "0.1.0"
edition = "2021"
[dependencies]

19
RustUDSClient/src/main.rs Normal file
View file

@ -0,0 +1,19 @@
use std::io::Write;
use std::os::unix::net::UnixStream;
fn main() {
let socket = "/tmp/udsserver.sock";
let stream_result = UnixStream::connect(socket);
match stream_result {
Ok(mut stream) => {
let message = "Hello, World from RUST™!";
let mut size_buf = [0u8] ;
size_buf[0] = message.len() as u8;
stream.write(size_buf.as_slice()).unwrap();
stream.write_all(message.as_bytes()).unwrap();
}
Err(e) => {
println!("Error: {}", e);
}
}
}