Questions tagged [rust-crates]

Crates are the unit of compilation in Rust.

Crates are the unit of compilation in , and the basic building block of its system.

The crates can be published in crates.io, the official Rust packages registry, where you can browse them.

206 questions
1
vote
1 answer

Why does solicit 0.4.4 attempt to use openssl 0.9.12 even though I have openssl 0.7.14 in my Cargo.toml?

I have a simple project using the Solicit example to make a request with HTTPS. My Cargo.toml has: [package] name = "test" version = "0.1.0" authors = ["einchear"] [dependencies.openssl] version = "0.7.14" features = ["tlsv1_2",…
Deoxyseia
  • 1,359
  • 18
  • 29
1
vote
2 answers

Compiling `core` from a specific source using Xargo

Based on this comment, it should be possible to use Xargo to manage the installation of a custom core crate for a particular target. I've tried the following to get it working with a crate that has no other dependency except core: Cargo.toml: no…
Cactus
  • 27,075
  • 9
  • 69
  • 149
1
vote
0 answers

Creating a Rust library with multiple modules which all are a unified API

I have an exercise library to learn Rust. This library provides two kinds of methods: core methods which should be in a file called renderay_core.rs. shape methods which use the core methods to have a higher abstraction/more concrete implementation…
xetra11
  • 7,671
  • 14
  • 84
  • 159
1
vote
2 answers

How to import a crate as a sub module?

I'd like to import a crate into my library, and then use that crate as if it's a module in my library. If I do this: extern crate sdl2; pub use sdl2; That gives me an error, suggesting I use sdl2::*, but I don't want to drag all the names from the…
Benjamin Lindley
  • 101,917
  • 9
  • 204
  • 274
1
vote
1 answer

How to define a multi level crate?

I'm trying to define the crate going along with my Rust application as explained in the documentation. Let's take the following directory structure: src/ ├─ lib.rs ├─ main.rs └─ myapp/ ├─ a/ │ ├─ a1.rs │ └─ mod.rs └─ mod.rs Now I defined…
Spack
  • 464
  • 4
  • 22
1
vote
1 answer

std::sync::Arc of trait in Rust

I am trying to implement library for making TCP servers. This is very simplified code with a problem: #![crate_name="http_server2"] #![crate_type="lib"] use std::io::{TcpListener, Listener, Acceptor, TcpStream, IoResult, Reader, Writer}; use…
Vladimir Lagunov
  • 1,895
  • 15
  • 15
1
vote
1 answer

No hash nor version when generating rlib

In both official docs and on rustbyexample.com it is stated that when compiling a library (--crate-type=lib) the generated library file will have a hash in their filename, like libworld--0.42.rlib. But when trying on my box it doesn't generate…
talles
  • 14,356
  • 8
  • 45
  • 58
1
vote
1 answer

Is it possible to have a module in different source files in Rust

This is actually a two part question: Can I have a single module in separate files in Rust? This is my file layout. Is it possible to have a single logging module and have a set of structs/traits to be defined inside this module, but in separate…
Valentin V
  • 24,971
  • 33
  • 103
  • 152
0
votes
0 answers

How to derive a trait for a struct if every member of it implements that trait?

It's similar to the spirit of SIMD. I have multiple structs that implement a trait, and I want to wrap instances of them in a composite struct, the latter of which implement the trait, too, by calling the methods on each member. Is there a crate for…
Fifnmar
  • 372
  • 1
  • 5
  • 9
0
votes
1 answer

&str not converted into StyleSource implicitly in rust stylist

I am trying out yew and stylist for the first time in rust. As per the tutorials, i should be able to convert &str into the required type, but it produces the error given as: the trait `From<&str>` is not implemented for `StyleSource` The error is…
0
votes
1 answer

No external crate `erc721`

I am very new to rust so a lot of things are still not fully clear to me. I have two dependencies in my cargo.toml: [dependencies] erc721 = "3.0.0" soroban-sdk = "0.9.2" And I'm importing them into my lib.rs like this: #![no_std] use…
0
votes
1 answer

Rust confusion about specific package #2

Still trying to run this script here. And still a Rustacean learner. Yesterday I had a problem with the docx_rs/docx-rs crate. Enlightenment from at54321. But the script still doesn't run. It appears to have a problem with a crate called clap. D:\My…
mike rodent
  • 14,126
  • 11
  • 103
  • 157
0
votes
0 answers

Why do I keep on getting an error message even though libssl-dev is installed?

I have a rust project that uses the below crate. reqwest = { version = "0.11.18", features = ["blocking", "json"] } In order to make it work, I installed "libssl-dev" using the below command in the terminal. sudo apt install libssl-dev However,…
Saad
  • 33
  • 5
0
votes
1 answer

how to access prom lib.rs from main.rs of pilot

I have a project that have peach (library) and pilot (binary) directories directory structure peach / src / lib.rs peach / prom / src / lib.rs pilot / src / main.rs main.rs of pilot- fn main() { println!("Hello, world!"); …
0
votes
2 answers

Can two crates in the same project have a module with same name?

I was trying to create two modules with the same name for different crates, and was surprised that when declaring the second module, it was pointing to the code of the first. Does this mean that module definitions are coupled to the file hierarchy…
aryzing
  • 4,982
  • 7
  • 39
  • 42