Category "rust"

How to use local project files in build.rs script?

How do I use local files without including their absolute paths in build.rs? I have, for example let proto_file_glob_paths: Paths = glob("../proto/**/*.proto").

Implementing Borrow trait for a type with a lifetime

I'm trying to use. strongly typed wrapper for a "keys" in my program, so that I don't mistake arbitrary strings for a Key. I have: #[derive(Debug, Clone, Partia

Poll raw file descriptor for data

I would like to poll a raw file descriptor for data and process it as it gets written to. This needs to be done on a separate thread so that my main thread is

How to send prompt input to std::process::Command in rust?

I'm writing a cli tool for automate the archlinux installation, that is based on toml config files... Currently i have this problem... Once the base system is i

cargo install cargo-generate --features vendored-openssl failed

I am trying to install terrain from terra-money. For that, the instructions said to follow the commands. I have run these instructions on ubuntu 20.04 1. Set 's

How to use .cargo/config.toml file with both stable and nightly rust toolchain?

I have installed both nightly and stable rust toolchains and make some -Z ... compile flags for nightly, but the stable rust can't recognize it and stops compil

How to use nom to parse until a string is found?

It's easy to use nom to parse a string until a character is found. How to use nom to gobble a string until a delimiter or the end? deals with this. How do I do

Newtype pattern error: cannot move out of dereference of

I want to create a Wrapper around an existing type/struct. According to the Newtype pattern, as per Rust Book ch 19, "implementing Deref trait on the Wrapper to

Cargo error: duplicate lang item in crate `casper_contract` (which `contract` depends on): `panic_impl`

I am trying to use the standard casper demo project as generated by command "cargo casper my-project" but with some std::io. I want to read a value from the con

Problem trying to install diesel (Mac air m1)

I am following the diesel guide: LINK When i try this: cargo install diesel_cli --no-default-features --features postgres i receive this error: error: failed t

Generic lifetime parameter and local scope

piet is a drawing library with generic backends (cairo, for example). I want to have a trait Renderable that can render to any piet backend (=context). pub trai

Custom openapi schema with rust, rocket and okapi

I am developing an API with Rust, using Rocket as main framework. To create the Swagger docs I use Okapi, which allows me to create the docs automatically. use

Deserializing a struct with custom data types

I am trying to #[derive(Deserialize, Serialize)] some structs that involve other custom structs, so I can transform them in and out of JSON, for example: #[deri

How can I call a rust function in rust inline asm module

I try to call my function just like the example code: use std::arch::asm; extern "C" fn foo(arg: i32) -> i32 { println!("arg = {}", arg); arg * 2 }

Why does `Fn() -> T` constrain `T` but `Fn(T) -> T` does not

The following code compiles fine: struct StructA<F>(F); impl<F, T> StructA<F> where F: Fn() -> T {} Although T doesn't show up in StructA'

error[E0412]: cannot find type `ProgramResult` in this scope

use anchor_lang::prelude::*; declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); #[program] pub mod myepicproject { use super::*; pub fn start_st

How to call a mvsc dll (C++ or Rust) from Progress Open Edge

I have a dll that i want to call from Progress code but I can't complete. I have tried with Visual Studio 2022, Windows C++ Dll and Rust Dll. Windows C++, Visua

How to use a generic session with Actix and Paperclip?

I've created a server using Actix Web which has authentication support. Now I want to add an OpenAPI Specification using paperclip. Normally you only have to ad

Rust Tcpstream: reading http request sometimes lose the body

I am learning how to write a http server using tcpstream with rust. I use this function to read stream buffer. fn handle_connection(mut stream: TcpStream) {

How do I get past the following GTK4 build errors in Rust

I have downloaded the GTK4 demo from Github and placed it in a directory. I have opened it in VC and attempt to run the demo according to the Read.ME. I get t