musicus/client/src/ensembles.rs

18 lines
547 B
Rust
Raw Normal View History

2021-02-04 21:47:22 +01:00
use crate::{Client, Result};
use musicus_database::Ensemble;
2020-11-28 22:23:35 +01:00
2021-02-04 21:47:22 +01:00
impl Client {
2020-11-28 22:23:35 +01:00
/// Get all available ensembles from the server.
pub async fn get_ensembles(&self) -> Result<Vec<Ensemble>> {
let body = self.get("ensembles").await?;
let ensembles: Vec<Ensemble> = serde_json::from_str(&body)?;
Ok(ensembles)
}
2020-11-29 01:00:19 +01:00
/// Post a new ensemble to the server.
2020-11-28 22:23:35 +01:00
pub async fn post_ensemble(&self, data: &Ensemble) -> Result<()> {
self.post("ensembles", serde_json::to_string(data)?).await?;
Ok(())
}
}