Category "rust"

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

Is there an idiomatic way to have a generic over T, &T, Box<T>, Arc<T>, and so forth, where T implements some trait R?

Let's say you have a structure that you want to be a generic over time type T, so long as that type implements some trait R. That's pretty trivial: trait R {

Lifetime of structure's object is shorter than lifetime of structure's member

I have some trouble to correctly understand lifetime concept in Rust. Especially in reference to structure's object itself and structure's member. Following min

How to implement !Send or !Sync for a type?

Is it possible to explicitly mark a type with unimplemented Send or Sync marker traits without some redundant fields? This can be an alternative: struct T {

LLDB prints `i8` as "signed char"

I'm using the LLDB extension for VSCode, and my variables typed as i8 are printed as characters. Both in the VSCode debugging panel, and when using print in the

Trouble implementing custom IntoIterator trait

I'm new to rust, so forgive me if the question is naive. I'm trying to build an OS in rust and I'm following this tutorial. The OS doesn't have memory managemen

Mixing anyhow::Result with std::io::Result

Can anyone help me understand why this code compiles fine: use actix_web::{App, HttpServer}; use anyhow::Result; mod error; #[actix_rt::main] async fn main()

How to compose warp log?

I am pretty new in Rust and trying to build a web application with https://docs.rs/warp/0.2.3/warp/index.html. I have tried: #[tokio::main] async fn main()

Why does my string not match when reading user input from stdin?

I'm trying to get user input and check if the user put in "y" or "n". Surprisingly, in the below code, neither the if nor the if else case executes! Apparently,

Rust thrussh library client example fails at channel_open_session

In thrussh's documentation they have server and client example code. Code based on the example server code has been working fine in various projects. However,

How do I print a backtrace without panicking using thiserror?

I am running a Rust warp webserver and I need more descriptive error messages. I'd like to print a backtrace or something similar so I can tell where the error

Why is rust-analyzer not finding dependencies in workspace member?

I have a cargo workspace with one library "./raytracing" and one binary "./cli". The two workspace members have different dependencies. ./raytracing/Cargo.toml: