radicle: Re-export `radicle_core::RepoId`
This commit is contained in:
parent
73827f5362
commit
02318f199c
|
|
@ -13,7 +13,16 @@ rust-version.workspace = true
|
|||
default = []
|
||||
test = ["tempfile", "qcheck", "radicle-crypto/test", "radicle-cob/test"]
|
||||
logger = ["colored", "chrono"]
|
||||
schemars = ["radicle-oid/schemars", "radicle-localtime/schemars", "dep:schemars"]
|
||||
qcheck = [
|
||||
"radicle-core/qcheck",
|
||||
"dep:qcheck"
|
||||
]
|
||||
schemars = [
|
||||
"radicle-oid/schemars",
|
||||
"radicle-core/schemars",
|
||||
"radicle-localtime/schemars",
|
||||
"dep:schemars"
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
amplify = { workspace = true, features = ["std"] }
|
||||
|
|
@ -33,7 +42,7 @@ multibase = { workspace = true }
|
|||
nonempty = { workspace = true, features = ["serialize"] }
|
||||
qcheck = { workspace = true, optional = true }
|
||||
radicle-cob = { workspace = true, features = ["git2"] }
|
||||
radicle-core = { workspace = true, features = ["git2"] }
|
||||
radicle-core = { workspace = true, features = ["git2", "serde", "sqlite"] }
|
||||
radicle-crypto = { workspace = true, features = ["git-ref-format-core", "ssh", "sqlite", "cyphernet"] }
|
||||
radicle-git-ref-format = { workspace = true, features = ["macro", "serde"] }
|
||||
radicle-localtime = { workspace = true, features = ["serde"] }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
pub mod update;
|
||||
|
||||
mod id;
|
||||
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::fmt;
|
||||
use std::num::{NonZeroU32, NonZeroUsize};
|
||||
|
|
@ -29,7 +27,7 @@ use crate::storage;
|
|||
use crate::storage::{ReadRepository, RepositoryError};
|
||||
|
||||
pub use crypto::PublicKey;
|
||||
pub use id::*;
|
||||
pub use radicle_core::repo::*;
|
||||
|
||||
use super::crefs::{self, RawCanonicalRefs};
|
||||
use super::CanonicalRefs;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ use std::str::FromStr;
|
|||
use sqlite as sql;
|
||||
use sqlite::Value;
|
||||
|
||||
use crate::identity::RepoId;
|
||||
use crate::node;
|
||||
use crate::node::{Address, UserAgent};
|
||||
|
||||
|
|
@ -28,29 +27,6 @@ pub fn transaction<T, E: From<sql::Error>>(
|
|||
}
|
||||
}
|
||||
|
||||
impl TryFrom<&Value> for RepoId {
|
||||
type Error = sql::Error;
|
||||
|
||||
fn try_from(value: &Value) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
Value::String(id) => RepoId::from_urn(id).map_err(|e| sql::Error {
|
||||
code: None,
|
||||
message: Some(e.to_string()),
|
||||
}),
|
||||
_ => Err(sql::Error {
|
||||
code: None,
|
||||
message: Some(format!("sql: invalid type `{:?}` for id", value.kind())),
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl sqlite::BindableWithIndex for &RepoId {
|
||||
fn bind<I: sql::ParameterIndex>(self, stmt: &mut sql::Statement<'_>, i: I) -> sql::Result<()> {
|
||||
self.urn().as_str().bind(stmt, i)
|
||||
}
|
||||
}
|
||||
|
||||
impl sql::BindableWithIndex for node::Features {
|
||||
fn bind<I: sql::ParameterIndex>(self, stmt: &mut sql::Statement<'_>, i: I) -> sql::Result<()> {
|
||||
(*self.deref() as i64).bind(stmt, i)
|
||||
|
|
|
|||
|
|
@ -270,15 +270,6 @@ impl Arbitrary for storage::Remote<crypto::Unverified> {
|
|||
}
|
||||
}
|
||||
|
||||
impl Arbitrary for RepoId {
|
||||
fn arbitrary(g: &mut qcheck::Gen) -> Self {
|
||||
let bytes = <[u8; 20]>::arbitrary(g);
|
||||
let oid = crate::git::Oid::from_sha1(bytes);
|
||||
|
||||
RepoId::from(oid)
|
||||
}
|
||||
}
|
||||
|
||||
impl Arbitrary for AddressType {
|
||||
fn arbitrary(g: &mut qcheck::Gen) -> Self {
|
||||
let t = *g.choose(&[1, 2, 3, 4]).unwrap() as u8;
|
||||
|
|
|
|||
Loading…
Reference in New Issue