Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Service
✓ use tower_service::Service;
Implement the Service trait for a simple echo service.
use tower_service::Service;
use std::task::{Context, Poll};
struct MyService;
impl Service<String> for MyService {
type Response = String;
type Error = std::io::Error;
type Future = std::future::Ready<Result<Self::Response, Self::Error>>;
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: String) -> Self::Future {
std::future::ready(Ok(format!("Echo: {}", req)))
}
}
fn main() {
let mut svc = MyService;
let fut = svc.call("hello".to_string());
println!("{:?}", fut.into_inner());
}
Debug
Known issues
No known issues recorded.
Audit
Dependencies
No dependency data recorded yet.