mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-05-19 22:07:57 -04:00
Update toolchain and fix a bunch of warnings
This commit is contained in:
BIN
Cargo.lock
generated
BIN
Cargo.lock
generated
Binary file not shown.
@@ -30,7 +30,6 @@ sd-core-sync = { path = "./crates/sync" }
|
||||
# Spacedrive Sub-crates
|
||||
sd-actors = { path = "../crates/actors" }
|
||||
sd-ai = { path = "../crates/ai", optional = true }
|
||||
sd-cloud-api = { path = "../crates/cloud-api" }
|
||||
sd-crypto = { path = "../crates/crypto" }
|
||||
sd-ffmpeg = { path = "../crates/ffmpeg", optional = true }
|
||||
sd-file-ext = { path = "../crates/file-ext" }
|
||||
|
||||
@@ -18,7 +18,7 @@ use super::{
|
||||
error::Error, key_manager::KeyManager, p2p::CloudP2P, token_refresher::TokenRefresher,
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug, Default, Clone)]
|
||||
enum ClientState {
|
||||
#[default]
|
||||
NotConnected,
|
||||
@@ -190,7 +190,8 @@ impl CloudServices {
|
||||
_message: &[u8],
|
||||
_cert: &rustls::pki_types::CertificateDer<'_>,
|
||||
_dss: &rustls::DigitallySignedStruct,
|
||||
) -> Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error> {
|
||||
) -> Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error>
|
||||
{
|
||||
Ok(rustls::client::danger::HandshakeSignatureValid::assertion())
|
||||
}
|
||||
|
||||
@@ -199,7 +200,8 @@ impl CloudServices {
|
||||
_message: &[u8],
|
||||
_cert: &rustls::pki_types::CertificateDer<'_>,
|
||||
_dss: &rustls::DigitallySignedStruct,
|
||||
) -> Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error> {
|
||||
) -> Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error>
|
||||
{
|
||||
Ok(rustls::client::danger::HandshakeSignatureValid::assertion())
|
||||
}
|
||||
|
||||
@@ -268,8 +270,8 @@ impl CloudServices {
|
||||
/// Available routes documented in
|
||||
/// [`sd_cloud_schema::Service`](https://github.com/spacedriveapp/cloud-services-schema).
|
||||
pub async fn client(&self) -> Result<Client<QuinnConnection<Service>, Service>, Error> {
|
||||
if let ClientState::Connected(client) = &*self.client_state.read().await {
|
||||
return Ok(client.clone());
|
||||
if let ClientState::Connected(client) = { self.client_state.read().await.clone() } {
|
||||
return Ok(client);
|
||||
}
|
||||
|
||||
// If we're not connected, we need to try to connect.
|
||||
|
||||
@@ -33,7 +33,7 @@ pub struct KeyStore {
|
||||
}
|
||||
|
||||
impl KeyStore {
|
||||
pub fn new(iroh_secret_key: IrohSecretKey) -> Self {
|
||||
pub const fn new(iroh_secret_key: IrohSecretKey) -> Self {
|
||||
Self {
|
||||
iroh_secret_key,
|
||||
keys: BTreeMap::new(),
|
||||
|
||||
@@ -82,7 +82,7 @@ enum IngestStatus {
|
||||
}
|
||||
|
||||
impl Ingester {
|
||||
pub fn new(
|
||||
pub const fn new(
|
||||
sync: SyncManager,
|
||||
ingest_notify: Arc<Notify>,
|
||||
active: Arc<AtomicBool>,
|
||||
|
||||
@@ -402,7 +402,7 @@ impl ReportBuilder {
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn new(id: JobId, name: JobName) -> Self {
|
||||
pub const fn new(id: JobId, name: JobName) -> Self {
|
||||
Self {
|
||||
id,
|
||||
name,
|
||||
|
||||
@@ -47,7 +47,7 @@ pub async fn update_library_statistics(
|
||||
node.config
|
||||
.data_directory()
|
||||
.join("libraries")
|
||||
.join(&format!("{}.db", library.id)),
|
||||
.join(format!("{}.db", library.id)),
|
||||
)
|
||||
.await
|
||||
.unwrap_or(0);
|
||||
|
||||
@@ -67,6 +67,8 @@ type Handler = ios::EventHandler;
|
||||
pub(super) type IgnorePath = (PathBuf, bool);
|
||||
|
||||
type INode = u64;
|
||||
|
||||
#[cfg(any(target_os = "ios", target_os = "macos", target_os = "windows"))]
|
||||
type InstantAndPath = (Instant, PathBuf);
|
||||
|
||||
const ONE_SECOND: Duration = Duration::from_secs(1);
|
||||
|
||||
@@ -169,7 +169,8 @@ impl<Id: ActorId> ActorsCollection<Id> {
|
||||
|
||||
#[instrument(skip(self))]
|
||||
pub async fn start(&self, identifier: Id) {
|
||||
if let Some(actor) = self.actors_map.write().await.get_mut(&identifier) {
|
||||
let mut actors_map = self.actors_map.write().await;
|
||||
if let Some(actor) = actors_map.get_mut(&identifier) {
|
||||
if actor.is_running.load(Ordering::Acquire) {
|
||||
warn!("Actor already running!");
|
||||
return;
|
||||
@@ -223,7 +224,8 @@ impl<Id: ActorId> ActorsCollection<Id> {
|
||||
|
||||
#[instrument(skip(self))]
|
||||
pub async fn stop(&self, identifier: Id) {
|
||||
if let Some(actor) = self.actors_map.write().await.get_mut(&identifier) {
|
||||
let mut actors_map = self.actors_map.write().await;
|
||||
if let Some(actor) = actors_map.get_mut(&identifier) {
|
||||
if !actor.is_running.load(Ordering::Acquire) {
|
||||
warn!("Actor already stopped!");
|
||||
return;
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
[package]
|
||||
name = "sd-cloud-api"
|
||||
version = "0.1.0"
|
||||
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[dependencies]
|
||||
# Spacedrive Sub-crates
|
||||
sd-p2p = { path = "../p2p" }
|
||||
|
||||
# Workspace dependencies
|
||||
reqwest = { workspace = true, features = ["native-tls-vendored"] }
|
||||
rspc = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
specta = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
uuid = { workspace = true }
|
||||
@@ -1,17 +0,0 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct OAuthToken {
|
||||
pub access_token: String,
|
||||
pub refresh_token: String,
|
||||
pub token_type: String,
|
||||
pub expires_in: i32,
|
||||
}
|
||||
|
||||
impl OAuthToken {
|
||||
pub fn to_header(&self) -> String {
|
||||
format!("{} {}", self.token_type, self.access_token)
|
||||
}
|
||||
}
|
||||
|
||||
pub const DEVICE_CODE_URN: &str = "urn:ietf:params:oauth:grant-type:device_code";
|
||||
@@ -1,636 +0,0 @@
|
||||
pub mod auth;
|
||||
|
||||
use std::{collections::HashMap, future::Future, sync::Arc};
|
||||
|
||||
use auth::OAuthToken;
|
||||
use sd_p2p::RemoteIdentity;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
use specta::Type;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub struct RequestConfig {
|
||||
pub client: reqwest::Client,
|
||||
pub api_url: String,
|
||||
pub auth_token: Option<auth::OAuthToken>,
|
||||
}
|
||||
|
||||
pub trait RequestConfigProvider {
|
||||
fn get_request_config(self: &Arc<Self>) -> impl Future<Output = RequestConfig> + Send;
|
||||
}
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
#[error("{0}")]
|
||||
pub struct Error(String);
|
||||
|
||||
impl From<Error> for rspc::Error {
|
||||
fn from(e: Error) -> rspc::Error {
|
||||
rspc::Error::new(rspc::ErrorCode::InternalServerError, e.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Type)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[specta(rename = "CloudLibrary")]
|
||||
pub struct Library {
|
||||
pub id: String,
|
||||
pub uuid: Uuid,
|
||||
pub name: String,
|
||||
pub instances: Vec<Instance>,
|
||||
pub owner_id: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Type)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[specta(rename = "CloudInstance")]
|
||||
pub struct Instance {
|
||||
pub id: String,
|
||||
pub uuid: Uuid,
|
||||
pub identity: RemoteIdentity,
|
||||
#[serde(rename = "nodeId")]
|
||||
pub node_id: Uuid,
|
||||
pub node_remote_identity: String,
|
||||
pub metadata: HashMap<String, String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Type)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[specta(rename = "CloudMessageCollection")]
|
||||
pub struct MessageCollection {
|
||||
pub instance_uuid: Uuid,
|
||||
pub start_time: String,
|
||||
pub end_time: String,
|
||||
pub contents: String,
|
||||
}
|
||||
|
||||
trait WithAuth {
|
||||
fn with_auth(self, token: OAuthToken) -> Self;
|
||||
}
|
||||
|
||||
impl WithAuth for reqwest::RequestBuilder {
|
||||
fn with_auth(self, token: OAuthToken) -> Self {
|
||||
self.header(
|
||||
"authorization",
|
||||
format!("{} {}", token.token_type, token.access_token),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub mod feedback {
|
||||
use super::*;
|
||||
|
||||
pub use send::exec as send;
|
||||
pub mod send {
|
||||
use super::*;
|
||||
|
||||
pub async fn exec(config: RequestConfig, message: String, emoji: u8) -> Result<(), Error> {
|
||||
let mut req = config
|
||||
.client
|
||||
.post(format!("{}/api/v1/feedback", config.api_url))
|
||||
.json(&json!({
|
||||
"message": message,
|
||||
"emoji": emoji,
|
||||
}));
|
||||
|
||||
if let Some(auth_token) = config.auth_token {
|
||||
req = req.with_auth(auth_token);
|
||||
}
|
||||
|
||||
req.send()
|
||||
.await
|
||||
.and_then(|r| r.error_for_status())
|
||||
.map_err(|e| Error(e.to_string()))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod user {
|
||||
use super::*;
|
||||
|
||||
pub use me::exec as me;
|
||||
pub mod me {
|
||||
use super::*;
|
||||
|
||||
#[derive(Serialize, Deserialize, Type)]
|
||||
#[specta(inline)]
|
||||
pub struct Response {
|
||||
id: String,
|
||||
email: String,
|
||||
}
|
||||
|
||||
pub async fn exec(config: RequestConfig) -> Result<Response, Error> {
|
||||
let Some(auth_token) = config.auth_token else {
|
||||
return Err(Error("Authentication required".to_string()));
|
||||
};
|
||||
|
||||
config
|
||||
.client
|
||||
.get(&format!("{}/api/v1/user/me", config.api_url))
|
||||
.with_auth(auth_token)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))?
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod library {
|
||||
use super::*;
|
||||
|
||||
pub use get::exec as get;
|
||||
pub mod get {
|
||||
use super::*;
|
||||
|
||||
pub async fn exec(config: RequestConfig, library_id: Uuid) -> Result<Response, Error> {
|
||||
let Some(auth_token) = config.auth_token else {
|
||||
return Err(Error("Authentication required".to_string()));
|
||||
};
|
||||
|
||||
config
|
||||
.client
|
||||
.get(&format!(
|
||||
"{}/api/v1/libraries/{}",
|
||||
config.api_url, library_id
|
||||
))
|
||||
.with_auth(auth_token)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))?
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))
|
||||
}
|
||||
|
||||
pub type Response = Option<Library>;
|
||||
}
|
||||
|
||||
pub use list::exec as list;
|
||||
pub mod list {
|
||||
use super::*;
|
||||
|
||||
pub async fn exec(config: RequestConfig) -> Result<Response, Error> {
|
||||
let Some(auth_token) = config.auth_token else {
|
||||
return Err(Error("Authentication required".to_string()));
|
||||
};
|
||||
|
||||
config
|
||||
.client
|
||||
.get(&format!("{}/api/v1/libraries", config.api_url))
|
||||
.with_auth(auth_token)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))?
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))
|
||||
}
|
||||
|
||||
pub type Response = Vec<Library>;
|
||||
}
|
||||
|
||||
pub use create::exec as create;
|
||||
pub mod create {
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct CreateResult {
|
||||
pub id: String,
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn exec(
|
||||
config: RequestConfig,
|
||||
library_id: Uuid,
|
||||
name: &str,
|
||||
instance_uuid: Uuid,
|
||||
instance_identity: RemoteIdentity,
|
||||
node_id: Uuid,
|
||||
node_remote_identity: RemoteIdentity,
|
||||
metadata: &HashMap<String, String>,
|
||||
) -> Result<CreateResult, Error> {
|
||||
let Some(auth_token) = config.auth_token else {
|
||||
return Err(Error("Authentication required".to_string()));
|
||||
};
|
||||
|
||||
config
|
||||
.client
|
||||
.post(&format!(
|
||||
"{}/api/v1/libraries/{}",
|
||||
config.api_url, library_id
|
||||
))
|
||||
.json(&json!({
|
||||
"name":name,
|
||||
"instanceUuid": instance_uuid,
|
||||
"instanceIdentity": instance_identity,
|
||||
"nodeId": node_id,
|
||||
"nodeRemoteIdentity": node_remote_identity,
|
||||
"metadata": metadata,
|
||||
}))
|
||||
.with_auth(auth_token)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))?
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
pub use update::exec as update;
|
||||
pub mod update {
|
||||
use super::*;
|
||||
|
||||
pub async fn exec(
|
||||
config: RequestConfig,
|
||||
library_id: Uuid,
|
||||
name: Option<String>,
|
||||
) -> Result<(), Error> {
|
||||
let Some(auth_token) = config.auth_token else {
|
||||
return Err(Error("Authentication required".to_string()));
|
||||
};
|
||||
|
||||
config
|
||||
.client
|
||||
.patch(&format!(
|
||||
"{}/api/v1/libraries/{}",
|
||||
config.api_url, library_id
|
||||
))
|
||||
.json(&json!({
|
||||
"name":name
|
||||
}))
|
||||
.with_auth(auth_token)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))
|
||||
.map(|_| ())
|
||||
}
|
||||
}
|
||||
|
||||
pub use update_instance::exec as update_instance;
|
||||
pub mod update_instance {
|
||||
use super::*;
|
||||
|
||||
pub async fn exec(
|
||||
config: RequestConfig,
|
||||
library_id: Uuid,
|
||||
instance_id: Uuid,
|
||||
node_id: Option<Uuid>,
|
||||
node_remote_identity: Option<RemoteIdentity>,
|
||||
metadata: Option<HashMap<String, String>>,
|
||||
) -> Result<(), Error> {
|
||||
let Some(auth_token) = config.auth_token else {
|
||||
return Err(Error("Authentication required".to_string()));
|
||||
};
|
||||
|
||||
config
|
||||
.client
|
||||
.patch(&format!(
|
||||
"{}/api/v1/libraries/{}/{}",
|
||||
config.api_url, library_id, instance_id
|
||||
))
|
||||
.json(&json!({
|
||||
"nodeId": node_id,
|
||||
"nodeRemoteIdentity": node_remote_identity,
|
||||
"metadata": metadata,
|
||||
}))
|
||||
.with_auth(auth_token)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))
|
||||
.map(|_| ())
|
||||
}
|
||||
}
|
||||
|
||||
pub use join::exec as join;
|
||||
pub mod join {
|
||||
use super::*;
|
||||
|
||||
pub async fn exec(
|
||||
config: RequestConfig,
|
||||
library_id: Uuid,
|
||||
instance_uuid: Uuid,
|
||||
instance_identity: RemoteIdentity,
|
||||
node_id: Uuid,
|
||||
node_remote_identity: RemoteIdentity,
|
||||
metadata: HashMap<String, String>,
|
||||
) -> Result<Vec<Instance>, Error> {
|
||||
let Some(auth_token) = config.auth_token else {
|
||||
return Err(Error("Authentication required".to_string()));
|
||||
};
|
||||
|
||||
config
|
||||
.client
|
||||
.post(&format!(
|
||||
"{}/api/v1/libraries/{library_id}/instances/{instance_uuid}",
|
||||
config.api_url
|
||||
))
|
||||
.json(&json!({
|
||||
"instanceIdentity": instance_identity,
|
||||
"nodeId": node_id,
|
||||
"nodeRemoteIdentity": node_remote_identity,
|
||||
"metadata": metadata,
|
||||
}))
|
||||
.with_auth(auth_token)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))?
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
pub mod message_collections {
|
||||
use super::*;
|
||||
|
||||
pub use get::exec as get;
|
||||
pub mod get {
|
||||
use super::*;
|
||||
use tracing::debug;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct InstanceTimestamp {
|
||||
pub instance_uuid: Uuid,
|
||||
pub from_time: String,
|
||||
}
|
||||
|
||||
pub async fn exec(
|
||||
config: RequestConfig,
|
||||
library_id: Uuid,
|
||||
this_instance_uuid: Uuid,
|
||||
timestamps: Vec<InstanceTimestamp>,
|
||||
) -> Result<Response, Error> {
|
||||
let Some(auth_token) = config.auth_token else {
|
||||
return Err(Error("Authentication required".to_string()));
|
||||
};
|
||||
|
||||
let res = config
|
||||
.client
|
||||
.post(&format!(
|
||||
"{}/api/v1/libraries/{}/messageCollections/get",
|
||||
config.api_url, library_id
|
||||
))
|
||||
.json(&json!({
|
||||
"instanceUuid": this_instance_uuid,
|
||||
"timestamps": timestamps
|
||||
}))
|
||||
.with_auth(auth_token)
|
||||
.send()
|
||||
.await;
|
||||
|
||||
debug!("get message collections response: {:?}", res);
|
||||
|
||||
match res {
|
||||
Ok(response) => {
|
||||
let status = response.status();
|
||||
let body = response.text().await.map_err(|e| Error(e.to_string()))?;
|
||||
debug!("Response status: {}", status);
|
||||
debug!("Response body: {}", body);
|
||||
|
||||
// Attempt to parse the body as JSON
|
||||
match serde_json::from_str::<Response>(&body) {
|
||||
Ok(json) => Ok(json),
|
||||
Err(e) => Err(Error(format!(
|
||||
"error decoding response body: {}. Body: {}",
|
||||
e, body
|
||||
))),
|
||||
}
|
||||
}
|
||||
Err(e) => Err(Error(e.to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
pub type Response = Vec<MessageCollection>;
|
||||
}
|
||||
|
||||
pub use request_add::exec as request_add;
|
||||
pub mod request_add {
|
||||
use super::*;
|
||||
use tracing::debug;
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RequestAdd {
|
||||
pub instance_uuid: Uuid,
|
||||
pub from_time: Option<String>,
|
||||
// mutex key on the instance
|
||||
pub key: String,
|
||||
}
|
||||
|
||||
pub async fn exec(
|
||||
config: RequestConfig,
|
||||
library_id: Uuid,
|
||||
instances: Vec<Uuid>,
|
||||
) -> Result<Response, Error> {
|
||||
let Some(auth_token) = config.auth_token else {
|
||||
return Err(Error("Authentication required".to_string()));
|
||||
};
|
||||
|
||||
let instances = instances
|
||||
.into_iter()
|
||||
.map(|i| json!({"instanceUuid": i }))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let res = config
|
||||
.client
|
||||
.post(&format!(
|
||||
"{}/api/v1/libraries/{}/messageCollections/requestAdd",
|
||||
config.api_url, library_id
|
||||
))
|
||||
.json(&json!({ "instances": instances }))
|
||||
.with_auth(auth_token)
|
||||
.send()
|
||||
.await;
|
||||
|
||||
debug!("request add response: {:?}", res);
|
||||
|
||||
match res {
|
||||
Ok(response) => {
|
||||
let status = response.status();
|
||||
let body = response.text().await.map_err(|e| Error(e.to_string()))?;
|
||||
debug!("Response status: {}", status);
|
||||
debug!("Response body: {}", body);
|
||||
|
||||
// Attempt to parse the body as JSON
|
||||
match serde_json::from_str::<Response>(&body) {
|
||||
Ok(json) => Ok(json),
|
||||
Err(e) => Err(Error(format!(
|
||||
"error decoding response body: {}. Body: {}",
|
||||
e, body
|
||||
))),
|
||||
}
|
||||
}
|
||||
Err(e) => Err(Error(e.to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
pub type Response = Vec<RequestAdd>;
|
||||
}
|
||||
|
||||
pub use do_add::exec as do_add;
|
||||
pub mod do_add {
|
||||
use super::*;
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Input {
|
||||
pub uuid: Uuid,
|
||||
pub key: String,
|
||||
pub start_time: String,
|
||||
pub end_time: String,
|
||||
pub contents: String,
|
||||
pub ops_count: usize,
|
||||
}
|
||||
|
||||
pub async fn exec(
|
||||
config: RequestConfig,
|
||||
library_id: Uuid,
|
||||
instances: Vec<Input>,
|
||||
) -> Result<(), Error> {
|
||||
let Some(auth_token) = config.auth_token else {
|
||||
return Err(Error("Authentication required".to_string()));
|
||||
};
|
||||
|
||||
config
|
||||
.client
|
||||
.post(&format!(
|
||||
"{}/api/v1/libraries/{}/messageCollections/doAdd",
|
||||
config.api_url, library_id
|
||||
))
|
||||
.json(&json!({ "instances": instances }))
|
||||
.with_auth(auth_token)
|
||||
.send()
|
||||
.await
|
||||
.and_then(|r| r.error_for_status())
|
||||
.map_err(|e| Error(e.to_string()))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Type, Serialize, Deserialize)]
|
||||
#[specta(rename = "Core_CloudLocation")]
|
||||
pub struct CloudLocation {
|
||||
id: String,
|
||||
name: String,
|
||||
}
|
||||
|
||||
pub mod locations {
|
||||
use super::*;
|
||||
|
||||
pub use list::exec as list;
|
||||
pub mod list {
|
||||
use super::*;
|
||||
|
||||
pub async fn exec(config: RequestConfig) -> Result<Response, Error> {
|
||||
let Some(auth_token) = config.auth_token else {
|
||||
return Err(Error("Authentication required".to_string()));
|
||||
};
|
||||
|
||||
config
|
||||
.client
|
||||
.get(&format!("{}/api/v1/locations", config.api_url))
|
||||
.with_auth(auth_token)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))?
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))
|
||||
}
|
||||
|
||||
pub type Response = Vec<CloudLocation>;
|
||||
}
|
||||
|
||||
pub use create::exec as create;
|
||||
pub mod create {
|
||||
use super::*;
|
||||
|
||||
pub async fn exec(config: RequestConfig, name: String) -> Result<Response, Error> {
|
||||
let Some(auth_token) = config.auth_token else {
|
||||
return Err(Error("Authentication required".to_string()));
|
||||
};
|
||||
|
||||
config
|
||||
.client
|
||||
.post(&format!("{}/api/v1/locations", config.api_url))
|
||||
.json(&json!({
|
||||
"name": name,
|
||||
}))
|
||||
.with_auth(auth_token)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))?
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))
|
||||
}
|
||||
|
||||
pub type Response = CloudLocation;
|
||||
}
|
||||
|
||||
pub use remove::exec as remove;
|
||||
pub mod remove {
|
||||
use super::*;
|
||||
|
||||
pub async fn exec(config: RequestConfig, id: String) -> Result<Response, Error> {
|
||||
let Some(auth_token) = config.auth_token else {
|
||||
return Err(Error("Authentication required".to_string()));
|
||||
};
|
||||
|
||||
config
|
||||
.client
|
||||
.post(&format!("{}/api/v1/locations/delete", config.api_url))
|
||||
.json(&json!({
|
||||
"id": id,
|
||||
}))
|
||||
.with_auth(auth_token)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))?
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))
|
||||
}
|
||||
|
||||
pub type Response = CloudLocation;
|
||||
}
|
||||
|
||||
pub use authorize::exec as authorize;
|
||||
pub mod authorize {
|
||||
use super::*;
|
||||
|
||||
pub async fn exec(config: RequestConfig, id: String) -> Result<Response, Error> {
|
||||
let Some(auth_token) = config.auth_token else {
|
||||
return Err(Error("Authentication required".to_string()));
|
||||
};
|
||||
|
||||
config
|
||||
.client
|
||||
.post(&format!("{}/api/v1/locations/authorize", config.api_url))
|
||||
.json(&json!({ "id": id }))
|
||||
.with_auth(auth_token)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))?
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| Error(e.to_string()))
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Type, Deserialize)]
|
||||
pub struct Response {
|
||||
pub access_key_id: String,
|
||||
pub secret_access_key: String,
|
||||
pub session_token: String,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ impl Tunnel {
|
||||
library_identity: &Identity,
|
||||
) -> Result<Self, TunnelError> {
|
||||
stream
|
||||
.write_all(&[b'T'])
|
||||
.write_all(b"T")
|
||||
.await
|
||||
.map_err(|_| TunnelError::DiscriminatorWriteError)?;
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ impl Drop for Interrupter {
|
||||
}
|
||||
|
||||
impl Interrupter {
|
||||
pub(crate) fn new(interrupt_tx: chan::Receiver<InterruptionRequest>) -> Self {
|
||||
pub(crate) const fn new(interrupt_tx: chan::Receiver<InterruptionRequest>) -> Self {
|
||||
Self {
|
||||
interrupt_rx: interrupt_tx,
|
||||
}
|
||||
@@ -659,7 +659,7 @@ pub struct TaskWorktable {
|
||||
}
|
||||
|
||||
impl TaskWorktable {
|
||||
pub fn new(worker_id: WorkerId, interrupt_tx: chan::Sender<InterruptionRequest>) -> Self {
|
||||
pub const fn new(worker_id: WorkerId, interrupt_tx: chan::Sender<InterruptionRequest>) -> Self {
|
||||
Self {
|
||||
started: AtomicBool::new(false),
|
||||
is_running: AtomicBool::new(false),
|
||||
@@ -899,7 +899,7 @@ pub struct PanicOnSenderDrop<E: RunError> {
|
||||
}
|
||||
|
||||
impl<E: RunError> PanicOnSenderDrop<E> {
|
||||
pub fn new(
|
||||
pub const fn new(
|
||||
task_id: TaskId,
|
||||
done_tx: oneshot::Sender<Result<TaskStatus<E>, SystemError>>,
|
||||
) -> Self {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "1.80.1"
|
||||
channel = "1.81.0"
|
||||
|
||||
Reference in New Issue
Block a user