Advanced Search
Search Results
15 total results found
Smart Pointers
Smart Pointers are references to data, so you can use it, without taking ownership of this data. But before talking about Smart Pointers, lets take a look at normal references. Normal references You can create references to variables. This gives code the abi...
ESP8266
The ESP8266 is a microcontroller by Espressif. Properties Property Value Nominal Voltage 3.3 V CPU 32 bit CPU Connectivity 2.4 GHz Wifi, Bluetooth ADC 1 10-bit ADC with max 1.0 Volt Pins GPIO Pins, I2C, SPI, UART ...
Basics
Tauri is a framework for building desktop applications using the programming language Rust. It uses Rust for the core of the application, but gives you the ability to define the user interface using JS/TS based frameworks like Vue or React. Install and create...
Vue Invoke
When writing the user interface, you need to invoke the functions written in rust using the "invoke" function in vue. Example code for a rust function: #[tauri::command] fn my_function() -> String { "Hello world!".to_string() } #[cfg_attr(mobile, t...
SQLx
SQLx is a SQL framework for Rust, which allows to write SQL queries and check them on compile time. It also comes with a migration logic to update your database. Install SQLx To install the SQLx, run the following command in the terminal cargo install sqlx-...
Procedural Macros
Procedural macros are "headers" added above e.g. a struct, take those information and generate different code out of it. They look like this: #[example]. They are way more complex, but give you the ability to generate complex code. Procedural Macros takes an ...
Declarative Macros
Declarative macros look like a function: e.g. println!(), format!() or todo!(). They have an exclamation mark between the name and the parameter list. Declarative macros are like "shortcuts", it is usually more code, packed in a code block, which will generat...
Actix-Web
actix-web is a framework for writting web applications and REST APIs. Installation # To install: cargo add actix-web # Recommended for validation cargo add validator actix-web-validator Simple example #[get("/hello") async fn hello() -> Response { ...
Tracing
Tracing is a library for logging. It consists of multiple libraries. You need at least tracing, which is the base of the logging system, and tracing_subscriber, which defines the subscriber of the tracing messages. # To install cargo add tracing tracing_subs...
Patterns
Exhaustive patterns In this case, exhaustive means "It covers all cases", e.g. for an enum, so when a new entry is added, it causes an error until this case is considered everywhere. Example with never: enum Status { Open, InProgress, Done, } ...
Tricks
Allow everything what can be a str reference fn do_something<S: AsRef<str>>(input: S) { let input_str = input.as_ref(); println!("This is a &str: {}", input_str); } do_something("Hello World"); do_something("Hello World".to_string());
Serde
Serde (Serialize and Deserialize) is a library to serialize and deserialize data to or from a struct. This is usually used with language based crates like serde_json for JSON or serde_yaml for YAML. To use it, install it, and then you can use the derives on y...
Cross compilation
You can cross compile your Rust code using the target specifier. For example: cargo build --target x86_64-unknown-linux-gnu --release You can list all targets using rustup target list and add the targets you need. But often you need an environment with the c...
Check open ports
If you want to check open ports on your Linux device, you can use the ss command (socket statistics). Older versions may use netstat. ss Example: ss -tulpen Flags: -t → TCP -u → UDP -l → nur listening sockets -p → Prozess anzeigen -e → erweiterte In...
Modify Images
Resize ffmpeg -i input.jpg -vf "scale=1920:-1" output.jpg Change quality ffmpeg -i input.jpg -q:v 5 output.jpg Quality goes from 2 (best) to 31 (worst). 2-5 High quality 6-10 Good compression