Category "rust"

Why doesn't rustc infer the type based on std trait implementations?

Consider the following code: use std::net::IpAddr; pub struct Server { host: IpAddr } impl Server { fn new(host: IpAddr) -> Self { Self {ho

Use rsa-pss algorithm to sign data

I want to use RSA-PSS algorithm to sign and verify data by using rust openssl crate. But I ran into some problems. Here is my code: use openssl::sign::{Sign

How to replace all '\n' character after 'word' with 'comma' character

Trying to replace all the \n character after the word 'key2:' pattern with comma. Input String: key1:value1\nkey2:value2\nvalue22\nvalue222 Expected: key1:valu

Can macros match against constant arguments instead of literals?

Given the macro matching example, this shows how macros can match an argument. I've made very minor changes here to use numbers: macro_rules! foo { (0 =&g

What is a "projection" and how does it relate to a StreamReader?

I'm receiving RecordBatches serialized as bytes and I'm trying to de-serialize into RecordBatches. Using StreamReader::try_new() and passing in the byte data an

What is the best way to solve multiple definitions introduced by a 3rd party library? [ELF and Mach-O]

Background Imagine the situation: static library libR.a is written rust and it depends on libCXX0.a. Binary X depends on both libR.a and libCXX0.a and it is wri

Linux custom init and SIGTERM

I try to build my own init with rust language. this is my example code : use std::process::Command; fn main() { loop { println!("Welcome to custom

How decompress and unpack tar.gz archive in download process?

I need decompress and unpack big .tar.gz files (e.g. ~5Gb) in download process without save an archive file on disk. I use reqwest crate for downloading files,

how do i make custom file that acts like an secured folder that only my rust app can access, with a password

I'm making an emulated os that uses a browser to render and a abstraction of file system to allow apps to access their folders only. However, since it's an laye

Unable to Setup\Connect to AWS Lightsail TCP Server

I have created a rust tcp server framework. (https://github.com/HasinZaman/SingleThreadServer) The framework works fine without any issue on my local machine; a

cannot find type `Json` in module `content` in rust rocket

Today when I using cargo cargo 1.59.0 (49d8809dc 2022-02-10) compile the rust rustc 1.59.0 (9d1b2106e 2022-02-23) project, shows error: error[E0412]: cannot fin

the trait `anchor_lang::AccountDeserialize` is not implemented for `anchor_spl::token::Mint`

I am trying to CPI the Token Program to send spl-tokens to a wallet. For this the derive accounts in the context struct has three accounts without any attribute

Iterator next method lifetime mismatch

I'm trying to create an Iterator interface using the csv crate such that I can return a HashMap of col-name: value and am running into a lifetime error I cannot

Is there something like Rust's std::option_env in csharp?

In Rust you can inspect environment variables at compile time like so: let sha: Option<&'static str> = option_env!("CI_COMMIT_SHA"); println!("CI_COMM

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