From b1f432ef3f5ce4d3d81041daf876f2527da263d2 Mon Sep 17 00:00:00 2001 From: Robert Schauklies Date: Sat, 11 Jan 2025 16:14:30 +0100 Subject: [PATCH] initial commit for client+libs --- beamer/client/.gitignore | 1 + beamer/client/Cargo.toml | 8 +++ beamer/client/src/main.rs | 3 + beamer/libs/semserialize/.gitignore | 1 + beamer/libs/semserialize/Cargo.lock | 96 +++++++++++++++++++++++++++++ beamer/libs/semserialize/Cargo.toml | 14 +++++ beamer/libs/semserialize/shell.nix | 16 +++++ beamer/libs/semserialize/src/lib.rs | 28 +++++++++ 8 files changed, 167 insertions(+) create mode 100644 beamer/client/.gitignore create mode 100644 beamer/client/Cargo.toml create mode 100644 beamer/client/src/main.rs create mode 100644 beamer/libs/semserialize/.gitignore create mode 100644 beamer/libs/semserialize/Cargo.lock create mode 100644 beamer/libs/semserialize/Cargo.toml create mode 100644 beamer/libs/semserialize/shell.nix create mode 100644 beamer/libs/semserialize/src/lib.rs diff --git a/beamer/client/.gitignore b/beamer/client/.gitignore new file mode 100644 index 0000000..eb5a316 --- /dev/null +++ b/beamer/client/.gitignore @@ -0,0 +1 @@ +target diff --git a/beamer/client/Cargo.toml b/beamer/client/Cargo.toml new file mode 100644 index 0000000..729587b --- /dev/null +++ b/beamer/client/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "client" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/beamer/client/src/main.rs b/beamer/client/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/beamer/client/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/beamer/libs/semserialize/.gitignore b/beamer/libs/semserialize/.gitignore new file mode 100644 index 0000000..eb5a316 --- /dev/null +++ b/beamer/libs/semserialize/.gitignore @@ -0,0 +1 @@ +target diff --git a/beamer/libs/semserialize/Cargo.lock b/beamer/libs/semserialize/Cargo.lock new file mode 100644 index 0000000..819f47f --- /dev/null +++ b/beamer/libs/semserialize/Cargo.lock @@ -0,0 +1,96 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "itoa" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "proc-macro2" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "semserialize" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "serde" +version = "1.0.216" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.216" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.134" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "syn" +version = "2.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ae51629bf965c5c098cc9e87908a3df5301051a9e087d6f9bef5c9771ed126" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" diff --git a/beamer/libs/semserialize/Cargo.toml b/beamer/libs/semserialize/Cargo.toml new file mode 100644 index 0000000..4835f1a --- /dev/null +++ b/beamer/libs/semserialize/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "semserialize" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +# By default, `serde` has the `std` feature enabled, which makes it unsuitable for embedded targets +# disabling default-features fixes this +serde = { version = "1.0", features = ["derive"] } + +[dev-dependencies] +serde_json = "1.0.134" diff --git a/beamer/libs/semserialize/shell.nix b/beamer/libs/semserialize/shell.nix new file mode 100644 index 0000000..0e480ce --- /dev/null +++ b/beamer/libs/semserialize/shell.nix @@ -0,0 +1,16 @@ +{ pkgs ? import {}}: +let rust-toolchain = with pkgs; symlinkJoin { + name = "rust-toolchain"; + paths = [ + rustc + cargo + rustfmt + rust-analyzer + clippy + rustPlatform.rustcSrc + ]; + }; +in pkgs.mkShell { + buildInputs = [rust-toolchain]; + RUST_BACKTRACE = 1; +} diff --git a/beamer/libs/semserialize/src/lib.rs b/beamer/libs/semserialize/src/lib.rs new file mode 100644 index 0000000..912e3a8 --- /dev/null +++ b/beamer/libs/semserialize/src/lib.rs @@ -0,0 +1,28 @@ +#[macro_use] +use serde::{Serialize, Deserialize}; + +// How many lines are there from HIGHEST to LOWEST +const HEIGHT: usize = 32; +// "Pixels" from left to right +const WIDTH: usize = 32; +#[derive(Serialize, Deserialize, Debug)] +struct SemLine{ + line: u32, + pixels:[u8;WIDTH] + +} + +#[cfg(test)] +mod tests { + use super::*; + use serde_json; + #[test] + fn test_serialize(){ + let test_struct: SemLine = SemLine{line:0,pixels:[0;WIDTH]}; + let serialized = serde_json::to_string(&test_struct).unwrap(); + let + } + fn deserialize(){ + + } +}