@@ -73,7 +73,7 @@ use self::ready::{err, ok, ready, Ready};
73
73
/// impl Service<u8> for MyService {
74
74
/// type Response = u64;
75
75
/// type Error = MyError;
76
- /// type Future = Pin<Box<Future<Output= Result<Self::Response, Self::Error>>>>;
76
+ /// type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>>>>;
77
77
///
78
78
/// fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { ... }
79
79
///
@@ -82,7 +82,7 @@ use self::ready::{err, ok, ready, Ready};
82
82
/// ```
83
83
///
84
84
/// Sometimes it is not necessary to implement the Service trait. For example, the above service
85
- /// could be rewritten as a simple function and passed to [fn_service](fn_service()).
85
+ /// could be rewritten as a simple function and passed to [` fn_service` ](fn_service()).
86
86
///
87
87
/// ```ignore
88
88
/// async fn my_service(req: u8) -> Result<u64, MyError>;
@@ -102,13 +102,12 @@ pub trait Service<Req> {
102
102
103
103
/// Returns `Ready` when the service is able to process requests.
104
104
///
105
- /// If the service is at capacity, then `Pending` is returned and the task
106
- /// is notified when the service becomes ready again. This function is
107
- /// expected to be called while on a task.
105
+ /// If the service is at capacity, then `Pending` is returned and the task is notified when the
106
+ /// service becomes ready again. This function is expected to be called while on a task.
108
107
///
109
- /// This is a ** best effort** implementation. False positives are permitted.
110
- /// It is permitted for the service to return `Ready` from a `poll_ready`
111
- /// call and the next invocation of `call` results in an error.
108
+ /// This is a best effort implementation. False positives are permitted. It is permitted for
109
+ /// the service to return `Ready` from a `poll_ready` call and the next invocation of `call `
110
+ /// results in an error.
112
111
///
113
112
/// # Notes
114
113
/// 1. `poll_ready` might be called on a different task to `call`.
@@ -117,25 +116,26 @@ pub trait Service<Req> {
117
116
118
117
/// Process the request and return the response asynchronously.
119
118
///
120
- /// This function is expected to be callable off task. As such,
121
- /// implementations should take care to not call `poll_ready`. If the
122
- /// service is at capacity and the request is unable to be handled, the
123
- /// returned `Future` should resolve to an error.
119
+ /// This function is expected to be callable off-task. As such, implementations of `call` should
120
+ /// take care to not call `poll_ready`. If the service is at capacity and the request is unable
121
+ /// to be handled, the returned `Future` should resolve to an error.
124
122
///
125
- /// Calling `call` without calling `poll_ready` is permitted. The
126
- /// implementation must be resilient to this fact.
123
+ /// Invoking `call` without first invoking `poll_ready` is permitted. Implementations must be
124
+ /// resilient to this fact.
127
125
fn call ( & self , req : Req ) -> Self :: Future ;
128
126
}
129
127
130
128
/// Factory for creating `Service`s.
131
129
///
132
- /// Acts as a service factory. This is useful for cases where new `Service`s
133
- /// must be produced. One case is a TCP server listener. The listener
134
- /// accepts new TCP streams, obtains a new `Service` using the
135
- /// `ServiceFactory` trait, and uses the new `Service` to process inbound
136
- /// requests on that new TCP stream.
130
+ /// This is useful for cases where new `Service`s must be produced. One case is a TCP
131
+ /// server listener: a listener accepts new connections, constructs a new `Service` for each using
132
+ /// the `ServiceFactory` trait, and uses the new `Service` to process inbound requests on that new
133
+ /// connection.
137
134
///
138
135
/// `Config` is a service factory configuration type.
136
+ ///
137
+ /// Simple factories may be able to use [`fn_factory`] or [`fn_factory_with_config`] to
138
+ /// reduce boilerplate.
139
139
pub trait ServiceFactory < Req > {
140
140
/// Responses given by the created services.
141
141
type Response ;
0 commit comments