2021-02-04 21:47:22 +01:00
|
|
|
use crate::{Client, Result};
|
|
|
|
|
use musicus_database::Instrument;
|
2020-11-28 23:07:31 +01:00
|
|
|
|
2021-02-04 21:47:22 +01:00
|
|
|
impl Client {
|
2020-11-28 23:07:31 +01:00
|
|
|
/// 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(())
|
|
|
|
|
}
|
|
|
|
|
}
|