Rust
!rust
help-circle
rss
[SOLVED] Having problems using crate
I've tried running [this crate](https://github.com/runfalk/ed2k-rs) and it runs fine. I've copied the code, I've modified it very little when adding it to [my project](https://git.disroot.org/hirrolot19/Jedi_Archives/src/branch/main/core/src/file/cas/ed2k/), but it's giving me a bunch of errors. Have I done something wrong when adding the repository to get so many errors? ```rust ❯ cargo test Compiling sdcore v0.1.0 (/home/user/code/rust/spacedrive/core) error[E0437]: type `OutputSize` is not a member of trait `FixedOutput` --> core/src/file/cas/ed2k/ed2k_hash.rs:71:5 | 71 | type OutputSize = typenum::U16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `FixedOutput` error[E0407]: method `finalize_into_reset` is not a member of trait `FixedOutput` --> core/src/file/cas/ed2k/ed2k_hash.rs:84:5 | 84 | fn finalize_into_reset(&mut self, out: &mut GenericArray<u8, Self::OutputSize>) { | ^ ------------------- help: there is an associated function with a similar name: `finalize_into` | _____| | | 85 | | if self.num_full_chunks == 0 { 86 | | self.md4_hasher.finalize_into_reset(out); 87 | | } else { ... | 92 | | self.current_chunk_len = 0; 93 | | } | |_____^ not a member of trait `FixedOutput` error[E0437]: type `OutputSize` is not a member of trait `FixedOutput` --> core/src/file/cas/ed2k/ed2k_hasher.rs:82:5 | 82 | type OutputSize = typenum::U16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `FixedOutput` error[E0407]: method `finalize_into_reset` is not a member of trait `FixedOutput` --> core/src/file/cas/ed2k/ed2k_hasher.rs:95:5 | 95 | fn finalize_into_reset(&mut self, out: &mut GenericArray<u8, Self::OutputSize>) { | ^ ------------------- help: there is an associated function with a similar name: `finalize_into` | _____| | | 96 | | if self.num_full_chunks == 0 { 97 | | self.md4_hasher.finalize_into_reset(out); 98 | | } else { ... | 103 | | self.current_chunk_len = 0; 104 | | } | |_____^ not a member of trait `FixedOutput` error[E0433]: failed to resolve: use of undeclared crate or module `ed2k` --> core/src/file/cas/ed2k/mod.rs:147:58 | 147 | let mut zero_chunk: Vec<u8> = Vec::with_capacity(ed2k::Ed2kHasher::CHUNK_SIZE); | ^^^^ use of undeclared crate or module `ed2k` error[E0433]: failed to resolve: use of undeclared crate or module `ed2k` --> core/src/file/cas/ed2k/mod.rs:170:58 | 170 | let mut zero_chunk: Vec<u8> = Vec::with_capacity(ed2k::Ed2kHasher::CHUNK_SIZE); | ^^^^ use of undeclared crate or module `ed2k` warning: unused import: `FixedOffset` --> core/src/file/indexer/scan.rs:3:24 | 3 | use chrono::{DateTime, FixedOffset, Utc}; | ^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unused import: `encode::ThumbnailJob` --> core/src/sys/locations.rs:2:2 | 2 | encode::ThumbnailJob, | ^^^^^^^^^^^^^^^^^^^^ warning: unused imports: `PrismaValue`, `raw` --> core/src/sys/locations.rs:8:26 | 8 | use prisma_client_rust::{raw, PrismaValue}; | ^^^ ^^^^^^^^^^^ error[E0433]: failed to resolve: use of undeclared crate or module `ed2k` --> core/src/file/cas/ed2k/mod.rs:114:32 | 114 | let mut hasher = ed2k::Ed2kHasher::new(); | ^^^^^^^^^^ not found in `ed2k` | help: consider importing this struct | 101 | use crate::file::cas::ed2k::Ed2kHasher; | error[E0433]: failed to resolve: use of undeclared crate or module `ed2k` --> core/src/file/cas/ed2k/mod.rs:152:36 | 152 | let mut hasher = ed2k::Ed2kHasher::new(); | ^^^^^^^^^^ not found in `ed2k` | help: consider importing this struct | 101 | use crate::file::cas::ed2k::Ed2kHasher; | error[E0433]: failed to resolve: use of undeclared crate or module `ed2k` --> core/src/file/cas/ed2k/mod.rs:160:36 | 160 | let mut hasher = ed2k::Ed2kHasher::new(); | ^^^^^^^^^^ not found in `ed2k` | help: consider importing this struct | 101 | use crate::file::cas::ed2k::Ed2kHasher; | error[E0433]: failed to resolve: use of undeclared crate or module `ed2k` --> core/src/file/cas/ed2k/mod.rs:175:36 | 175 | let mut hasher = ed2k::Ed2kHasher::with_legacy_hashing(true); | ^^^^^^^^^^ not found in `ed2k` | help: consider importing this struct | 101 | use crate::file::cas::ed2k::Ed2kHasher; | error[E0433]: failed to resolve: use of undeclared crate or module `ed2k` --> core/src/file/cas/ed2k/mod.rs:183:36 | 183 | let mut hasher = ed2k::Ed2kHasher::with_legacy_hashing(true); | ^^^^^^^^^^ not found in `ed2k` | help: consider importing this struct | 101 | use crate::file::cas::ed2k::Ed2kHasher; | error[E0277]: the trait bound `Ed2kHash: OutputSizeUser` is not satisfied --> core/src/file/cas/ed2k/ed2k_hash.rs:70:6 | 70 | impl FixedOutput for Ed2kHash { | ^^^^^^^^^^^ the trait `OutputSizeUser` is not implemented for `Ed2kHash` | note: required by a bound in `FixedOutput` --> /home/user/.local/share/cargo/registry/src/github.com-1ecc6299db9ec823/digest-0.10.3/src/lib.rs:91:33 | 91 | pub trait FixedOutput: Update + OutputSizeUser + Sized { | ^^^^^^^^^^^^^^ required by this bound in `FixedOutput` error[E0277]: the trait bound `Ed2kHash: OutputSizeUser` is not satisfied --> core/src/file/cas/ed2k/ed2k_hash.rs:73:59 | 73 | fn finalize_into(mut self, out: &mut GenericArray<u8, Self::OutputSize>) { | ^^^^^^^^^^^^^^^^ the trait `OutputSizeUser` is not implemented for `Ed2kHash` error[E0277]: the trait bound `Ed2kHash: OutputSizeUser` is not satisfied --> core/src/file/cas/ed2k/ed2k_hash.rs:84:66 | 84 | fn finalize_into_reset(&mut self, out: &mut GenericArray<u8, Self::OutputSize>) { | ^^^^^^^^^^^^^^^^ the trait `OutputSizeUser` is not implemented for `Ed2kHash` error[E0277]: the trait bound `Ed2kHasher: OutputSizeUser` is not satisfied --> core/src/file/cas/ed2k/ed2k_hasher.rs:81:6 | 81 | impl FixedOutput for Ed2kHasher { | ^^^^^^^^^^^ the trait `OutputSizeUser` is not implemented for `Ed2kHasher` | note: required by a bound in `FixedOutput` --> /home/user/.local/share/cargo/registry/src/github.com-1ecc6299db9ec823/digest-0.10.3/src/lib.rs:91:33 | 91 | pub trait FixedOutput: Update + OutputSizeUser + Sized { | ^^^^^^^^^^^^^^ required by this bound in `FixedOutput` error[E0277]: the trait bound `Ed2kHasher: OutputSizeUser` is not satisfied --> core/src/file/cas/ed2k/ed2k_hasher.rs:84:59 | 84 | fn finalize_into(mut self, out: &mut GenericArray<u8, Self::OutputSize>) { | ^^^^^^^^^^^^^^^^ the trait `OutputSizeUser` is not implemented for `Ed2kHasher` error[E0277]: the trait bound `Ed2kHasher: OutputSizeUser` is not satisfied --> core/src/file/cas/ed2k/ed2k_hasher.rs:95:66 | 95 | fn finalize_into_reset(&mut self, out: &mut GenericArray<u8, Self::OutputSize>) { | ^^^^^^^^^^^^^^^^ the trait `OutputSizeUser` is not implemented for `Ed2kHasher` Some errors have detailed explanations: E0277, E0407, E0437. For more information about an error, try `rustc --explain E0277`. warning: `sdcore` (lib) generated 3 warnings error: could not compile `sdcore` due to 10 previous errors; 3 warnings emitted warning: build failed, waiting for other jobs to finish... Some errors have detailed explanations: E0277, E0407, E0433, E0437. warning: `sdcore` (lib test) generated 3 warnings (3 duplicates) error: build failed ```
fedilink

