Skip to content

Commit

Permalink
refactor: move daemon module to new scion crate
Browse files Browse the repository at this point in the history
  • Loading branch information
mlegner committed Nov 22, 2023
1 parent 4f9111e commit ac1f2c1
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 13 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
resolver = "2"

members = [
"crates/scion",
"crates/scion-grpc",
"crates/scion-proto",
]
1 change: 0 additions & 1 deletion crates/scion-proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ chrono = { version = "0.4.31", default-features = false }
scion-grpc = { version = "0.1.0", path = "../scion-grpc" }
serde = { version = "1.0.188", features = ["derive"] }
thiserror = "1.0.48"
tonic = "0.10.2"
tracing = "0.1.40"

[dev-dependencies]
Expand Down
1 change: 0 additions & 1 deletion crates/scion-proto/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod address;
pub mod daemon;
pub mod packet;
pub mod path;
pub mod reliable;
Expand Down
13 changes: 13 additions & 0 deletions crates/scion/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "scion"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
scion-grpc = { version = "0.1.0", path = "../scion-grpc" }
scion-proto = { version = "0.1.0", path = "../scion-proto" }
thiserror = "1.0.48"
tokio = { version = "1.34.0", features = ["rt-multi-thread", "macros"] }
tonic = "0.10.2"
tracing = "0.1.40"
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use scion_grpc::daemon::{v1 as daemon_grpc, v1::daemon_service_client::DaemonServiceClient};
use scion_proto::{address::IsdAsn, packet::ByEndpoint, path::Path};
use thiserror::Error;
use tonic::transport::Channel;
use tracing::warn;

use super::{messages::PathRequest, AsInfo};
use crate::{address::IsdAsn, packet::ByEndpoint, path::Path};
use super::{
messages::{self, PathRequest},
AsInfo,
};

#[derive(Debug, Error)]
pub enum DaemonClientError {
Expand Down Expand Up @@ -48,7 +51,7 @@ impl DaemonClient {
/// about the local AS.
pub async fn as_info(&self, isd_asn: IsdAsn) -> Result<AsInfo, DaemonClientError> {
self.client()
.r#as(daemon_grpc::AsRequest::from(isd_asn))
.r#as(messages::sas_request_from(isd_asn))
.await?
.into_inner()
.try_into()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
use std::num::TryFromIntError;

use scion_grpc::daemon::v1::{self as daemon_grpc};
use scion_proto::address::IsdAsn;

use crate::address::IsdAsn;

impl From<IsdAsn> for daemon_grpc::AsRequest {
fn from(value: IsdAsn) -> Self {
Self {
isd_as: value.as_u64(),
}
pub fn sas_request_from(value: IsdAsn) -> daemon_grpc::AsRequest {
daemon_grpc::AsRequest {
isd_as: value.as_u64(),
}
}

Expand Down Expand Up @@ -95,7 +92,7 @@ mod tests {
#[test]
fn request_conversion() {
assert_eq!(
daemon_grpc::AsRequest::from(IsdAsn::from(42)),
sas_request_from(IsdAsn::from(42)),
daemon_grpc::AsRequest { isd_as: 42 }
)
}
Expand Down
1 change: 1 addition & 0 deletions crates/scion/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod daemon;

0 comments on commit ac1f2c1

Please sign in to comment.