Skip to content

Commit

Permalink
Provide context for raw service examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jasta committed Apr 15, 2022
1 parent fae8fd0 commit 5a4e0d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ tokio-util = { version = "0.7.0", features = ["codec", "net"] }
bytes = "1.1.0"
futures = "0.3.21"
async-trait = "0.1.53"
async-stream = "0.3.3"
pin-project = "1.0.10"
sync_wrapper = "0.1.1"
dyn-clone = "1.0.5"
Expand All @@ -27,3 +26,6 @@ env_logger = "0.9.0"
log = "0.4.16"
coap-lite = "0.9.0"
dashmap = "5.2.0"

[dev-dependencies]
async-stream = "0.3.3"
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ async fn main() -> Result<(), FatalServerError> {
server.serve(NonPiggybackedService::default()).await
}

/// Highly customized service that manually implements advanced features like not using
/// a piggy backed response + ack in order to allow very slow running responses to not
/// confuse clients. These features will eventually make their way into the app-based
/// approach (if they aren't already there!), but this provides a good example of what is
/// possible with the lowest level API.
#[derive(Default, Clone)]
struct NonPiggybackedService {}

Expand Down
3 changes: 3 additions & 0 deletions examples/service_mutability.rs → examples/custom_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ impl Default for CountingService {
}
}

/// It is possible to do all the raw packet handling yourself if you have some very sophisticated
/// use case not currently covered by the generic App-based handler. Pull requests welcome,
/// however!
impl PacketHandler<SocketAddr> for CountingService {
fn handle(
&self,
Expand Down

0 comments on commit 5a4e0d6

Please sign in to comment.