Skip to content

Commit

Permalink
Implement From for various types (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
andronat authored Oct 5, 2024
1 parent 2990ab6 commit fcc3d95
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 7 deletions.
120 changes: 114 additions & 6 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 rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ server = []
[dependencies]
prost = "0.13.3"
prost-types = "0.13.3"
tonic = "0.12.3"
tonic = { version = "0.12.3", features = ["tls"] }

[build-dependencies]
tonic-build = "0.12.2"
Expand Down
25 changes: 25 additions & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
pub use ::prost;
pub use ::prost_types;
pub use ::tonic;

pub mod relay {
tonic::include_proto!("relay");

impl From<RelayPayload> for RelayConnectRequest {
fn from(payload: RelayPayload) -> Self {
RelayConnectRequest {
msg: Some(relay_connect_request::Msg::Payload(payload)),
}
}
}

impl From<Heartbeat> for RelayConnectRequest {
fn from(heartbeat: Heartbeat) -> Self {
RelayConnectRequest {
msg: Some(relay_connect_request::Msg::Heartbeat(heartbeat)),
}
}
}

impl From<ConnectRequest> for RelayConnectRequest {
fn from(connect_request: ConnectRequest) -> Self {
RelayConnectRequest {
msg: Some(relay_connect_request::Msg::ConnectRequest(connect_request)),
}
}
}
}

pub mod common {
Expand Down

0 comments on commit fcc3d95

Please sign in to comment.