mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-10-18 19:10:30 +08:00
radicle: Remove dependency amplify
The `amplify` crate is only used in a handful places to derive `impl`s that are not very complex. Provide the required `impl`s directly, and remove the dependency.
This commit is contained in:
committed by
Fintan Halpenny
parent
564c167de1
commit
e4775edf41
Generated
-1
@@ -2908,7 +2908,6 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
||||
name = "radicle"
|
||||
version = "0.24.0"
|
||||
dependencies = [
|
||||
"amplify",
|
||||
"base64 0.21.7",
|
||||
"bytesize",
|
||||
"crossbeam-channel",
|
||||
|
||||
@@ -30,7 +30,6 @@ schemars = [
|
||||
tor = ["cyphernet/tor"]
|
||||
|
||||
[dependencies]
|
||||
amplify = { workspace = true, features = ["std"] }
|
||||
base64 = "0.21.3"
|
||||
bytesize = { version = "2", features = ["serde"] }
|
||||
crossbeam-channel = { workspace = true }
|
||||
|
||||
@@ -77,8 +77,7 @@ pub enum TitleError {
|
||||
/// - Must not be empty
|
||||
/// - Must not contain `\n` or `\r` characters
|
||||
/// - Will be trimmed of any preceding or following whitespace
|
||||
#[derive(Display, Deserialize, Serialize, PartialEq, Eq, Clone, Debug)]
|
||||
#[display(inner)]
|
||||
#[derive(Deserialize, Serialize, PartialEq, Eq, Clone, Debug)]
|
||||
pub struct Title(String);
|
||||
|
||||
impl Title {
|
||||
@@ -123,6 +122,12 @@ impl TryFrom<String> for Title {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Title {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
/// Author.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct Author {
|
||||
|
||||
@@ -12,7 +12,6 @@ use std::ops::Deref;
|
||||
use std::str::FromStr;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use amplify::Wrapper;
|
||||
use nonempty::NonEmpty;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use storage::{HasRepoId, RepositoryError};
|
||||
@@ -57,45 +56,89 @@ impl<'a> PatchStream<'a> {
|
||||
}
|
||||
|
||||
/// Unique identifier for a patch revision.
|
||||
#[derive(
|
||||
Wrapper,
|
||||
Debug,
|
||||
Clone,
|
||||
Copy,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
PartialEq,
|
||||
Eq,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
Hash,
|
||||
From,
|
||||
Display,
|
||||
)]
|
||||
#[display(inner)]
|
||||
#[wrap(Deref)]
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct RevisionId(EntryId);
|
||||
|
||||
impl RevisionId {
|
||||
pub fn into_inner(self) -> EntryId {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for RevisionId {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<EntryId> for RevisionId {
|
||||
fn from(id: EntryId) -> Self {
|
||||
Self(id)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RevisionId> for EntryId {
|
||||
fn from(id: RevisionId) -> Self {
|
||||
id.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for RevisionId {
|
||||
type Target = EntryId;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl std::borrow::Borrow<EntryId> for RevisionId {
|
||||
fn borrow(&self) -> &EntryId {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Unique identifier for a patch review.
|
||||
#[derive(
|
||||
Wrapper,
|
||||
Debug,
|
||||
Clone,
|
||||
Copy,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
PartialEq,
|
||||
Eq,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
Hash,
|
||||
From,
|
||||
Display,
|
||||
)]
|
||||
#[display(inner)]
|
||||
#[wrapper(Deref)]
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct ReviewId(EntryId);
|
||||
|
||||
impl ReviewId {
|
||||
pub fn into_inner(self) -> EntryId {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ReviewId {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<EntryId> for ReviewId {
|
||||
fn from(id: EntryId) -> Self {
|
||||
Self(id)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ReviewId> for EntryId {
|
||||
fn from(id: ReviewId) -> Self {
|
||||
id.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for ReviewId {
|
||||
type Target = EntryId;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl std::borrow::Borrow<EntryId> for ReviewId {
|
||||
fn borrow(&self) -> &EntryId {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Index of a revision in the revisions list.
|
||||
pub type RevisionIx = usize;
|
||||
|
||||
|
||||
@@ -715,7 +715,6 @@ mod tests {
|
||||
use std::num::NonZeroU8;
|
||||
use std::str::FromStr;
|
||||
|
||||
use amplify::Wrapper;
|
||||
use radicle_cob::ObjectId;
|
||||
|
||||
use crate::cob::cache::{Store, Update, Write};
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
|
||||
pub extern crate radicle_crypto as crypto;
|
||||
|
||||
#[macro_use]
|
||||
extern crate amplify;
|
||||
|
||||
extern crate radicle_localtime as localtime;
|
||||
|
||||
mod canonical;
|
||||
|
||||
@@ -32,7 +32,6 @@ use std::os::unix::net::UnixStream;
|
||||
#[cfg(windows)]
|
||||
use uds_windows::UnixStream;
|
||||
|
||||
use amplify::WrapperMut;
|
||||
use cyphernet::addr::{AddrParseError, NetAddr};
|
||||
use localtime::{LocalDuration, LocalTime};
|
||||
use serde::de::DeserializeOwned;
|
||||
@@ -462,9 +461,7 @@ impl TryFrom<&sqlite::Value> for Alias {
|
||||
}
|
||||
|
||||
/// Peer public protocol address.
|
||||
#[derive(Clone, Eq, PartialEq, Debug, Hash, Wrapper, WrapperMut, Serialize, Deserialize)]
|
||||
#[wrapper(Deref)]
|
||||
#[wrapper_mut(DerefMut)]
|
||||
#[derive(Clone, Eq, PartialEq, Debug, Hash, Serialize, Deserialize)]
|
||||
#[serde(try_from = "String", into = "String")]
|
||||
#[cfg_attr(
|
||||
feature = "schemars",
|
||||
@@ -482,7 +479,6 @@ impl TryFrom<&sqlite::Value> for Alias {
|
||||
),
|
||||
))]
|
||||
pub struct Address {
|
||||
#[wrap]
|
||||
inner: NetAddr<HostName>,
|
||||
|
||||
/// See documentation of [`Address::is_ipv6_without_square_brackets`] for details.
|
||||
@@ -652,6 +648,14 @@ impl FromStr for Address {
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for Address {
|
||||
type Target = NetAddr<HostName>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.inner
|
||||
}
|
||||
}
|
||||
|
||||
impl cyphernet::addr::Host for Address {
|
||||
fn requires_proxy(&self) -> bool {
|
||||
self.inner.requires_proxy()
|
||||
|
||||
@@ -255,8 +255,7 @@ pub struct ConnectionLimits {
|
||||
/// Rate limiting uses a token bucket for each peer. The capacity of the bucket
|
||||
/// is defined by [`RateLimit::capacity`], and refill rate of the bucket is
|
||||
/// defined by [`RateLimit::fill_rate`].
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Display)]
|
||||
#[display("RateLimit(fill_rate={fill_rate}, capacity={capacity})")]
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
pub struct RateLimit {
|
||||
@@ -278,6 +277,16 @@ pub struct RateLimit {
|
||||
pub capacity: usize,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for RateLimit {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"RateLimit(fill_rate={}, capacity={})",
|
||||
self.fill_rate, self.capacity
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Rate limits for inbound and outbound connections.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@@ -699,9 +708,8 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Display, Deserialize, Serialize, From)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||
#[serde(transparent)]
|
||||
#[display("{0}")]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
pub struct LogLevel(
|
||||
#[serde(with = "crate::serde_ext::string")]
|
||||
@@ -718,12 +726,24 @@ impl Default for LogLevel {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<log::Level> for LogLevel {
|
||||
fn from(value: log::Level) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<LogLevel> for log::Level {
|
||||
fn from(value: LogLevel) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for LogLevel {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize, Eq, PartialEq)]
|
||||
#[serde(transparent)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
@@ -778,8 +798,7 @@ impl From<LimitGossipMaxAge> for LocalDuration {
|
||||
/// - `From<$name> for $type`, i.e. can convert back into the original type
|
||||
macro_rules! wrapper {
|
||||
($name:ident, $type:ty, $default:expr_2021 $(, $derive:ty)*) => {
|
||||
#[derive(Clone, Debug, Deserialize, Display, Serialize, From $(, $derive)*)]
|
||||
#[display("{0}")]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize $(, $derive)*)]
|
||||
#[serde(transparent)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
pub struct $name($type);
|
||||
@@ -790,11 +809,23 @@ macro_rules! wrapper {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<$type> for $name {
|
||||
fn from(value: $type) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<$name> for $type {
|
||||
fn from(value: $name) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for $name {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
wrapper!(Workers, usize, 8, Copy);
|
||||
|
||||
Reference in New Issue
Block a user