Skip to content

Difficulties in the record_wav.rs example #757

@JContro

Description

@JContro

Hi, if I try and run the record_wav.rs code, I get the following errors. I am relatively new to rust, which is why i am finding it difficult.

Here is the error:

error: cannot find derive macro Parserin this scope --> src/main.rs:9:10 | 9 | #[derive(Parser, Debug)] | ^^^^^^ | note:Parser` is imported here, but it is only a trait, without a derive macro
--> src/main.rs:2:5
|
2 | use clap::Parser;
| ^^^^^^^^^^^^

error: cannot find attribute command in this scope
--> src/main.rs:10:3
|
10 | #[command(version, about = "CPAL record_wav example", long_about = None)]
| ^^^^^^^

error: cannot find attribute arg in this scope
--> src/main.rs:13:7
|
13 | #[arg(short, long, default_value_t = String::from("default"))]
| ^^^

error[E0433]: failed to resolve: use of undeclared crate or module anyhow
--> src/main.rs:31:25
|
31 | fn main() -> Result<(), anyhow::Error> {
| ^^^^^^ use of undeclared crate or module anyhow

error[E0433]: failed to resolve: use of undeclared crate or module anyhow
--> src/main.rs:126:32
|
126 | return Err(anyhow::Error::msg(format!(
| ^^^^^ not found in anyhow
|
help: consider importing one of these items
|
2 | use clap::Error;
|
2 | use clap::error::Error;
|
2 | use core::error::Error;
|
2 | use core::fmt::Error;
|
and 4 other candidates
help: if you import Error, refer to it directly
|
126 - return Err(anyhow::Error::msg(format!(
126 + return Err(Error::msg(format!(
|

error[E0599]: no function or associated item named parse found for struct Opt in the current scope
--> src/main.rs:32:20
|
11 | struct Opt {
| ---------- function or associated item parse not found for this struct
...
32 | let opt = Opt::parse();
| ^^^^^ function or associated item not found in Opt
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following traits define an item parse, perhaps you need to implement one of them:
candidate #1: Parser
candidate #2: TypedValueParser

warning: unused import: StreamTrait
--> src/main.rs:3:44
|
3 | use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
| ^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default

Some errors have detailed explanations: E0433, E0599.
For more information about an error, try rustc --explain E0433.`

And this is my cargo.toml

[dependencies]
clap = "4.1.6"
cpal = "0.15.0"
ringbuf = "0.3.2"
hound = "3.5.0"

All in all, I am just looking to record some audio from the default audio interface.

Any help would be hugely appreciated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions