mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
use btreemap instead of indexmap
to establish canonical lock ordering
This commit is contained in:
committed by
Aiden McClelland
parent
a28f6ca5e2
commit
1a86f393d6
59
appmgr/Cargo.lock
generated
59
appmgr/Cargo.lock
generated
@@ -788,6 +788,7 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"nix 0.22.1",
|
"nix 0.22.1",
|
||||||
|
"num",
|
||||||
"openssh-keys",
|
"openssh-keys",
|
||||||
"openssl",
|
"openssl",
|
||||||
"patch-db",
|
"patch-db",
|
||||||
@@ -1728,6 +1729,40 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606"
|
||||||
|
dependencies = [
|
||||||
|
"num-bigint",
|
||||||
|
"num-complex",
|
||||||
|
"num-integer",
|
||||||
|
"num-iter",
|
||||||
|
"num-rational",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-bigint"
|
||||||
|
version = "0.4.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "74e768dff5fb39a41b3bcd30bb25cf989706c90d028d1ad71971987aa309d535"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-complex"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-integer"
|
name = "num-integer"
|
||||||
version = "0.1.44"
|
version = "0.1.44"
|
||||||
@@ -1738,6 +1773,29 @@ dependencies = [
|
|||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-iter"
|
||||||
|
version = "0.1.42"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-rational"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"num-bigint",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.14"
|
version = "0.2.14"
|
||||||
@@ -1868,7 +1926,6 @@ dependencies = [
|
|||||||
"async-trait",
|
"async-trait",
|
||||||
"fd-lock-rs",
|
"fd-lock-rs",
|
||||||
"futures",
|
"futures",
|
||||||
"indexmap",
|
|
||||||
"json-patch",
|
"json-patch",
|
||||||
"json-ptr",
|
"json-ptr",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ lazy_static = "1.4"
|
|||||||
libc = "0.2.103"
|
libc = "0.2.103"
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
||||||
nix = "0.22.1"
|
nix = "0.22.1"
|
||||||
|
num = "0.4.0"
|
||||||
openssh-keys = "0.5.0"
|
openssh-keys = "0.5.0"
|
||||||
openssl = { version = "0.10.36", features = ["vendored"] }
|
openssl = { version = "0.10.36", features = ["vendored"] }
|
||||||
patch-db = { version = "*", path = "../patch-db/patch-db", features = ["log"] }
|
patch-db = { version = "*", path = "../patch-db/patch-db", features = ["log"] }
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::ffi::{OsStr, OsString};
|
use std::ffi::{OsStr, OsString};
|
||||||
use std::net::Ipv4Addr;
|
use std::net::Ipv4Addr;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use indexmap::IndexMap;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ pub struct DockerAction {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub args: Vec<String>,
|
pub args: Vec<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub mounts: IndexMap<VolumeId, PathBuf>,
|
pub mounts: BTreeMap<VolumeId, PathBuf>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub io_format: Option<IoFormat>,
|
pub io_format: Option<IoFormat>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
|
use std::collections::BTreeMap;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
use indexmap::{IndexMap, IndexSet};
|
use indexmap::IndexSet;
|
||||||
use patch_db::HasModel;
|
use patch_db::HasModel;
|
||||||
use rpc_toolkit::command;
|
use rpc_toolkit::command;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -13,9 +14,7 @@ use crate::config::{Config, ConfigSpec};
|
|||||||
use crate::context::RpcContext;
|
use crate::context::RpcContext;
|
||||||
use crate::id::{Id, InvalidId};
|
use crate::id::{Id, InvalidId};
|
||||||
use crate::s9pk::manifest::PackageId;
|
use crate::s9pk::manifest::PackageId;
|
||||||
use crate::util::{
|
use crate::util::{display_serializable, parse_stdin_deserializable, IoFormat, Version};
|
||||||
display_serializable, parse_stdin_deserializable, IoFormat, ValuePrimative, Version,
|
|
||||||
};
|
|
||||||
use crate::volume::Volumes;
|
use crate::volume::Volumes;
|
||||||
use crate::{Error, ResultExt};
|
use crate::{Error, ResultExt};
|
||||||
|
|
||||||
@@ -23,7 +22,7 @@ pub mod docker;
|
|||||||
|
|
||||||
// TODO: create RPC endpoint that looks up the appropriate action and calls `execute`
|
// TODO: create RPC endpoint that looks up the appropriate action and calls `execute`
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
|
||||||
pub struct ActionId<S: AsRef<str> = String>(Id<S>);
|
pub struct ActionId<S: AsRef<str> = String>(Id<S>);
|
||||||
impl FromStr for ActionId {
|
impl FromStr for ActionId {
|
||||||
type Err = InvalidId;
|
type Err = InvalidId;
|
||||||
@@ -70,7 +69,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
pub struct Actions(pub IndexMap<ActionId, Action>);
|
pub struct Actions(pub BTreeMap<ActionId, Action>);
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "version")]
|
#[serde(tag = "version")]
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use std::collections::BTreeMap;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
@@ -6,7 +7,6 @@ use chrono::{DateTime, Utc};
|
|||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
use http::header::COOKIE;
|
use http::header::COOKIE;
|
||||||
use http::HeaderValue;
|
use http::HeaderValue;
|
||||||
use indexmap::IndexMap;
|
|
||||||
use rpc_toolkit::command;
|
use rpc_toolkit::command;
|
||||||
use rpc_toolkit::command_helpers::prelude::{RequestParts, ResponseParts};
|
use rpc_toolkit::command_helpers::prelude::{RequestParts, ResponseParts};
|
||||||
use rpc_toolkit::yajrc::RpcError;
|
use rpc_toolkit::yajrc::RpcError;
|
||||||
@@ -160,7 +160,7 @@ pub struct Session {
|
|||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct SessionList {
|
pub struct SessionList {
|
||||||
current: String,
|
current: String,
|
||||||
sessions: IndexMap<String, Session>,
|
sessions: BTreeMap<String, Session>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command(subcommands(list, kill))]
|
#[command(subcommands(list, kill))]
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use indexmap::{IndexMap, IndexSet};
|
|
||||||
use nix::sys::signal::Signal;
|
use nix::sys::signal::Signal;
|
||||||
use patch_db::HasModel;
|
use patch_db::HasModel;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -93,5 +94,5 @@ pub struct SetResult {
|
|||||||
#[serde(deserialize_with = "crate::util::deserialize_from_str_opt")]
|
#[serde(deserialize_with = "crate::util::deserialize_from_str_opt")]
|
||||||
#[serde(serialize_with = "crate::util::serialize_display_opt")]
|
#[serde(serialize_with = "crate::util::serialize_display_opt")]
|
||||||
pub signal: Option<Signal>,
|
pub signal: Option<Signal>,
|
||||||
pub depends_on: IndexMap<PackageId, IndexSet<HealthCheckId>>,
|
pub depends_on: BTreeMap<PackageId, BTreeSet<HealthCheckId>>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use bollard::container::KillContainerOptions;
|
use bollard::container::KillContainerOptions;
|
||||||
use futures::future::{BoxFuture, FutureExt};
|
use futures::future::{BoxFuture, FutureExt};
|
||||||
use indexmap::{IndexMap, IndexSet};
|
use indexmap::IndexSet;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use patch_db::DbHandle;
|
use patch_db::DbHandle;
|
||||||
use rand::SeedableRng;
|
use rand::SeedableRng;
|
||||||
@@ -205,7 +206,7 @@ pub async fn set_dry(
|
|||||||
) -> Result<BreakageRes, Error> {
|
) -> Result<BreakageRes, Error> {
|
||||||
let mut db = ctx.db.handle();
|
let mut db = ctx.db.handle();
|
||||||
let mut tx = db.begin().await?;
|
let mut tx = db.begin().await?;
|
||||||
let mut breakages = IndexMap::new();
|
let mut breakages = BTreeMap::new();
|
||||||
configure(
|
configure(
|
||||||
&ctx,
|
&ctx,
|
||||||
&mut tx,
|
&mut tx,
|
||||||
@@ -213,7 +214,7 @@ pub async fn set_dry(
|
|||||||
config,
|
config,
|
||||||
&timeout,
|
&timeout,
|
||||||
true,
|
true,
|
||||||
&mut IndexMap::new(),
|
&mut BTreeMap::new(),
|
||||||
&mut breakages,
|
&mut breakages,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
@@ -241,7 +242,7 @@ pub async fn set_impl(
|
|||||||
) -> Result<WithRevision<()>, Error> {
|
) -> Result<WithRevision<()>, Error> {
|
||||||
let mut db = ctx.db.handle();
|
let mut db = ctx.db.handle();
|
||||||
let mut tx = db.begin().await?;
|
let mut tx = db.begin().await?;
|
||||||
let mut breakages = IndexMap::new();
|
let mut breakages = BTreeMap::new();
|
||||||
configure(
|
configure(
|
||||||
&ctx,
|
&ctx,
|
||||||
&mut tx,
|
&mut tx,
|
||||||
@@ -249,7 +250,7 @@ pub async fn set_impl(
|
|||||||
config,
|
config,
|
||||||
&timeout,
|
&timeout,
|
||||||
false,
|
false,
|
||||||
&mut IndexMap::new(),
|
&mut BTreeMap::new(),
|
||||||
&mut breakages,
|
&mut breakages,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
@@ -278,8 +279,8 @@ pub fn configure<'a, Db: DbHandle>(
|
|||||||
config: Option<Config>,
|
config: Option<Config>,
|
||||||
timeout: &'a Option<Duration>,
|
timeout: &'a Option<Duration>,
|
||||||
dry_run: bool,
|
dry_run: bool,
|
||||||
overrides: &'a mut IndexMap<PackageId, Config>,
|
overrides: &'a mut BTreeMap<PackageId, Config>,
|
||||||
breakages: &'a mut IndexMap<PackageId, TaggedDependencyError>,
|
breakages: &'a mut BTreeMap<PackageId, TaggedDependencyError>,
|
||||||
) -> BoxFuture<'a, Result<(), Error>> {
|
) -> BoxFuture<'a, Result<(), Error>> {
|
||||||
async move {
|
async move {
|
||||||
crate::db::DatabaseModel::new()
|
crate::db::DatabaseModel::new()
|
||||||
@@ -332,7 +333,7 @@ pub fn configure<'a, Db: DbHandle>(
|
|||||||
// create backreferences to pointers
|
// create backreferences to pointers
|
||||||
let mut sys = pkg_model.clone().system_pointers().get_mut(db).await?;
|
let mut sys = pkg_model.clone().system_pointers().get_mut(db).await?;
|
||||||
sys.truncate(0);
|
sys.truncate(0);
|
||||||
let mut current_dependencies: IndexMap<PackageId, CurrentDependencyInfo> = dependencies
|
let mut current_dependencies: BTreeMap<PackageId, CurrentDependencyInfo> = dependencies
|
||||||
.0
|
.0
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(id, info)| {
|
.filter_map(|(id, info)| {
|
||||||
@@ -353,7 +354,7 @@ pub fn configure<'a, Db: DbHandle>(
|
|||||||
package_id,
|
package_id,
|
||||||
CurrentDependencyInfo {
|
CurrentDependencyInfo {
|
||||||
pointers: vec![target],
|
pointers: vec![target],
|
||||||
health_checks: IndexSet::new(),
|
health_checks: BTreeSet::new(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use std::borrow::{Borrow, Cow};
|
use std::borrow::{Borrow, Cow};
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::ops::RangeBounds;
|
use std::ops::RangeBounds;
|
||||||
@@ -6,7 +7,7 @@ use std::sync::Arc;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use indexmap::{IndexMap, IndexSet};
|
use indexmap::IndexSet;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use jsonpath_lib::Compiled as CompiledJsonPath;
|
use jsonpath_lib::Compiled as CompiledJsonPath;
|
||||||
use patch_db::{DbHandle, OptionModel};
|
use patch_db::{DbHandle, OptionModel};
|
||||||
@@ -37,7 +38,7 @@ pub trait ValueSpec {
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
db: &mut Db,
|
db: &mut Db,
|
||||||
config_overrides: &IndexMap<PackageId, Config>,
|
config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
value: &mut Value,
|
value: &mut Value,
|
||||||
) -> Result<(), ConfigurationError>;
|
) -> Result<(), ConfigurationError>;
|
||||||
// returns all pointers that are live in the provided config
|
// returns all pointers that are live in the provided config
|
||||||
@@ -152,7 +153,7 @@ where
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
db: &mut Db,
|
db: &mut Db,
|
||||||
config_overrides: &IndexMap<PackageId, Config>,
|
config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
value: &mut Value,
|
value: &mut Value,
|
||||||
) -> Result<(), ConfigurationError> {
|
) -> Result<(), ConfigurationError> {
|
||||||
self.inner.update(ctx, db, config_overrides, value).await
|
self.inner.update(ctx, db, config_overrides, value).await
|
||||||
@@ -193,7 +194,7 @@ where
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
db: &mut Db,
|
db: &mut Db,
|
||||||
config_overrides: &IndexMap<PackageId, Config>,
|
config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
value: &mut Value,
|
value: &mut Value,
|
||||||
) -> Result<(), ConfigurationError> {
|
) -> Result<(), ConfigurationError> {
|
||||||
self.inner.update(ctx, db, config_overrides, value).await
|
self.inner.update(ctx, db, config_overrides, value).await
|
||||||
@@ -267,7 +268,7 @@ where
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
db: &mut Db,
|
db: &mut Db,
|
||||||
config_overrides: &IndexMap<PackageId, Config>,
|
config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
value: &mut Value,
|
value: &mut Value,
|
||||||
) -> Result<(), ConfigurationError> {
|
) -> Result<(), ConfigurationError> {
|
||||||
self.inner.update(ctx, db, config_overrides, value).await
|
self.inner.update(ctx, db, config_overrides, value).await
|
||||||
@@ -378,7 +379,7 @@ impl ValueSpec for ValueSpecAny {
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
db: &mut Db,
|
db: &mut Db,
|
||||||
config_overrides: &IndexMap<PackageId, Config>,
|
config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
value: &mut Value,
|
value: &mut Value,
|
||||||
) -> Result<(), ConfigurationError> {
|
) -> Result<(), ConfigurationError> {
|
||||||
match self {
|
match self {
|
||||||
@@ -471,7 +472,7 @@ impl ValueSpec for ValueSpecBoolean {
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
_db: &mut Db,
|
_db: &mut Db,
|
||||||
_config_overrides: &IndexMap<PackageId, Config>,
|
_config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
_value: &mut Value,
|
_value: &mut Value,
|
||||||
) -> Result<(), ConfigurationError> {
|
) -> Result<(), ConfigurationError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -507,7 +508,7 @@ impl DefaultableWith for ValueSpecBoolean {
|
|||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct ValueSpecEnum {
|
pub struct ValueSpecEnum {
|
||||||
pub values: IndexSet<String>,
|
pub values: IndexSet<String>,
|
||||||
pub value_names: IndexMap<String, String>,
|
pub value_names: BTreeMap<String, String>,
|
||||||
}
|
}
|
||||||
impl<'de> serde::de::Deserialize<'de> for ValueSpecEnum {
|
impl<'de> serde::de::Deserialize<'de> for ValueSpecEnum {
|
||||||
fn deserialize<D: serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
|
fn deserialize<D: serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
|
||||||
@@ -516,7 +517,7 @@ impl<'de> serde::de::Deserialize<'de> for ValueSpecEnum {
|
|||||||
pub struct _ValueSpecEnum {
|
pub struct _ValueSpecEnum {
|
||||||
pub values: IndexSet<String>,
|
pub values: IndexSet<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub value_names: IndexMap<String, String>,
|
pub value_names: BTreeMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut r#enum = _ValueSpecEnum::deserialize(deserializer)?;
|
let mut r#enum = _ValueSpecEnum::deserialize(deserializer)?;
|
||||||
@@ -559,7 +560,7 @@ impl ValueSpec for ValueSpecEnum {
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
_db: &mut Db,
|
_db: &mut Db,
|
||||||
_config_overrides: &IndexMap<PackageId, Config>,
|
_config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
_value: &mut Value,
|
_value: &mut Value,
|
||||||
) -> Result<(), ConfigurationError> {
|
) -> Result<(), ConfigurationError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -644,7 +645,7 @@ where
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
db: &mut Db,
|
db: &mut Db,
|
||||||
config_overrides: &IndexMap<PackageId, Config>,
|
config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
value: &mut Value,
|
value: &mut Value,
|
||||||
) -> Result<(), ConfigurationError> {
|
) -> Result<(), ConfigurationError> {
|
||||||
if let Value::Array(ref mut ls) = value {
|
if let Value::Array(ref mut ls) = value {
|
||||||
@@ -746,7 +747,7 @@ impl ValueSpec for ValueSpecList {
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
db: &mut Db,
|
db: &mut Db,
|
||||||
config_overrides: &IndexMap<PackageId, Config>,
|
config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
value: &mut Value,
|
value: &mut Value,
|
||||||
) -> Result<(), ConfigurationError> {
|
) -> Result<(), ConfigurationError> {
|
||||||
match self {
|
match self {
|
||||||
@@ -869,7 +870,7 @@ impl ValueSpec for ValueSpecNumber {
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
_db: &mut Db,
|
_db: &mut Db,
|
||||||
_config_overrides: &IndexMap<PackageId, Config>,
|
_config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
_value: &mut Value,
|
_value: &mut Value,
|
||||||
) -> Result<(), ConfigurationError> {
|
) -> Result<(), ConfigurationError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -887,56 +888,6 @@ impl ValueSpec for ValueSpecNumber {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: remove
|
|
||||||
// #[derive(Clone, Copy, Debug, Serialize)]
|
|
||||||
// pub struct Number(pub f64);
|
|
||||||
// impl<'de> serde::de::Deserialize<'de> for Number {
|
|
||||||
// fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
||||||
// where
|
|
||||||
// D: serde::de::Deserializer<'de>,
|
|
||||||
// {
|
|
||||||
// use serde::de::*;
|
|
||||||
// struct NumberVisitor;
|
|
||||||
// impl<'de> Visitor<'de> for NumberVisitor {
|
|
||||||
// type Value = Number;
|
|
||||||
|
|
||||||
// fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
// formatter.write_str("a number")
|
|
||||||
// }
|
|
||||||
// fn visit_i8<E: Error>(self, value: i8) -> Result<Self::Value, E> {
|
|
||||||
// Ok(Number(value.into()))
|
|
||||||
// }
|
|
||||||
// fn visit_i16<E: Error>(self, value: i16) -> Result<Self::Value, E> {
|
|
||||||
// Ok(Number(value.into()))
|
|
||||||
// }
|
|
||||||
// fn visit_i32<E: Error>(self, value: i32) -> Result<Self::Value, E> {
|
|
||||||
// Ok(Number(value.into()))
|
|
||||||
// }
|
|
||||||
// fn visit_i64<E: Error>(self, value: i64) -> Result<Self::Value, E> {
|
|
||||||
// Ok(Number(value as f64))
|
|
||||||
// }
|
|
||||||
// fn visit_u8<E: Error>(self, value: u8) -> Result<Self::Value, E> {
|
|
||||||
// Ok(Number(value.into()))
|
|
||||||
// }
|
|
||||||
// fn visit_u16<E: Error>(self, value: u16) -> Result<Self::Value, E> {
|
|
||||||
// Ok(Number(value.into()))
|
|
||||||
// }
|
|
||||||
// fn visit_u32<E: Error>(self, value: u32) -> Result<Self::Value, E> {
|
|
||||||
// Ok(Number(value.into()))
|
|
||||||
// }
|
|
||||||
// fn visit_u64<E: Error>(self, value: u64) -> Result<Self::Value, E> {
|
|
||||||
// Ok(Number(value as f64))
|
|
||||||
// }
|
|
||||||
// fn visit_f32<E: Error>(self, value: f32) -> Result<Self::Value, E> {
|
|
||||||
// Ok(Number(value.into()))
|
|
||||||
// }
|
|
||||||
// fn visit_f64<E: Error>(self, value: f64) -> Result<Self::Value, E> {
|
|
||||||
// Ok(Number(value))
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// deserializer.deserialize_any(NumberVisitor)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
impl DefaultableWith for ValueSpecNumber {
|
impl DefaultableWith for ValueSpecNumber {
|
||||||
type DefaultSpec = Option<Number>;
|
type DefaultSpec = Option<Number>;
|
||||||
type Error = crate::util::Never;
|
type Error = crate::util::Never;
|
||||||
@@ -981,7 +932,7 @@ impl ValueSpec for ValueSpecObject {
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
db: &mut Db,
|
db: &mut Db,
|
||||||
config_overrides: &IndexMap<PackageId, Config>,
|
config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
value: &mut Value,
|
value: &mut Value,
|
||||||
) -> Result<(), ConfigurationError> {
|
) -> Result<(), ConfigurationError> {
|
||||||
if let Value::Object(o) = value {
|
if let Value::Object(o) = value {
|
||||||
@@ -1042,7 +993,7 @@ impl Defaultable for ValueSpecObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
||||||
pub struct ConfigSpec(pub IndexMap<String, ValueSpecAny>);
|
pub struct ConfigSpec(pub BTreeMap<String, ValueSpecAny>);
|
||||||
impl ConfigSpec {
|
impl ConfigSpec {
|
||||||
pub fn matches(&self, value: &Config) -> Result<(), NoMatchWithPath> {
|
pub fn matches(&self, value: &Config) -> Result<(), NoMatchWithPath> {
|
||||||
for (key, val) in self.0.iter() {
|
for (key, val) in self.0.iter() {
|
||||||
@@ -1080,7 +1031,7 @@ impl ConfigSpec {
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
db: &mut Db,
|
db: &mut Db,
|
||||||
config_overrides: &IndexMap<PackageId, Config>,
|
config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
cfg: &mut Config,
|
cfg: &mut Config,
|
||||||
) -> Result<(), ConfigurationError> {
|
) -> Result<(), ConfigurationError> {
|
||||||
for (k, vs) in self.0.iter() {
|
for (k, vs) in self.0.iter() {
|
||||||
@@ -1171,7 +1122,7 @@ impl ValueSpec for ValueSpecString {
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
_db: &mut Db,
|
_db: &mut Db,
|
||||||
_config_overrides: &IndexMap<PackageId, Config>,
|
_config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
_value: &mut Value,
|
_value: &mut Value,
|
||||||
) -> Result<(), ConfigurationError> {
|
) -> Result<(), ConfigurationError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1263,14 +1214,14 @@ pub struct UnionTag {
|
|||||||
pub id: String,
|
pub id: String,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub description: Option<String>,
|
pub description: Option<String>,
|
||||||
pub variant_names: IndexMap<String, String>,
|
pub variant_names: BTreeMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize)]
|
#[derive(Clone, Debug, Serialize)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct ValueSpecUnion {
|
pub struct ValueSpecUnion {
|
||||||
pub tag: UnionTag,
|
pub tag: UnionTag,
|
||||||
pub variants: IndexMap<String, ConfigSpec>,
|
pub variants: BTreeMap<String, ConfigSpec>,
|
||||||
pub display_as: Option<String>,
|
pub display_as: Option<String>,
|
||||||
pub unique_by: UniqueBy,
|
pub unique_by: UniqueBy,
|
||||||
}
|
}
|
||||||
@@ -1287,7 +1238,7 @@ impl<'de> serde::de::Deserialize<'de> for ValueSpecUnion {
|
|||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct _ValueSpecUnion {
|
pub struct _ValueSpecUnion {
|
||||||
pub variants: IndexMap<String, ConfigSpec>,
|
pub variants: BTreeMap<String, ConfigSpec>,
|
||||||
pub tag: _UnionTag,
|
pub tag: _UnionTag,
|
||||||
pub display_as: Option<String>,
|
pub display_as: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@@ -1381,7 +1332,7 @@ impl ValueSpec for ValueSpecUnion {
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
db: &mut Db,
|
db: &mut Db,
|
||||||
config_overrides: &IndexMap<PackageId, Config>,
|
config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
value: &mut Value,
|
value: &mut Value,
|
||||||
) -> Result<(), ConfigurationError> {
|
) -> Result<(), ConfigurationError> {
|
||||||
if let Value::Object(o) = value {
|
if let Value::Object(o) = value {
|
||||||
@@ -1522,7 +1473,7 @@ impl ValueSpec for ValueSpecPointer {
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
db: &mut Db,
|
db: &mut Db,
|
||||||
config_overrides: &IndexMap<PackageId, Config>,
|
config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
value: &mut Value,
|
value: &mut Value,
|
||||||
) -> Result<(), ConfigurationError> {
|
) -> Result<(), ConfigurationError> {
|
||||||
match self {
|
match self {
|
||||||
@@ -1561,7 +1512,7 @@ impl PackagePointerSpec {
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
db: &mut Db,
|
db: &mut Db,
|
||||||
config_overrides: &IndexMap<PackageId, Config>,
|
config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
) -> Result<Value, ConfigurationError> {
|
) -> Result<Value, ConfigurationError> {
|
||||||
match &self.target {
|
match &self.target {
|
||||||
PackagePointerSpecVariant::TorAddress { interface } => {
|
PackagePointerSpecVariant::TorAddress { interface } => {
|
||||||
@@ -1665,7 +1616,7 @@ impl ValueSpec for PackagePointerSpec {
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
db: &mut Db,
|
db: &mut Db,
|
||||||
config_overrides: &IndexMap<PackageId, Config>,
|
config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
value: &mut Value,
|
value: &mut Value,
|
||||||
) -> Result<(), ConfigurationError> {
|
) -> Result<(), ConfigurationError> {
|
||||||
*value = self.deref(ctx, db, config_overrides).await?;
|
*value = self.deref(ctx, db, config_overrides).await?;
|
||||||
@@ -1782,7 +1733,7 @@ impl ValueSpec for SystemPointerSpec {
|
|||||||
&self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
db: &mut Db,
|
db: &mut Db,
|
||||||
_config_overrides: &IndexMap<PackageId, Config>,
|
_config_overrides: &BTreeMap<PackageId, Config>,
|
||||||
value: &mut Value,
|
value: &mut Value,
|
||||||
) -> Result<(), ConfigurationError> {
|
) -> Result<(), ConfigurationError> {
|
||||||
*value = self.deref(db).await?;
|
*value = self.deref(db).await?;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use indexmap::IndexMap;
|
|
||||||
use patch_db::DbHandle;
|
use patch_db::DbHandle;
|
||||||
use rpc_toolkit::command;
|
use rpc_toolkit::command;
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ pub async fn start(
|
|||||||
|
|
||||||
*status = MainStatus::Running {
|
*status = MainStatus::Running {
|
||||||
started: Utc::now(),
|
started: Utc::now(),
|
||||||
health: IndexMap::new(),
|
health: BTreeMap::new(),
|
||||||
};
|
};
|
||||||
status
|
status
|
||||||
.synchronize(
|
.synchronize(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use indexmap::{IndexMap, IndexSet};
|
|
||||||
use patch_db::json_ptr::JsonPointer;
|
use patch_db::json_ptr::JsonPointer;
|
||||||
use patch_db::{HasModel, Map, MapModel, OptionModel};
|
use patch_db::{HasModel, Map, MapModel, OptionModel};
|
||||||
use reqwest::Url;
|
use reqwest::Url;
|
||||||
@@ -130,7 +130,7 @@ pub struct ConnectionAddresses {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Deserialize, Serialize)]
|
#[derive(Debug, Default, Deserialize, Serialize)]
|
||||||
pub struct AllPackageData(pub IndexMap<PackageId, PackageDataEntry>);
|
pub struct AllPackageData(pub BTreeMap<PackageId, PackageDataEntry>);
|
||||||
impl Map for AllPackageData {
|
impl Map for AllPackageData {
|
||||||
type Key = PackageId;
|
type Key = PackageId;
|
||||||
type Value = PackageDataEntry;
|
type Value = PackageDataEntry;
|
||||||
@@ -216,11 +216,11 @@ pub struct InstalledPackageDataEntry {
|
|||||||
pub manifest: Manifest,
|
pub manifest: Manifest,
|
||||||
pub system_pointers: Vec<SystemPointerSpec>,
|
pub system_pointers: Vec<SystemPointerSpec>,
|
||||||
#[model]
|
#[model]
|
||||||
pub dependency_info: IndexMap<PackageId, StaticDependencyInfo>,
|
pub dependency_info: BTreeMap<PackageId, StaticDependencyInfo>,
|
||||||
#[model]
|
#[model]
|
||||||
pub current_dependents: IndexMap<PackageId, CurrentDependencyInfo>,
|
pub current_dependents: BTreeMap<PackageId, CurrentDependencyInfo>,
|
||||||
#[model]
|
#[model]
|
||||||
pub current_dependencies: IndexMap<PackageId, CurrentDependencyInfo>,
|
pub current_dependencies: BTreeMap<PackageId, CurrentDependencyInfo>,
|
||||||
#[model]
|
#[model]
|
||||||
pub interface_addresses: InterfaceAddressMap,
|
pub interface_addresses: InterfaceAddressMap,
|
||||||
}
|
}
|
||||||
@@ -236,11 +236,11 @@ pub struct StaticDependencyInfo {
|
|||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct CurrentDependencyInfo {
|
pub struct CurrentDependencyInfo {
|
||||||
pub pointers: Vec<PackagePointerSpecVariant>,
|
pub pointers: Vec<PackagePointerSpecVariant>,
|
||||||
pub health_checks: IndexSet<HealthCheckId>,
|
pub health_checks: BTreeSet<HealthCheckId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct InterfaceAddressMap(pub IndexMap<InterfaceId, InterfaceAddresses>);
|
pub struct InterfaceAddressMap(pub BTreeMap<InterfaceId, InterfaceAddresses>);
|
||||||
impl Map for InterfaceAddressMap {
|
impl Map for InterfaceAddressMap {
|
||||||
type Key = InterfaceId;
|
type Key = InterfaceId;
|
||||||
type Value = InterfaceAddresses;
|
type Value = InterfaceAddresses;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use emver::VersionRange;
|
use emver::VersionRange;
|
||||||
use indexmap::IndexMap;
|
|
||||||
use patch_db::{DbHandle, DiffPatch, HasModel, Map, MapModel};
|
use patch_db::{DbHandle, DiffPatch, HasModel, Map, MapModel};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ pub enum DependencyError {
|
|||||||
}, // { "type": "config-unsatisfied", "error": "Bitcoin Core must have pruning set to manual." }
|
}, // { "type": "config-unsatisfied", "error": "Bitcoin Core must have pruning set to manual." }
|
||||||
NotRunning, // { "type": "not-running" }
|
NotRunning, // { "type": "not-running" }
|
||||||
HealthChecksFailed {
|
HealthChecksFailed {
|
||||||
failures: IndexMap<HealthCheckId, HealthCheckResult>,
|
failures: BTreeMap<HealthCheckId, HealthCheckResult>,
|
||||||
}, // { "type": "health-checks-failed", "checks": { "rpc": { "time": "2021-05-11T18:21:29Z", "result": "warming-up" } } }
|
}, // { "type": "health-checks-failed", "checks": { "rpc": { "time": "2021-05-11T18:21:29Z", "result": "warming-up" } } }
|
||||||
}
|
}
|
||||||
impl DependencyError {
|
impl DependencyError {
|
||||||
@@ -100,11 +101,11 @@ pub struct TaggedDependencyError {
|
|||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct BreakageRes {
|
pub struct BreakageRes {
|
||||||
pub patch: DiffPatch,
|
pub patch: DiffPatch,
|
||||||
pub breakages: IndexMap<PackageId, TaggedDependencyError>,
|
pub breakages: BTreeMap<PackageId, TaggedDependencyError>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
pub struct Dependencies(pub IndexMap<PackageId, DepInfo>);
|
pub struct Dependencies(pub BTreeMap<PackageId, DepInfo>);
|
||||||
impl Map for Dependencies {
|
impl Map for Dependencies {
|
||||||
type Key = PackageId;
|
type Key = PackageId;
|
||||||
type Value = DepInfo;
|
type Value = DepInfo;
|
||||||
@@ -209,7 +210,7 @@ impl DepInfo {
|
|||||||
health,
|
health,
|
||||||
}
|
}
|
||||||
| MainStatus::Running { health, .. } => {
|
| MainStatus::Running { health, .. } => {
|
||||||
let mut failures = IndexMap::with_capacity(health.len());
|
let mut failures = BTreeMap::new();
|
||||||
for (check, res) in health {
|
for (check, res) in health {
|
||||||
if !matches!(res.result, HealthCheckResultVariant::Success) {
|
if !matches!(res.result, HealthCheckResultVariant::Success) {
|
||||||
failures.insert(check.clone(), res.clone());
|
failures.insert(check.clone(), res.clone());
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
|
use std::collections::BTreeMap;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
use indexmap::{IndexMap, IndexSet};
|
use indexmap::IndexSet;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tokio::fs::File;
|
use tokio::fs::File;
|
||||||
@@ -141,7 +142,7 @@ pub async fn list() -> Result<Vec<DiskInfo>, Error> {
|
|||||||
crate::ErrorKind::Filesystem,
|
crate::ErrorKind::Filesystem,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.try_fold(IndexMap::new(), |mut disks, dir_entry| async move {
|
.try_fold(BTreeMap::new(), |mut disks, dir_entry| async move {
|
||||||
if let Some(disk_path) = dir_entry.path().file_name().and_then(|s| s.to_str()) {
|
if let Some(disk_path) = dir_entry.path().file_name().and_then(|s| s.to_str()) {
|
||||||
let (disk_path, part_path) = if let Some(end) = PARTITION_REGEX.find(disk_path) {
|
let (disk_path, part_path) = if let Some(end) = PARTITION_REGEX.find(disk_path) {
|
||||||
(
|
(
|
||||||
@@ -169,7 +170,7 @@ pub async fn list() -> Result<Vec<DiskInfo>, Error> {
|
|||||||
part_path.display().to_string(),
|
part_path.display().to_string(),
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
disks[&disk].insert(part);
|
disks.get_mut(&disk).unwrap().insert(part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(disks)
|
Ok(disks)
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ impl<'de> Deserialize<'de> for IdUnchecked<&'de str> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct Id<S: AsRef<str> = String>(S);
|
pub struct Id<S: AsRef<str> = String>(S);
|
||||||
impl<S: AsRef<str>> Id<S> {
|
impl<S: AsRef<str>> Id<S> {
|
||||||
pub fn try_from(value: S) -> Result<Self, InvalidId> {
|
pub fn try_from(value: S) -> Result<Self, InvalidId> {
|
||||||
@@ -137,7 +137,7 @@ impl<S: AsRef<str>> Serialize for Id<S> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
|
||||||
pub struct ImageId<S: AsRef<str> = String>(Id<S>);
|
pub struct ImageId<S: AsRef<str> = String>(Id<S>);
|
||||||
impl<S: AsRef<str>> std::fmt::Display for ImageId<S> {
|
impl<S: AsRef<str>> std::fmt::Display for ImageId<S> {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::{BTreeMap, HashSet};
|
||||||
use std::io::SeekFrom;
|
use std::io::SeekFrom;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
@@ -9,7 +9,6 @@ use anyhow::anyhow;
|
|||||||
use emver::VersionRange;
|
use emver::VersionRange;
|
||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use indexmap::IndexMap;
|
|
||||||
use patch_db::DbHandle;
|
use patch_db::DbHandle;
|
||||||
use reqwest::Response;
|
use reqwest::Response;
|
||||||
use rpc_toolkit::command;
|
use rpc_toolkit::command;
|
||||||
@@ -287,7 +286,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
|||||||
log::info!("Install {}@{}: Unpacked Manifest", pkg_id, version);
|
log::info!("Install {}@{}: Unpacked Manifest", pkg_id, version);
|
||||||
|
|
||||||
log::info!("Install {}@{}: Fetching Dependency Info", pkg_id, version);
|
log::info!("Install {}@{}: Fetching Dependency Info", pkg_id, version);
|
||||||
let mut dependency_info = IndexMap::with_capacity(manifest.dependencies.0.len());
|
let mut dependency_info = BTreeMap::new();
|
||||||
let reg_url = ctx.package_registry_url().await?;
|
let reg_url = ctx.package_registry_url().await?;
|
||||||
for (dep, info) in &manifest.dependencies.0 {
|
for (dep, info) in &manifest.dependencies.0 {
|
||||||
let manifest: Option<Manifest> = match reqwest::get(format!(
|
let manifest: Option<Manifest> = match reqwest::get(format!(
|
||||||
@@ -542,7 +541,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
|||||||
update_current_dependents(&mut tx, pkg_id, ¤t_dependencies).await?;
|
update_current_dependents(&mut tx, pkg_id, ¤t_dependencies).await?;
|
||||||
let current_dependents = {
|
let current_dependents = {
|
||||||
// search required dependencies
|
// search required dependencies
|
||||||
let mut deps = IndexMap::new();
|
let mut deps = BTreeMap::new();
|
||||||
for package in crate::db::DatabaseModel::new()
|
for package in crate::db::DatabaseModel::new()
|
||||||
.package_data()
|
.package_data()
|
||||||
.keys(&mut tx, true)
|
.keys(&mut tx, true)
|
||||||
@@ -648,8 +647,8 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
|||||||
None,
|
None,
|
||||||
&None,
|
&None,
|
||||||
false,
|
false,
|
||||||
&mut IndexMap::new(),
|
&mut BTreeMap::new(),
|
||||||
&mut IndexMap::new(),
|
&mut BTreeMap::new(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
todo!("set as running if viable");
|
todo!("set as running if viable");
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::{BTreeMap, HashMap};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
use indexmap::{IndexMap, IndexSet};
|
use indexmap::IndexSet;
|
||||||
use itertools::Either;
|
use itertools::Either;
|
||||||
use serde::{Deserialize, Deserializer, Serialize};
|
use serde::{Deserialize, Deserializer, Serialize};
|
||||||
use sqlx::{Executor, Sqlite};
|
use sqlx::{Executor, Sqlite};
|
||||||
@@ -17,7 +17,7 @@ use crate::Error;
|
|||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct Interfaces(pub IndexMap<InterfaceId, Interface>); // TODO
|
pub struct Interfaces(pub BTreeMap<InterfaceId, Interface>); // TODO
|
||||||
impl Interfaces {
|
impl Interfaces {
|
||||||
pub async fn install<Ex>(
|
pub async fn install<Ex>(
|
||||||
&self,
|
&self,
|
||||||
@@ -27,7 +27,7 @@ impl Interfaces {
|
|||||||
where
|
where
|
||||||
for<'a> &'a mut Ex: Executor<'a, Database = Sqlite>,
|
for<'a> &'a mut Ex: Executor<'a, Database = Sqlite>,
|
||||||
{
|
{
|
||||||
let mut interface_addresses = InterfaceAddressMap(IndexMap::new());
|
let mut interface_addresses = InterfaceAddressMap(BTreeMap::new());
|
||||||
for (id, iface) in &self.0 {
|
for (id, iface) in &self.0 {
|
||||||
let mut addrs = InterfaceAddresses {
|
let mut addrs = InterfaceAddresses {
|
||||||
tor_address: None,
|
tor_address: None,
|
||||||
@@ -101,7 +101,7 @@ impl Interfaces {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
|
||||||
pub struct InterfaceId<S: AsRef<str> = String>(Id<S>);
|
pub struct InterfaceId<S: AsRef<str> = String>(Id<S>);
|
||||||
impl<S: AsRef<str>> From<Id<S>> for InterfaceId<S> {
|
impl<S: AsRef<str>> From<Id<S>> for InterfaceId<S> {
|
||||||
fn from(id: Id<S>) -> Self {
|
fn from(id: Id<S>) -> Self {
|
||||||
@@ -148,7 +148,7 @@ pub struct Interface {
|
|||||||
pub name: String,
|
pub name: String,
|
||||||
pub description: String,
|
pub description: String,
|
||||||
pub tor_config: Option<TorConfig>,
|
pub tor_config: Option<TorConfig>,
|
||||||
pub lan_config: Option<IndexMap<Port, LanPortConfig>>,
|
pub lan_config: Option<BTreeMap<Port, LanPortConfig>>,
|
||||||
pub ui: bool,
|
pub ui: bool,
|
||||||
pub protocols: IndexSet<String>,
|
pub protocols: IndexSet<String>,
|
||||||
}
|
}
|
||||||
@@ -156,7 +156,7 @@ pub struct Interface {
|
|||||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct TorConfig {
|
pub struct TorConfig {
|
||||||
pub port_mapping: IndexMap<Port, Port>,
|
pub port_mapping: BTreeMap<Port, Port>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::{BTreeMap, HashMap};
|
||||||
use std::net::Ipv4Addr;
|
use std::net::Ipv4Addr;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use indexmap::{IndexMap, IndexSet};
|
use indexmap::IndexSet;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
@@ -201,6 +201,6 @@ struct PackageNetInfo {
|
|||||||
}
|
}
|
||||||
pub struct InterfaceMetadata {
|
pub struct InterfaceMetadata {
|
||||||
pub dns_base: String,
|
pub dns_base: String,
|
||||||
pub lan_config: IndexMap<Port, LanPortConfig>,
|
pub lan_config: BTreeMap<Port, LanPortConfig>,
|
||||||
pub protocols: IndexSet<String>,
|
pub protocols: IndexSet<String>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use crate::volume::Volumes;
|
|||||||
|
|
||||||
pub const SYSTEM_PACKAGE_ID: PackageId<&'static str> = PackageId(SYSTEM_ID);
|
pub const SYSTEM_PACKAGE_ID: PackageId<&'static str> = PackageId(SYSTEM_ID);
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct PackageId<S: AsRef<str> = String>(Id<S>);
|
pub struct PackageId<S: AsRef<str> = String>(Id<S>);
|
||||||
impl<'a> PackageId<&'a str> {
|
impl<'a> PackageId<&'a str> {
|
||||||
pub fn owned(&self) -> PackageId {
|
pub fn owned(&self) -> PackageId {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
use std::collections::BTreeMap;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use indexmap::IndexMap;
|
|
||||||
use serde::{Deserialize, Deserializer, Serialize};
|
use serde::{Deserialize, Deserializer, Serialize};
|
||||||
|
|
||||||
use crate::action::{ActionImplementation, NoOutput};
|
use crate::action::{ActionImplementation, NoOutput};
|
||||||
@@ -12,7 +12,7 @@ use crate::util::Version;
|
|||||||
use crate::volume::Volumes;
|
use crate::volume::Volumes;
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
|
||||||
pub struct HealthCheckId<S: AsRef<str> = String>(Id<S>);
|
pub struct HealthCheckId<S: AsRef<str> = String>(Id<S>);
|
||||||
impl<S: AsRef<str>> std::fmt::Display for HealthCheckId<S> {
|
impl<S: AsRef<str>> std::fmt::Display for HealthCheckId<S> {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
@@ -43,7 +43,7 @@ impl<S: AsRef<str>> AsRef<Path> for HealthCheckId<S> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct HealthChecks(pub IndexMap<HealthCheckId, HealthCheck>);
|
pub struct HealthChecks(pub BTreeMap<HealthCheckId, HealthCheck>);
|
||||||
impl HealthChecks {
|
impl HealthChecks {
|
||||||
pub async fn check_all(
|
pub async fn check_all(
|
||||||
&self,
|
&self,
|
||||||
@@ -52,7 +52,7 @@ impl HealthChecks {
|
|||||||
pkg_id: &PackageId,
|
pkg_id: &PackageId,
|
||||||
pkg_version: &Version,
|
pkg_version: &Version,
|
||||||
volumes: &Volumes,
|
volumes: &Volumes,
|
||||||
) -> Result<IndexMap<HealthCheckId, HealthCheckResult>, Error> {
|
) -> Result<BTreeMap<HealthCheckId, HealthCheckResult>, Error> {
|
||||||
let res = futures::future::try_join_all(self.0.iter().map(|(id, check)| async move {
|
let res = futures::future::try_join_all(self.0.iter().map(|(id, check)| async move {
|
||||||
Ok::<_, Error>((
|
Ok::<_, Error>((
|
||||||
id.clone(),
|
id.clone(),
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use futures::future::BoxFuture;
|
use futures::future::BoxFuture;
|
||||||
use futures::{FutureExt, StreamExt};
|
use futures::{FutureExt, StreamExt};
|
||||||
use indexmap::IndexMap;
|
|
||||||
use patch_db::{DbHandle, HasModel, Map, MapModel, ModelData};
|
use patch_db::{DbHandle, HasModel, Map, MapModel, ModelData};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@@ -129,7 +128,7 @@ pub async fn check_all(ctx: &RpcContext) -> Result<(), Error> {
|
|||||||
.to_owned()
|
.to_owned()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|(id, _)| listed_deps.contains(id))
|
.filter(|(id, _)| listed_deps.contains(id))
|
||||||
.collect::<IndexMap<PackageId, CurrentDependencyInfo>>()
|
.collect::<BTreeMap<PackageId, CurrentDependencyInfo>>()
|
||||||
}),
|
}),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -182,7 +181,7 @@ pub async fn check_all(ctx: &RpcContext) -> Result<(), Error> {
|
|||||||
id: &PackageId,
|
id: &PackageId,
|
||||||
statuses: Arc<HashMap<PackageId, MainStatus>>,
|
statuses: Arc<HashMap<PackageId, MainStatus>>,
|
||||||
model: InstalledPackageDataEntryModel,
|
model: InstalledPackageDataEntryModel,
|
||||||
current_deps: Arc<IndexMap<PackageId, CurrentDependencyInfo>>,
|
current_deps: Arc<BTreeMap<PackageId, CurrentDependencyInfo>>,
|
||||||
mut db: Db,
|
mut db: Db,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
for (dep_id, dep_info) in &*current_deps {
|
for (dep_id, dep_info) in &*current_deps {
|
||||||
@@ -192,7 +191,7 @@ pub async fn check_all(ctx: &RpcContext) -> Result<(), Error> {
|
|||||||
started: Some(_),
|
started: Some(_),
|
||||||
ref health,
|
ref health,
|
||||||
}) => {
|
}) => {
|
||||||
let mut failures = IndexMap::new();
|
let mut failures = BTreeMap::new();
|
||||||
for check in &dep_info.health_checks {
|
for check in &dep_info.health_checks {
|
||||||
let res = health
|
let res = health
|
||||||
.get(check)
|
.get(check)
|
||||||
@@ -219,7 +218,7 @@ pub async fn check_all(ctx: &RpcContext) -> Result<(), Error> {
|
|||||||
dep_id,
|
dep_id,
|
||||||
model.clone(),
|
model.clone(),
|
||||||
err,
|
err,
|
||||||
&mut IndexMap::new(),
|
&mut BTreeMap::new(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
} else {
|
} else {
|
||||||
@@ -274,11 +273,11 @@ pub enum MainStatus {
|
|||||||
Stopping,
|
Stopping,
|
||||||
Running {
|
Running {
|
||||||
started: DateTime<Utc>,
|
started: DateTime<Utc>,
|
||||||
health: IndexMap<HealthCheckId, HealthCheckResult>,
|
health: BTreeMap<HealthCheckId, HealthCheckResult>,
|
||||||
},
|
},
|
||||||
BackingUp {
|
BackingUp {
|
||||||
started: Option<DateTime<Utc>>,
|
started: Option<DateTime<Utc>>,
|
||||||
health: IndexMap<HealthCheckId, HealthCheckResult>,
|
health: BTreeMap<HealthCheckId, HealthCheckResult>,
|
||||||
},
|
},
|
||||||
Restoring {
|
Restoring {
|
||||||
running: bool,
|
running: bool,
|
||||||
@@ -394,7 +393,7 @@ impl MainStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
|
||||||
pub struct DependencyErrors(pub IndexMap<PackageId, DependencyError>);
|
pub struct DependencyErrors(pub BTreeMap<PackageId, DependencyError>);
|
||||||
impl Map for DependencyErrors {
|
impl Map for DependencyErrors {
|
||||||
type Key = PackageId;
|
type Key = PackageId;
|
||||||
type Value = DependencyError;
|
type Value = DependencyError;
|
||||||
@@ -410,9 +409,9 @@ impl DependencyErrors {
|
|||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
db: &mut Db,
|
db: &mut Db,
|
||||||
manifest: &Manifest,
|
manifest: &Manifest,
|
||||||
current_dependencies: &IndexMap<PackageId, CurrentDependencyInfo>,
|
current_dependencies: &BTreeMap<PackageId, CurrentDependencyInfo>,
|
||||||
) -> Result<DependencyErrors, Error> {
|
) -> Result<DependencyErrors, Error> {
|
||||||
let mut res = IndexMap::new();
|
let mut res = BTreeMap::new();
|
||||||
for dep_id in current_dependencies.keys() {
|
for dep_id in current_dependencies.keys() {
|
||||||
if let Err(e) = manifest
|
if let Err(e) = manifest
|
||||||
.dependencies
|
.dependencies
|
||||||
@@ -448,7 +447,7 @@ pub fn handle_broken_dependents<'a, Db: DbHandle>(
|
|||||||
dependency: &'a PackageId,
|
dependency: &'a PackageId,
|
||||||
model: InstalledPackageDataEntryModel,
|
model: InstalledPackageDataEntryModel,
|
||||||
error: DependencyError,
|
error: DependencyError,
|
||||||
breakages: &'a mut IndexMap<PackageId, TaggedDependencyError>,
|
breakages: &'a mut BTreeMap<PackageId, TaggedDependencyError>,
|
||||||
) -> BoxFuture<'a, Result<(), Error>> {
|
) -> BoxFuture<'a, Result<(), Error>> {
|
||||||
async move {
|
async move {
|
||||||
let mut status = model.clone().status().get_mut(db).await?;
|
let mut status = model.clone().status().get_mut(db).await?;
|
||||||
|
|||||||
@@ -704,7 +704,68 @@ impl<H: Digest, W: std::io::Write> std::io::Write for HashWriter<H, W> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
pub fn deserialize_number_permissive<
|
||||||
|
'de,
|
||||||
|
D: serde::de::Deserializer<'de>,
|
||||||
|
T: FromStr<Err = E> + num::cast::FromPrimitive,
|
||||||
|
E: std::fmt::Display,
|
||||||
|
>(
|
||||||
|
deserializer: D,
|
||||||
|
) -> std::result::Result<T, D::Error> {
|
||||||
|
use num::cast::FromPrimitive;
|
||||||
|
|
||||||
|
struct Visitor<T: FromStr<Err = E> + num::cast::FromPrimitive, E>(std::marker::PhantomData<T>);
|
||||||
|
impl<'de, T: FromStr<Err = Err> + num::cast::FromPrimitive, Err: std::fmt::Display>
|
||||||
|
serde::de::Visitor<'de> for Visitor<T, Err>
|
||||||
|
{
|
||||||
|
type Value = T;
|
||||||
|
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(formatter, "a parsable string")
|
||||||
|
}
|
||||||
|
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
|
||||||
|
where
|
||||||
|
E: serde::de::Error,
|
||||||
|
{
|
||||||
|
v.parse().map_err(|e| serde::de::Error::custom(e))
|
||||||
|
}
|
||||||
|
fn visit_f64<E>(self, v: f64) -> Result<Self::Value, E>
|
||||||
|
where
|
||||||
|
E: serde::de::Error,
|
||||||
|
{
|
||||||
|
T::from_f64(v).ok_or_else(|| {
|
||||||
|
serde::de::Error::custom(format!(
|
||||||
|
"{} cannot be represented by the requested type",
|
||||||
|
v
|
||||||
|
))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
|
||||||
|
where
|
||||||
|
E: serde::de::Error,
|
||||||
|
{
|
||||||
|
T::from_u64(v).ok_or_else(|| {
|
||||||
|
serde::de::Error::custom(format!(
|
||||||
|
"{} cannot be represented by the requested type",
|
||||||
|
v
|
||||||
|
))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
fn visit_i64<E>(self, v: i64) -> Result<Self::Value, E>
|
||||||
|
where
|
||||||
|
E: serde::de::Error,
|
||||||
|
{
|
||||||
|
T::from_i64(v).ok_or_else(|| {
|
||||||
|
serde::de::Error::custom(format!(
|
||||||
|
"{} cannot be represented by the requested type",
|
||||||
|
v
|
||||||
|
))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deserializer.deserialize_str(Visitor(std::marker::PhantomData))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct Port(pub u16);
|
pub struct Port(pub u16);
|
||||||
impl<'de> Deserialize<'de> for Port {
|
impl<'de> Deserialize<'de> for Port {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
@@ -712,7 +773,7 @@ impl<'de> Deserialize<'de> for Port {
|
|||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
{
|
{
|
||||||
//TODO: if number, be permissive
|
//TODO: if number, be permissive
|
||||||
deserialize_from_str(deserializer).map(Port)
|
deserialize_number_permissive(deserializer).map(Port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Serialize for Port {
|
impl Serialize for Port {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use indexmap::IndexMap;
|
|
||||||
use patch_db::{HasModel, Map, MapModel};
|
use patch_db::{HasModel, Map, MapModel};
|
||||||
use serde::{Deserialize, Deserializer, Serialize};
|
use serde::{Deserialize, Deserializer, Serialize};
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ use crate::Error;
|
|||||||
pub const PKG_VOLUME_DIR: &'static str = "package-data/volumes";
|
pub const PKG_VOLUME_DIR: &'static str = "package-data/volumes";
|
||||||
pub const BACKUP_DIR: &'static str = "/mnt/embassy-os-backups/EmbassyBackups";
|
pub const BACKUP_DIR: &'static str = "/mnt/embassy-os-backups/EmbassyBackups";
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub enum VolumeId<S: AsRef<str> = String> {
|
pub enum VolumeId<S: AsRef<str> = String> {
|
||||||
Backup,
|
Backup,
|
||||||
Custom(Id<S>),
|
Custom(Id<S>),
|
||||||
@@ -73,7 +73,7 @@ impl<S: AsRef<str>> Serialize for VolumeId<S> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
pub struct Volumes(IndexMap<VolumeId, Volume>);
|
pub struct Volumes(BTreeMap<VolumeId, Volume>);
|
||||||
impl Volumes {
|
impl Volumes {
|
||||||
pub async fn install(
|
pub async fn install(
|
||||||
&self,
|
&self,
|
||||||
@@ -111,7 +111,7 @@ impl Volumes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Deref for Volumes {
|
impl Deref for Volumes {
|
||||||
type Target = IndexMap<VolumeId, Volume>;
|
type Target = BTreeMap<VolumeId, Volume>;
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
|
|||||||
2
patch-db
2
patch-db
Submodule patch-db updated: d26e1563e8...6f3921e329
Reference in New Issue
Block a user