Category "rust"

Error adding Custom RPCs for custom pallet Substrate

I've been working with parity's contracts node (latest version) and the substrate template node (tag polkadot-v0.9.18), both present the same issue when compili

Os permission error when trying to create a `tun` device

I'm trying to create a tun device with rust's tun_tap create, I'm following documentation and trying to create an interface with the tun_tap::Iface::new(..);, b

actix-web: Add data to request in middleware

I am learning actix-web, I parsed jwt in middleware, I want to pass the data in jwt to the controller that parses to handle this request, but I don't know how t

shadertoy's GLSL and Rust Bevy WGSL incoherence

I'm trying to get into Shaders and decided to init a project using Rust and Bevy, the objective is to reproduce a raymarching shader just to confirm that the en

how to store a closure to map and call it in another thread?

I just try to write a consumer for rocketmq with rust, and have a PushConsumer like below: pub struct PushConsumer { consumer: Consumer, handler_map: Ha

how to store a closure to map and call it in another thread?

I just try to write a consumer for rocketmq with rust, and have a PushConsumer like below: pub struct PushConsumer { consumer: Consumer, handler_map: Ha

Is it possible to initialize a reference to ones self without needing to use an Option?

I'm building a circular linked list using an arena for the nodes. If I use a struct like the following it works fine: struct Node<'a> { next: Cell<Op

How to share same implementation and maybe share fields

How can I simplify this code? I still can't wrap my head around rust's traits and structs after OOP. struct Player { entity: Entity, hp: i32, atk: i

actix-web: limit upload file size

I successfully uploaded the file referring to this example, but I don't know how to limit the size of the file, for example I can't save the file more than 5M [

How can I pattern match Option in rust? Current code keeps panicking

I am working on a simple binary search algorithm in rust. It returns an Option<usize> and I am trying to pattern match on the return value. My code curren

HashMap with key referring a field in the value [duplicate]

I want to create a hash map from a vector of entities. I want the key to be a reference to a field in the corresponding value. This is somethi

How to use if let statement with conditions?

I know it's possible to express AND logic between if let statement and a condition like this if let (Some(a), true) = (b, c == d) { // do something } But w

Loading wkhtmltopdf DLL (`wkhtmltox.dll`) on Windows

I have installed wkhtmltopdf using the Windows installer and am using the wkhtmltopdf crate. wkhtmltopdf is installed at C:\Program Files\wkhtmltopdf, which con

How Can I Hash By A Raw Pointer?

I want to create a function that provides a two step write and commit, like so: // Omitting locking for brevity struct States { commited_state: u64, //

Create macro to simplify declaration of deeply nested enum?

I want to use deeply nested enums to represent blocks in my game: enum Element { Void, Materal(Material) } enum Material { Gas(Gas), NonGas(NonGas) } enum NonGa

Check 2 keys for Vacant

I am using the HashMap to store some of the value. Now I want to check whether HashMap contains keys, if not insert data else return HashMap is not empty. Below

Explicit lifetime annotations toy example

I'm trying to figure out a Rust lifetime issue and after boiling it down a bunch, I realized that I have no idea how I would explicitly annotate the lifetimes o

Lifetime on a single argument function

I've read the Rust Book and some other tutorials on lifetimes. I thought I was understanding lifetimes as like a generic parameter that a function takes, and th

Rust generic value memory store implementation

I am working on an API for an object store, and I am struggling to figure out a way to implement it in Rust. It is a bit frustrating, since I have a good idea o

Path always returning false when trying to manually put a path with Rust

I've been learning Rust, and I'm having a bit of a problem with this code. let path = Path::new(&return_path); // return path is the user input println!("{