31 lines
658 B
Rust
31 lines
658 B
Rust
use color_eyre::eyre::Result;
|
|
|
|
use crate::{context::Context, models::library::Library};
|
|
|
|
use super::action::Action;
|
|
|
|
pub struct FetchAllLibraries {}
|
|
|
|
impl Action for FetchAllLibraries {
|
|
type Input = ();
|
|
type Output = Vec<Library>;
|
|
|
|
fn new(_input: Self::Input) -> Self {
|
|
Self {}
|
|
}
|
|
|
|
fn describe(&self) -> String {
|
|
String::from("Fetching all libraries")
|
|
}
|
|
|
|
async fn execute(&self, ctx: &Context) -> Result<Self::Output> {
|
|
Ok(ctx
|
|
.client
|
|
.get_all_libraries()
|
|
.await?
|
|
.clone()
|
|
.into_iter()
|
|
.map(Into::into)
|
|
.collect())
|
|
}
|
|
}
|