Update gtk-rs crates

This commit is contained in:
Elias Projahn 2021-05-07 23:49:05 +02:00
parent df6e2e86c7
commit 7d7343ea8c
63 changed files with 3499 additions and 908 deletions

View file

@ -31,6 +31,4 @@ pub enum Error {
Other(&'static str),
}
pub type Result<T> = std::result::Result<T, Error>;

View file

@ -14,7 +14,8 @@ impl Client {
/// Post a new instrument to the server.
pub async fn post_instrument(&self, data: &Instrument) -> Result<()> {
info!("Post instrument {:?}", data);
self.post("instruments", serde_json::to_string(data)?).await?;
self.post("instruments", serde_json::to_string(data)?)
.await?;
Ok(())
}
}

View file

@ -1,10 +1,10 @@
use isahc::{AsyncBody, Request, Response};
use isahc::http::StatusCode;
use isahc::prelude::*;
use isahc::{AsyncBody, Request, Response};
use log::info;
use serde::Serialize;
use std::time::Duration;
use std::cell::RefCell;
use std::time::Duration;
pub mod ensembles;
pub use ensembles::*;
@ -112,7 +112,7 @@ impl Client {
.body(())?
.send_async()
.await?;
match response.status() {
StatusCode::OK => Ok(response.text().await?),
status_code => Err(Error::UnexpectedResponse(status_code)),
@ -164,16 +164,21 @@ impl Client {
/// Require the server URL to be set.
fn server_url(&self) -> Result<String> {
self.get_server_url().ok_or(Error::Other("The server URL is not available!"))
self.get_server_url()
.ok_or(Error::Other("The server URL is not available!"))
}
/// Require the login data to be set.
fn login_data(&self) -> Result<LoginData> {
self.get_login_data().ok_or(Error::Other("The login data is unset!"))
self.get_login_data()
.ok_or(Error::Other("The login data is unset!"))
}
/// Require a login token to be set.
fn token(&self) -> Result<String> {
self.token.borrow().clone().ok_or(Error::Other("No login token found!"))
self.token
.borrow()
.clone()
.ok_or(Error::Other("No login token found!"))
}
}

View file

@ -7,7 +7,9 @@ impl Client {
/// recording.
pub async fn get_mediums_for_recording(&self, recording_id: &str) -> Result<Vec<Medium>> {
info!("Get mediums for recording {}", recording_id);
let body = self.get(&format!("recordings/{}/mediums", recording_id)).await?;
let body = self
.get(&format!("recordings/{}/mediums", recording_id))
.await?;
let mediums: Vec<Medium> = serde_json::from_str(&body)?;
Ok(mediums)
}

View file

@ -14,7 +14,8 @@ impl Client {
/// Post a new recording to the server.
pub async fn post_recording(&self, data: &Recording) -> Result<()> {
info!("Post recording {:?}", data);
self.post("recordings", serde_json::to_string(data)?).await?;
self.post("recordings", serde_json::to_string(data)?)
.await?;
Ok(())
}
}

View file

@ -1,7 +1,7 @@
use crate::{Client, Result};
use isahc::Request;
use isahc::http::StatusCode;
use isahc::prelude::*;
use isahc::Request;
use log::info;
use serde::{Deserialize, Serialize};
use std::time::Duration;