Presenting Activitypub-Rust crate
cross-posted from: https://lemmy.ml/post/341718 > [Activitypub](https://www.w3.org/TR/activitypub/) is decentralized social networking protocol recommended by the W3C. It provides a client to server API for creating, updating and deleting content, as well as a federated server to server API for delivering notifications and content. As part of the work on [Lemmy](https://join-lemmy.org/), we have implemented some high-level abstractions for handling the server-to-server protocol in Rust. These abstractions are now available as a standalone library. > > The main features are: > > - Data structures for federation are defined by the user, not the library. This gives you maximal flexibility, and lets you accept only messages which your code can handle. Others are rejected automatically during deserialization. > - ObjectId type, wraps the id url and allows for type safe fetching of objects, both from database and HTTP > - Queue for activity sending, handles HTTP signatures, retry with exponential backoff, all in background workers > - Inbox for receiving activities, verifies HTTP signatures, performs other basic checks and helps with routing > - Generic error type (unfortunately this was necessary) > - various helpers for verification, (de)serialization, context etc > > Documentation is currently lacking. If you want to get started with the library, best look at the example. > > The code has already been used in production as part of Lemmy for a long time, without any notable problems. However, ergonomics are lacking and need to be improved. There are also many additional features which would be worth implementing. See the project readme for details. Contributions and suggestions are very much welcome! > > You can find the project here: > > [https://github.com/LemmyNet/activitypub-federation-rust](https://github.com/LemmyNet/activitypub-federation-rust) > > [https://crates.io/crates/activitypub-federation](https://crates.io/crates/activitypub-federation)
fedilink

E0515: Returns a value referencing data owned by the current function
I'm getting a `returns a value referencing data owned by the current function` on line 17 on `.unwrap_or("/tmp/")`. This is the first time I try something on rust after finishing the book. I still don't know enough to debug this. ``` use clap::{Arg, Command}; fn main() { args = parse_args(); println!("The directory passed is: {}", args[0]); } fn parse_args() -> Vec<&str> { let matches = Command::new("Parse Torrent") .arg(Arg::new("dir") .short('f') .long("dir") .takes_value(true) .help("input directory of your computer, example /disk1/dir1/")) .get_matches(); matches.value_of(dir).unwrap_or("/tmp/") } ```
fedilink

Ask specific questions about how to code something in rust

Rust Docs

General rust discussion on lemmy.ml

Create Post From:
lemmy.ml

  • 0 users online
  • 2 users / day
  • 2 users / week
  • 2 users / month
  • 2 users / 6 months
  • 15 subscribers
  • 3 Posts
  • 1 Comment
  • Modlog