mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
16 lines
560 B
Rust
16 lines
560 B
Rust
use crate::backend::{Backend, Instrument, Result};
|
|
|
|
impl Backend {
|
|
/// Get all available instruments from the server.
|
|
pub async fn get_instruments(&self) -> Result<Vec<Instrument>> {
|
|
let body = self.get("instruments").await?;
|
|
let instruments: Vec<Instrument> = serde_json::from_str(&body)?;
|
|
Ok(instruments)
|
|
}
|
|
|
|
/// Post a new instrument to the server.
|
|
pub async fn post_instrument(&self, data: &Instrument) -> Result<()> {
|
|
self.post("instruments", serde_json::to_string(data)?).await?;
|
|
Ok(())
|
|
}
|
|
}
|