Skip to content

Commit

Permalink
refactor: eliminated dependency on derive_more crate
Browse files Browse the repository at this point in the history
  • Loading branch information
gh0st42 committed Feb 27, 2024
1 parent 075cac1 commit 10846a0
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 47 deletions.
41 changes: 3 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dtn7-codegen"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
authors = ["Lars Baumgaertner <[email protected]>"]
description = "codegen helpers for dtn7-rs"
Expand Down
14 changes: 12 additions & 2 deletions core/codegen/src/cla.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,27 @@ pub fn init_cla_subsystem(_item: TokenStream) -> TokenStream {

let cla_enum = quote! {
#[enum_dispatch]
#[derive(Debug, Display)]
#[derive(Debug)]
pub enum CLAEnum {
#(#cla_subsystem),*
}
impl std::fmt::Display for CLAEnum {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}
};

let clas_available = quote! {
#[derive(Debug, Display, PartialEq, Eq, Hash, Clone, Copy, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Serialize, Deserialize)]
pub enum CLAsAvailable {
#(#cla_subsystem),*
}
impl std::fmt::Display for CLAsAvailable {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}
impl From<CLAsAvailable> for &'static str {
fn from(v: CLAsAvailable) -> Self {
match v {
Expand Down
5 changes: 2 additions & 3 deletions core/dtn7/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ tempfile = "3.5.0"
humansize = "2.1.2"
sled = "0.34.7"
enum_dispatch = "0.3.8"
derive_more = "0.99.17"
axum = { version = "0.5.13", features = ["ws"] }
http = "0.2.7"
#tower = "0.4.8"
Expand All @@ -73,8 +72,8 @@ bitflags = "2.0.2"
num-derive = "0.4.2"
num-traits = "0.2.15"
thiserror = "1.0.31"
dtn7-codegen = { path = "../codegen", version = "0.1.1" }
reqwest = { version = "0.11.13", default-features = false, features = ["json"] }
dtn7-codegen = { path = "../codegen", version = "0.1.2" }
reqwest = { version = "0.11.13", default-features = false}
sha1 = "0.10.5"
glob-match = "0.2.1"

Expand Down
1 change: 0 additions & 1 deletion core/dtn7/src/cla/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use self::http::HttpConvergenceLayer;
use anyhow::Result;
use async_trait::async_trait;
use bp7::{ByteBuffer, EndpointID};
use derive_more::*;
use dtn7_codegen::init_cla_subsystem;
use dummy::DummyConvergenceLayer;
use enum_dispatch::enum_dispatch;
Expand Down
9 changes: 7 additions & 2 deletions core/dtn7/src/routing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::BundleID;
use async_trait::async_trait;
use bp7::Bundle;
use bp7::EndpointID;
use derive_more::*;
use enum_dispatch::enum_dispatch;
use epidemic::EpidemicRoutingAgent;
use external::ExternalRoutingAgent;
Expand All @@ -35,7 +34,7 @@ pub enum RoutingNotifcation {
}

#[enum_dispatch]
#[derive(Debug, Display)]
#[derive(Debug)]
pub enum RoutingAgentsEnum {
EpidemicRoutingAgent,
FloodingRoutingAgent,
Expand All @@ -45,6 +44,12 @@ pub enum RoutingAgentsEnum {
StaticRoutingAgent,
}

impl Display for RoutingAgentsEnum {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}

pub enum RoutingCmd {
SenderForBundle(BundlePack, oneshot::Sender<(Vec<ClaSenderTask>, bool)>),
Notify(RoutingNotifcation),
Expand Down

0 comments on commit 10846a0

Please sign in to comment.