mastodon-async/examples/search.rs

37 lines
914 B
Rust
Raw Permalink Normal View History

2022-11-27 14:44:43 +00:00
#![cfg_attr(not(feature = "toml"), allow(dead_code))]
#![cfg_attr(not(feature = "toml"), allow(unused_imports))]
mod register;
2022-12-22 18:19:49 +00:00
use mastodon_async::Result;
2022-11-27 14:44:43 +00:00
#[cfg(feature = "toml")]
async fn run() -> Result<()> {
let mastodon = register::get_mastodon_data().await?;
2022-11-27 14:44:43 +00:00
let input = register::read_line("Enter the term you'd like to search: ")?;
let result = mastodon.search(&input, false).await?;
2022-11-27 14:44:43 +00:00
println!("{:#?}", result);
Ok(())
}
#[cfg(all(feature = "toml", feature = "mt"))]
#[tokio::main]
async fn main() -> Result<()> {
run().await
}
#[cfg(all(feature = "toml", not(feature = "mt")))]
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> {
run().await
}
2022-11-27 14:44:43 +00:00
#[cfg(not(feature = "toml"))]
fn main() {
println!(
"examples require the `toml` feature, run this command for this example:\n\ncargo run \
--example search --features toml\n"
);
}