-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Going whole hog on implementing service servers as well, just so I ca…
…n test service clients how I want to
- Loading branch information
Carter
committed
Jun 26, 2024
1 parent
b183744
commit 2e08c3e
Showing
7 changed files
with
227 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Purpose of this array is send and receive a large payload | ||
uint8[] bytes | ||
--- | ||
uint8[] bytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use super::{names::Name, NodeHandle}; | ||
|
||
// TODO: someday I'd like to define a trait alias here for a ServerFunction | ||
// Currently unstable: | ||
// https://doc.rust-lang.org/beta/unstable-book/language-features/trait-alias.html | ||
// trait ServerFunction<T> = Fn(T::Request) -> Err(T::Response, Box<dyn std::error::Error + Send + Sync>) + Send + Sync + 'static; | ||
|
||
/// ServiceServer is simply a lifetime control | ||
/// The underlying ServiceServer is kept alive while object is kept alive. | ||
/// Dropping this object, un-advertises the underlying service with rosmaster | ||
pub struct ServiceServer { | ||
service_name: Name, | ||
node_handle: NodeHandle, | ||
} | ||
|
||
impl ServiceServer { | ||
pub fn new(service_name: Name, node_handle: NodeHandle) -> Self { | ||
Self { | ||
service_name, | ||
node_handle, | ||
} | ||
} | ||
} | ||
|
||
impl Drop for ServiceServer { | ||
fn drop(&mut self) { | ||
self.node_handle | ||
.unadvertise_service(&self.service_name.to_string()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters