Category "rust"

Rust Actix Websockets & Actix Broker

I'm quite new to rust and actix, but I tried to build a technology prototype where a server sends protobuf messages to clients via websockets. The protobuf part

Tauri Rust Invoke and return to frontend issues

I have invoked a function from my frontend to my backend. It works however I want to return results back to frontend and all I get is null #[tauri::command] fn

Rust: Move issue in while loop

I have the following rust code and for the life of me I cant workout why I am getting a borrow-checker issue with this value and why does it get moved as part o

Most idiomatic way to read a range of bytes from a file

I have a file, say myfile. Using Rust, I would like to open myfile, and read bytes N to M into a Vec, say myvec. What is the most idiomatic way to do so? Naivel

Ownership of values whose variables are shadowed

See some code below: #[derive(Debug)] struct MyString { a: String, } impl MyString { fn new(s: &str) -> Self { MyString { a: String::fro

How can I make my Rust program run at startup?

I know about how to run programs at startup on Windows, but not Linux (even though I use Linux myself). Is there a library I can use which will automatically ru

Pre-release version number in mixed python/rust project with maturin

I am working on a mixed Rust/Python project being build with maturin. I am having trouble figuring out how I can specify a pre-release version that can than be

Mutable borrow inside loop

I have a vector of tuples, each containing two strings. I want to transfer (one of) the two strings as a mutable reference into a hashmap. The other string is a

Neon bindings example with RefCell not working

I'm trying to figure out how to use native Rust modules in NodeJS using the Neon crate. To get started I was following an example using RefCell to make it possi

Splitting a Rust string into a Vec of its substrings with contiguous identical characters

I have a string or a &str of ASCII characters and I want to separate it into a Vec of all substrings with contiguous identical characters (for example, "aab

VSCode Rust add semicolon on save

I am using the Rust extension on vscode and NOT rust-analyzer. However, when I am saving a file, vscode is using rustfmt to format my file but it doesn't automa

Why use traits? [closed]

What typical scenario would traits be used for in a Rust program? I have tried to wrap my head around them, but I still don't have a clear con

Using Rust with C API and mut/pointer problems with types

I'm trying to interact with a low-level C API using Rust. It requires calling to get the size of an array, then calling again with an allocated array of structs

Why is this match pattern unreachable when using non-literal patterns?

The following code (playground) let max_column = 7; edge = match current_column { 0 => Edge::Left, max_column => Edge::Right, _ => Edge::N

How should I handle smart contract structure change in NEAR protocol?

Suppose I have a contract ... pub struct Contract { collection_a: Vector<String>, } After I deploy this version, when I change the data structure of my

How to remove Smart Contract in NEAR Protocol?

I am new to blockchain and Near Protocol. I have created 2 smart contracts on Near Protocol. The first one was successfully done but when I try to deploy the se

Serialize/Deserialize json array to struct

I have incoming data in a json array that I deserialize into a struct, but I can't seem figure out how to serialize it back into an array instead of an object.

How do you check if an arithmetic operation will overflow?

I am coming from looking at Rust and How do I detect unsigned integer multiply overflow? where in Rust they have checked_add, which is implemented like this: pu

Deserialize using a function of the tag

An API with this internally tagged field structure, with "topic" being the tag: { "topic": "Car" "name": "BMW" "HP": 250 } This can be deserialized

Avoid using partially moved value in match statement

The solution provided in question 38553513 does not work for me. Consider these types and functions: pub enum Parameter { ParameterTypeA { n: i32 }, Par