musicus/src/backend/client/instruments.rs

19 lines
582 B
Rust
Raw Normal View History

2020-11-28 23:07:31 +01:00
use super::Backend;
use crate::database::Instrument;
use anyhow::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)
}
2020-11-29 01:00:19 +01:00
/// Post a new instrument to the server.
2020-11-28 23:07:31 +01:00
pub async fn post_instrument(&self, data: &Instrument) -> Result<()> {
self.post("instruments", serde_json::to_string(data)?).await?;
Ok(())
}
}