diff --git a/grpc/src/attributes/mod.rs b/grpc/src/attributes/mod.rs index c082bc36e..f6926ea36 100644 --- a/grpc/src/attributes/mod.rs +++ b/grpc/src/attributes/mod.rs @@ -86,7 +86,7 @@ impl Eq for AttributeValue {} /// A collection of attributes indexed by their type. /// /// `Attributes` provides a map-like interface where values are keyed by their -/// TypeId. +/// `TypeId`. /// /// Equality and ordering of `Attributes` are structural. /// This means two `Attributes` maps are equal if they contain the same set of diff --git a/grpc/src/client/channel.rs b/grpc/src/client/channel.rs index 9732eb826..e4af569ae 100644 --- a/grpc/src/client/channel.rs +++ b/grpc/src/client/channel.rs @@ -106,13 +106,13 @@ impl Channel { /// by the user. Valid examples of target names include: /// /// "foo.googleapis.com:8080" - /// "dns:///foo.googleapis.com:8080" - /// "dns:///foo.googleapis.com" - /// "dns:///10.0.0.213:8080" - /// "dns:///%5B2001:db8:85a3:8d3:1319:8a2e:370:7348%5D:443" - /// "dns://8.8.8.8/foo.googleapis.com:8080" - /// "dns://8.8.8.8/foo.googleapis.com" - /// "zookeeper://zk.example.com:9900/example_service" + /// "" + /// "" + /// "" + /// "" + /// "" + /// "" + /// "" /// /// Credentials must implement the [`ChannelCredentials`] trait. /// @@ -326,7 +326,7 @@ impl ActiveChannel { while let Some(w) = wqrx.recv().await { match w { WorkQueueItem::ScheduleResolver => { - resolver.work(&mut resolver_channel_controller) + resolver.work(&mut resolver_channel_controller); } WorkQueueItem::ResolveNow => resolver.resolve_now(), WorkQueueItem::ScheduleLbPolicy(data) => { diff --git a/grpc/src/client/interceptor.rs b/grpc/src/client/interceptor.rs index f1a08b558..8acf85431 100644 --- a/grpc/src/client/interceptor.rs +++ b/grpc/src/client/interceptor.rs @@ -588,14 +588,14 @@ mod test { } /// An Invoke impl that can be controlled via its paired - /// MockInvokerController. + /// `MockInvokerController`. #[derive(Clone)] struct MockInvoker { resp_tx: broadcast::Sender, req_tx: mpsc::Sender<(Bytes, SendOptions)>, } - /// A controller used to control the behavior of its paired MockInvoker's - /// SendStream and RecvStream. + /// A controller used to control the behavior of its paired `MockInvoker`'s + /// `SendStream` and `RecvStream`. struct MockInvokerController { resp_tx: broadcast::Sender, req_rx: mpsc::Receiver<(Bytes, SendOptions)>, @@ -884,7 +884,7 @@ mod test { RecvStreamState::Done(_) => Some(fut.await), } } - /// Resolves `self`: either returns the already-Done() result of the + /// Resolves `self`: either returns the `already-Done()` result of the /// recv operation or awaits the future and returns the result. async fn resolve(self) -> ResponseStreamItem { match self { @@ -917,7 +917,7 @@ mod test { Self { data } } } - impl<'a> SendMessage for ByteSendMsg<'a> { + impl SendMessage for ByteSendMsg<'_> { fn encode(&self) -> Result, String> { Ok(Box::new(self.data.clone())) } diff --git a/grpc/src/client/load_balancing/child_manager.rs b/grpc/src/client/load_balancing/child_manager.rs index d11c752c2..36f70cf82 100644 --- a/grpc/src/client/load_balancing/child_manager.rs +++ b/grpc/src/client/load_balancing/child_manager.rs @@ -69,17 +69,17 @@ pub struct Child { work_scheduler: Arc, } -/// A collection of data sent to a child of the ChildManager. +/// A collection of data sent to a child of the `ChildManager`. pub struct ChildUpdate<'a, T> { - /// The identifier the ChildManager should use for this child. + /// The identifier the `ChildManager` should use for this child. pub child_identifier: T, - /// The builder the ChildManager should use to create this child if it does - /// not exist. The child_policy_builder's name is effectively a part of the - /// child_identifier. If two identifiers are identical but have different + /// The builder the `ChildManager` should use to create this child if it does + /// not exist. The `child_policy_builder`'s name is effectively a part of the + /// `child_identifier`. If two identifiers are identical but have different /// builder names, they are treated as different children. pub child_policy_builder: Arc, - /// The relevant ResolverUpdate and LbConfig to send to this child. If - /// None, then resolver_update will not be called on the child. Should + /// The relevant `ResolverUpdate` and `LbConfig` to send to this child. If + /// None, then `resolver_update` will not be called on the child. Should /// generally be Some for any new children, otherwise they will not be /// called. pub child_update: Option<(ResolverUpdate, Option<&'a DynLbConfig>)>, @@ -89,8 +89,8 @@ impl ChildManager where T: Debug + PartialEq + Hash + Eq + Send + Sync + 'static, { - /// Creates a new ChildManager LB policy. shard_update is called whenever a - /// resolver_update operation occurs. + /// Creates a new `ChildManager` LB policy. `shard_update` is called whenever a + /// `resolver_update` operation occurs. pub fn new(runtime: GrpcRuntime, work_scheduler: Arc) -> Self { Self { subchannel_to_child_idx: Default::default(), @@ -163,18 +163,18 @@ where if let Some(state) = channel_controller.picker_update { self.children[child_idx].state = state; self.updated = true; - }; + } } /// Returns true if any child has updated its picker since the last call to - /// child_updated. + /// `child_updated`. pub fn child_updated(&mut self) -> bool { mem::take(&mut self.updated) } /// Retains only the child policies specified by the iterator. /// - /// If an ID is provided that does not exist in the ChildManager, it will be + /// If an ID is provided that does not exist in the `ChildManager`, it will be /// ignored. pub fn retain_children( &mut self, @@ -184,8 +184,8 @@ where } /// Resets the children and all state related to tracking them in accordance - /// with the iterator provided. When retain_only is true, any entry in - /// ids_builders that is not in the current set of children will be ignored; + /// with the iterator provided. When `retain_only` is true, any entry in + /// `ids_builders` that is not in the current set of children will be ignored; /// otherwise a new child will be built for it. fn reset_children( &mut self, @@ -270,17 +270,17 @@ where policy, work_scheduler, }); - }; + } } // Anything left in old_children will just be Dropped and cleaned up. } - /// Updates the ChildManager's children. + /// Updates the `ChildManager`'s children. /// /// `child_updates` is used to determine which children should exist (one /// for each item), how to construct them if they don't already, and what to /// send to their `resolver_update` methods, if anything. Any existing - /// children not present in child_updates will be removed. + /// children not present in `child_updates` will be removed. pub fn update<'a>( &mut self, child_updates: impl IntoIterator>, @@ -360,7 +360,7 @@ where } } - /// Forwards the incoming subchannel_update to the child that created the + /// Forwards the incoming `subchannel_update` to the child that created the /// subchannel being updated. pub fn subchannel_update( &mut self, @@ -407,7 +407,7 @@ where } } - /// Calls exit_idle on all children. + /// Calls `exit_idle` on all children. pub fn exit_idle(&mut self, channel_controller: &mut dyn ChannelController) { for child_idx in 0..self.children.len() { let child = &mut self.children[child_idx]; @@ -566,7 +566,7 @@ mod test { endpoints.push(Endpoint { addresses, ..Default::default() - }) + }); } endpoints } @@ -617,7 +617,7 @@ mod test { subchannels.push(sc); } other => panic!("unexpected event {:?}", other), - }; + } } subchannels } diff --git a/grpc/src/client/load_balancing/lazy.rs b/grpc/src/client/load_balancing/lazy.rs index 6078cef74..8a12cbb95 100644 --- a/grpc/src/client/load_balancing/lazy.rs +++ b/grpc/src/client/load_balancing/lazy.rs @@ -412,7 +412,7 @@ mod tests { assert!(rx.try_recv().is_err()); } - /// Implements both LbPolicyBuilder and LbPolicy to send events on a + /// Implements both `LbPolicyBuilder` and `LbPolicy` to send events on a /// channel. #[derive(Debug, Clone)] struct MockPolicy { diff --git a/grpc/src/client/load_balancing/mod.rs b/grpc/src/client/load_balancing/mod.rs index e517fbdcc..04d418fc3 100644 --- a/grpc/src/client/load_balancing/mod.rs +++ b/grpc/src/client/load_balancing/mod.rs @@ -54,7 +54,7 @@ pub use registry::GLOBAL_LB_REGISTRY; #[cfg(test)] pub(crate) mod test_utils; -/// An LB policy factory that produces LbPolicy instances used by the channel +/// An LB policy factory that produces `LbPolicy` instances used by the channel /// to manage connections and pick connections for RPCs. pub trait LbPolicyBuilder: Send + Sync + Debug + 'static { type LbPolicy: LbPolicy; @@ -62,9 +62,9 @@ pub trait LbPolicyBuilder: Send + Sync + Debug + 'static { /// Builds and returns a new LB policy instance. /// /// Note that build must not fail. Any optional configuration is delivered - /// via the LbPolicy's resolver_update method. + /// via the `LbPolicy`'s `resolver_update` method. /// - /// An LbPolicy instance is assumed to begin in a Connecting state that + /// An `LbPolicy` instance is assumed to begin in a Connecting state that /// queues RPCs until its first update. fn build(&self, options: LbPolicyOptions) -> Self::LbPolicy; @@ -110,20 +110,20 @@ pub trait LbPolicy: Send + Sync + Debug + 'static { ); /// Called by the channel in response to a call from the LB policy to the - /// WorkScheduler's request_work method. + /// `WorkScheduler`'s `request_work` method. fn work(&mut self, data: Option, channel_controller: &mut dyn ChannelController); - /// Called by the channel when an LbPolicy goes idle and the channel + /// Called by the channel when an `LbPolicy` goes idle and the channel /// wants it to start connecting to subchannels again. fn exit_idle(&mut self, channel_controller: &mut dyn ChannelController); } /// A collection of data configured on the channel that is constructing this -/// LbPolicy. +/// `LbPolicy`. #[derive(Debug)] pub struct LbPolicyOptions { - /// A hook into the channel's work scheduler that allows the LbPolicy to - /// request the ability to perform operations on the ChannelController. + /// A hook into the channel's work scheduler that allows the `LbPolicy` to + /// request the ability to perform operations on the `ChannelController`. pub work_scheduler: Arc, pub runtime: GrpcRuntime, } @@ -168,8 +168,8 @@ impl dyn WorkDataTrait { /// associated policy's [`work`](LbPolicy::work) method. pub type WorkData = Box; -/// Used to asynchronously request a call into the LbPolicy's work method if -/// the LbPolicy needs to provide an update without waiting for an update +/// Used to asynchronously request a call into the `LbPolicy`'s work method if +/// the `LbPolicy` needs to provide an update without waiting for an update /// from the channel first. pub trait WorkScheduler: Send + Sync + Debug { // Schedules a call into the LbPolicy's work method. If there is already a @@ -187,7 +187,7 @@ pub struct ParsedJsonLbConfig { } impl ParsedJsonLbConfig { - /// Creates a new ParsedJsonLbConfig from the provided JSON string. + /// Creates a new `ParsedJsonLbConfig` from the provided JSON string. pub fn new(json: &str) -> Result { match serde_json::from_str(json) { Ok(value) => Ok(ParsedJsonLbConfig { value }), @@ -232,25 +232,25 @@ pub trait ChannelController: Send + Sync { } /// A Picker is responsible for deciding what Subchannel to use for any given -/// request. A Picker is only used once for any RPC. If pick() returns Queue, +/// request. A Picker is only used once for any RPC. If `pick()` returns Queue, /// the channel will queue the RPC until a new Picker is produced by the -/// LbPolicy, and will call pick() on the new Picker for the request. +/// `LbPolicy`, and will call `pick()` on the new Picker for the request. /// -/// Pickers are always paired with a ConnectivityState which the channel will +/// Pickers are always paired with a `ConnectivityState` which the channel will /// expose to applications so they can predict what might happens when /// performing RPCs: /// -/// If the ConnectivityState is Idle, the Picker should ensure connections are -/// initiated by the LbPolicy that produced the Picker, and return a Queue +/// If the `ConnectivityState` is Idle, the Picker should ensure connections are +/// initiated by the `LbPolicy` that produced the Picker, and return a Queue /// result so the request is attempted the next time a Picker is produced. /// -/// If the ConnectivityState is Connecting, the Picker should return a Queue +/// If the `ConnectivityState` is Connecting, the Picker should return a Queue /// result and continue to wait for pending connections. /// -/// If the ConnectivityState is Ready, the Picker should return a Ready +/// If the `ConnectivityState` is Ready, the Picker should return a Ready /// Subchannel. /// -/// If the ConnectivityState is TransientFailure, the Picker should return an +/// If the `ConnectivityState` is `TransientFailure`, the Picker should return an /// Err with an error that describes why connections are failing. pub trait Picker: Send + Sync + Debug { /// Picks a connection to use for the request. @@ -258,7 +258,7 @@ pub trait Picker: Send + Sync + Debug { /// This function should not block. If the Picker needs to do blocking or /// time-consuming work to service this request, it should return Queue, and /// the Pick call will be repeated by the channel when a new Picker is - /// produced by the LbPolicy. + /// produced by the `LbPolicy`. fn pick(&self, request: &RequestHeaders) -> PickResult; } @@ -266,7 +266,7 @@ pub trait Picker: Send + Sync + Debug { pub enum PickResult { /// Indicates the Subchannel in the Pick should be used for the request. Pick(Pick), - /// Indicates the LbPolicy is attempting to connect to a server to use for + /// Indicates the `LbPolicy` is attempting to connect to a server to use for /// the request. Queue, /// Indicates that the request should fail with the included error status @@ -332,7 +332,7 @@ pub struct LbState { } impl PartialEq for LbState { - /// Equality for two LbStates. + /// Equality for two `LbStates`. /// /// Two `LbState`s are equal if and only if they have the same connectivity /// state and the same Picker allocation. Even if two Pickers have the same @@ -347,7 +347,7 @@ impl PartialEq for LbState { impl Eq for LbState {} impl LbState { - /// Returns a generic initial LbState which is Connecting and a picker which + /// Returns a generic initial `LbState` which is Connecting and a picker which /// queues all picks. pub fn initial() -> Self { Self { @@ -380,7 +380,7 @@ impl Debug for Pick { } } -/// OneSubchannelPicker always returns a single subchannel. +/// `OneSubchannelPicker` always returns a single subchannel. #[derive(Debug)] pub(crate) struct OneSubchannelPicker { sc: Arc, @@ -396,7 +396,7 @@ impl Picker for OneSubchannelPicker { } } -/// QueuingPicker always returns Queue. LB policies that are not actively +/// `QueuingPicker` always returns Queue. LB policies that are not actively /// Connecting should not use this picker. #[derive(Debug)] pub(crate) struct QueuingPicker; @@ -457,6 +457,6 @@ impl LbPolicy for Box { } fn exit_idle(&mut self, channel_controller: &mut dyn ChannelController) { - (**self).exit_idle(channel_controller) + (**self).exit_idle(channel_controller); } } diff --git a/grpc/src/client/load_balancing/pick_first.rs b/grpc/src/client/load_balancing/pick_first.rs index d978f2ac8..e77efc8f4 100644 --- a/grpc/src/client/load_balancing/pick_first.rs +++ b/grpc/src/client/load_balancing/pick_first.rs @@ -98,7 +98,7 @@ impl LbPolicyBuilder for PickFirstBuilder { } pub(crate) fn reg() { - super::GLOBAL_LB_REGISTRY.add_builder(PickFirstBuilder {}) + super::GLOBAL_LB_REGISTRY.add_builder(PickFirstBuilder {}); } pub struct PickFirstPolicy { @@ -928,7 +928,7 @@ mod test { let res = state.picker.pick(&RequestHeaders::default()); match res { PickResult::Pick(pick) => { - assert_eq!(pick.subchannel.address().address.to_string(), "addr1") + assert_eq!(pick.subchannel.address().address.to_string(), "addr1"); } other => panic!("unexpected pick result {:?}", other), } diff --git a/grpc/src/client/load_balancing/round_robin.rs b/grpc/src/client/load_balancing/round_robin.rs index 3a4bca22c..1b27cd775 100644 --- a/grpc/src/client/load_balancing/round_robin.rs +++ b/grpc/src/client/load_balancing/round_robin.rs @@ -220,7 +220,7 @@ impl LbPolicy for RoundRobinPolicy { } } -/// Register round robin as a LbPolicy. +/// Register round robin as a `LbPolicy`. pub(crate) fn reg() { START.call_once(|| { GLOBAL_LB_REGISTRY.add_builder(RoundRobinBuilder {}); @@ -358,7 +358,7 @@ mod test { endpoints.push(Endpoint { addresses, ..Default::default() - }) + }); } endpoints } @@ -482,7 +482,7 @@ mod test { channel_controller.request_resolution(); } return Ok(()); - }; + } let endpoints = update.endpoints.unwrap(); let new_addresses = addresses_from_endpoints(&endpoints); if new_addresses.is_empty() { @@ -583,7 +583,7 @@ mod test { subchannels.push(sc); } other => panic!("unexpected event {:?}", other), - }; + } } subchannels } @@ -693,7 +693,7 @@ mod test { match rx_events.recv().unwrap() { TestEvent::RequestResolution => {} other => panic!("unexpected event {:?}", other), - }; + } } fn verify_no_activity(rx_events: &mut mpsc::Receiver) { @@ -856,7 +856,7 @@ mod test { match picker.pick(&req) { PickResult::Pick(pick) => { println!("picked subchannel is {}", pick.subchannel); - picked.push(pick.subchannel.clone()) + picked.push(pick.subchannel.clone()); } other => panic!("unexpected pick result {}", other), } @@ -942,7 +942,7 @@ mod test { match picker.pick(&req) { PickResult::Pick(pick) => { println!("picked subchannel is {}", pick.subchannel); - picked.push(pick.subchannel.clone()) + picked.push(pick.subchannel.clone()); } other => panic!("unexpected pick result {}", other), } @@ -968,7 +968,7 @@ mod test { match new_picker.pick(&req) { PickResult::Pick(pick) => { println!("picked subchannel is {}", pick.subchannel); - picked.push(pick.subchannel.clone()) + picked.push(pick.subchannel.clone()); } other => panic!("unexpected pick result {}", other), } diff --git a/grpc/src/client/load_balancing/subchannel.rs b/grpc/src/client/load_balancing/subchannel.rs index 2b392327f..b511e2283 100644 --- a/grpc/src/client/load_balancing/subchannel.rs +++ b/grpc/src/client/load_balancing/subchannel.rs @@ -38,7 +38,7 @@ use crate::core::Address; /// Represents the current state of a Subchannel. #[derive(Debug, Clone)] pub struct SubchannelState { - /// The connectivity state of the subchannel. See SubChannel for a + /// The connectivity state of the subchannel. See `SubChannel` for a /// description of the various states and their valid transitions. pub connectivity_state: ConnectivityState, // Set if connectivity state is TransientFailure to describe the most recent @@ -119,13 +119,13 @@ pub(crate) mod private { /// /// - Subchannels start IDLE. /// -/// - IDLE transitions to CONNECTING when connect() is called. +/// - IDLE transitions to CONNECTING when `connect()` is called. /// -/// - CONNECTING transitions to READY on success or TRANSIENT_FAILURE on error. +/// - CONNECTING transitions to READY on success or `TRANSIENT_FAILURE` on error. /// /// - READY transitions to IDLE when the connection is lost. /// -/// - TRANSIENT_FAILURE transitions to IDLE when the reconnect backoff timer has +/// - `TRANSIENT_FAILURE` transitions to IDLE when the reconnect backoff timer has /// expired. This timer scales exponentially and is reset when the subchannel /// becomes READY. /// @@ -238,7 +238,7 @@ pub trait ForwardingSubchannel: DynHash + DynPartialEq + Any + Send + Sync { } fn connect(&self) { - self.delegate().connect() + self.delegate().connect(); } } @@ -252,7 +252,7 @@ impl Subchannel for T { } fn connect(&self) { - self.connect() + self.connect(); } } impl private::Sealed for T {} diff --git a/grpc/src/client/load_balancing/subchannel_sharing.rs b/grpc/src/client/load_balancing/subchannel_sharing.rs index 7cd0b612a..3ffcf16fd 100644 --- a/grpc/src/client/load_balancing/subchannel_sharing.rs +++ b/grpc/src/client/load_balancing/subchannel_sharing.rs @@ -126,7 +126,7 @@ impl LbPolicy for SubchannelSharing { for ext in ext_subchannels { self.delegate - .subchannel_update(ext, state, &mut channel_controller) + .subchannel_update(ext, state, &mut channel_controller); } } @@ -208,7 +208,7 @@ struct SharingChannelController<'a> { delegate: &'a mut dyn ChannelController, } -impl<'a> ChannelController for SharingChannelController<'a> { +impl ChannelController for SharingChannelController<'_> { fn new_subchannel(&mut self, address: &Address) -> (Arc, SubchannelState) { let mut inner = self.balancer_inner.lock().unwrap(); diff --git a/grpc/src/client/load_balancing/test_utils.rs b/grpc/src/client/load_balancing/test_utils.rs index cabe21cbf..cb2bd6adc 100644 --- a/grpc/src/client/load_balancing/test_utils.rs +++ b/grpc/src/client/load_balancing/test_utils.rs @@ -199,7 +199,7 @@ impl Debug for StubPolicyFuncs { } } -/// Data holds test data that will be passed all to functions in PolicyFuncs +/// Data holds test data that will be passed all to functions in `PolicyFuncs` #[derive(Debug)] pub(crate) struct StubPolicyData { pub lb_policy_options: LbPolicyOptions, @@ -207,7 +207,7 @@ pub(crate) struct StubPolicyData { } impl StubPolicyData { - /// Creates an instance of StubPolicyData. + /// Creates an instance of `StubPolicyData`. pub fn new(lb_policy_options: LbPolicyOptions) -> Self { Self { test_data: None, @@ -271,7 +271,7 @@ impl StubPolicy { } } -/// StubPolicyBuilder builds a StubLbPolicy. +/// `StubPolicyBuilder` builds a `StubLbPolicy`. #[derive(Debug)] pub(crate) struct StubPolicyBuilder { name: &'static str, @@ -311,5 +311,5 @@ impl LbPolicyBuilder for StubPolicyBuilder { } pub(crate) fn reg_stub_policy(name: &'static str, funcs: StubPolicyFuncs) { - super::GLOBAL_LB_REGISTRY.add_dyn_builder(Arc::new(StubPolicyBuilder { name, funcs })) + super::GLOBAL_LB_REGISTRY.add_dyn_builder(Arc::new(StubPolicyBuilder { name, funcs })); } diff --git a/grpc/src/client/metadata_utils.rs b/grpc/src/client/metadata_utils.rs index 84b3408da..11948d28f 100644 --- a/grpc/src/client/metadata_utils.rs +++ b/grpc/src/client/metadata_utils.rs @@ -62,10 +62,10 @@ impl Intercept for AttachHeadersInterceptor { for kv in self.md.iter() { match kv { crate::metadata::KeyAndValueRef::Ascii(key, value) => { - incoming_meta.append(key, value.clone()) + incoming_meta.append(key, value.clone()); } crate::metadata::KeyAndValueRef::Binary(key, value) => { - incoming_meta.append_bin(key, value.clone()) + incoming_meta.append_bin(key, value.clone()); } } } diff --git a/grpc/src/client/mod.rs b/grpc/src/client/mod.rs index 62b1cef9b..a1df9121e 100644 --- a/grpc/src/client/mod.rs +++ b/grpc/src/client/mod.rs @@ -171,7 +171,7 @@ pub trait DynInvoke: Send + Sync { /// Starts an RPC, returning the send and receive streams to interact with /// it. /// - /// Note that dyn_invoke is asynchronous, and may block as needed if the + /// Note that `dyn_invoke` is asynchronous, and may block as needed if the /// channel is still connecting or if the connection the RPC is routed to /// has reached its maximum stream limit. async fn dyn_invoke( @@ -205,7 +205,7 @@ pub trait InvokeOnce: Sync { /// Starts an RPC, returning the send and receive streams to interact with /// it. /// - /// Note that invoke_once is asynchronous, and may block as needed if the + /// Note that `invoke_once` is asynchronous, and may block as needed if the /// channel is still connecting or if the connection the RPC is routed to /// has reached its maximum stream limit. async fn invoke_once( @@ -238,13 +238,13 @@ impl InvokeOnce for &T { pub trait SendStream { /// Sends `msg` on the stream. If `Err(())` is returned, the message could /// not be delivered because the stream was closed. Future calls to - /// SendStream will do nothing. + /// `SendStream` will do nothing. /// /// # Cancel safety /// /// This method is not intended to be cancellation safe. If the returned /// future is not polled to completion, the behavior of any subsequent calls - /// to the SendStream are undefined and data may be lost. + /// to the `SendStream` are undefined and data may be lost. async fn send(&mut self, msg: &dyn SendMessage, options: SendOptions) -> Result<(), ()>; } @@ -262,7 +262,7 @@ impl DynSendStream for T { } } -impl<'a> SendStream for Box { +impl SendStream for Box { async fn send(&mut self, msg: &dyn SendMessage, options: SendOptions) -> Result<(), ()> { (**self).dyn_send(msg, options).await } @@ -309,11 +309,11 @@ impl SendOptions { /// /// A response stream must always contain items exactly as follows: /// -/// [Headers *Message] Trailers *StreamClosed +/// [Headers *Message] Trailers *`StreamClosed` /// /// That is: optionally, a Headers value and any number of Message values /// (including zero), followed by a required Trailers value. A response stream -/// should not be used after Trailers, but reads should return StreamClosed if +/// should not be used after Trailers, but reads should return `StreamClosed` if /// it is. #[derive(Debug, Clone)] pub enum ResponseStreamItem { @@ -343,7 +343,7 @@ pub trait RecvStream { /// /// This method is not intended to be cancellation safe. If the returned /// future is not polled to completion, the behavior of any subsequent calls - /// to the RecvStream are undefined and data may be lost. + /// to the `RecvStream` are undefined and data may be lost. async fn recv(&mut self, msg: &mut dyn RecvMessage) -> ResponseStreamItem; } @@ -361,7 +361,7 @@ impl DynRecvStream for T { } } -impl<'a> RecvStream for Box { +impl RecvStream for Box { async fn recv(&mut self, msg: &mut dyn RecvMessage) -> ResponseStreamItem { (**self).dyn_recv(msg).await } @@ -375,7 +375,7 @@ pub struct ResponseHeaders { } impl ResponseHeaders { - /// Returns a default ResponseHeaders instance. + /// Returns a default `ResponseHeaders` instance. pub fn new(connection_info: ConnectionInfo) -> Self { Self { metadata: MetadataMap::default(), @@ -409,7 +409,7 @@ impl ResponseHeaders { self } - /// Returns a reference to the connection_info in these headers. + /// Returns a reference to the `connection_info` in these headers. pub fn connection_info(&self) -> &ConnectionInfo { &self.connection_info } @@ -425,7 +425,7 @@ pub struct RequestHeaders { } impl RequestHeaders { - /// Returns a default RequestHeaders instance. + /// Returns a default `RequestHeaders` instance. pub fn new() -> Self { Self::default() } @@ -457,7 +457,7 @@ impl RequestHeaders { &mut self.metadata } - /// Returns the owned fields in the RequestHeaders. + /// Returns the owned fields in the `RequestHeaders`. // TODO: make public once fields are fixed. pub(crate) fn into_parts(self) -> (String, MetadataMap) { (self.method_name, self.metadata) @@ -525,7 +525,7 @@ impl Trailers { /// information will not be available in trailers in any the following /// circumstances: /// - /// 1. A ResponseHeaders was already present on the response stream. + /// 1. A `ResponseHeaders` was already present on the response stream. /// /// 2. The error was generated locally on the client before a connection was /// chosen for the RPC. diff --git a/grpc/src/client/name_resolution/backoff.rs b/grpc/src/client/name_resolution/backoff.rs index 6a75e4291..9bf522988 100644 --- a/grpc/src/client/name_resolution/backoff.rs +++ b/grpc/src/client/name_resolution/backoff.rs @@ -51,7 +51,7 @@ pub(crate) struct ExponentialBackoff { } /// This is a backoff configuration with the default values specified -/// at https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. +/// at . /// /// This should be useful for callers who want to configure backoff with /// non-default values only for a subset of the options. @@ -78,7 +78,7 @@ impl BackoffConfig { Err("jitter must be greater than or equal to 0")?; } if self.jitter > 1.0 { - Err("jitter must be less than or equal to 1")? + Err("jitter must be less than or equal to 1")?; } Ok(()) } diff --git a/grpc/src/client/name_resolution/dns/mod.rs b/grpc/src/client/name_resolution/dns/mod.rs index 066295c32..dedc6b194 100644 --- a/grpc/src/client/name_resolution/dns/mod.rs +++ b/grpc/src/client/name_resolution/dns/mod.rs @@ -351,7 +351,7 @@ fn parse_endpoint_and_authority(target: &Target) -> Result /// Takes the user input string of the format "host:port" and default port, /// returns the parsed host and port. If string doesn't specify a port, the -/// default_port is returned. If the string doesn't specify the host, +/// `default_port` is returned. If the string doesn't specify the host, /// Ok(None) is returned. fn parse_host_port(host_and_port: &str, default_port: u16) -> Result, String> { // We need to use the https scheme otherwise url::Url::parse doesn't convert diff --git a/grpc/src/client/name_resolution/mod.rs b/grpc/src/client/name_resolution/mod.rs index a50a33536..4cc320fc3 100644 --- a/grpc/src/client/name_resolution/mod.rs +++ b/grpc/src/client/name_resolution/mod.rs @@ -62,7 +62,7 @@ pub(crate) mod unix; pub(crate) mod unix_abstract; /// Target represents a target for gRPC, as specified in: -/// https://github.com/grpc/grpc/blob/master/doc/naming.md. +/// . /// It is parsed from the target string that gets passed during channel creation /// by the user. gRPC passes it to the resolver and the balancer. /// @@ -91,7 +91,7 @@ impl FromStr for Target { } /// Target represents a target for gRPC, as specified in: -/// https://github.com/grpc/grpc/blob/master/doc/naming.md. +/// . /// It is parsed from the target string that gets passed during channel creation /// by the user. gRPC passes it to the resolver and the balancer. /// @@ -151,7 +151,7 @@ pub trait ResolverBuilder: Send + Sync { /// Builds a name resolver instance. /// /// Note that build must not fail. Instead, an erroring Resolver may be - /// returned that calls ChannelController.update() with an Err value. + /// returned that calls `ChannelController.update()` with an Err value. fn build(&self, target: &Target, options: ResolverOptions) -> Box; /// Reports the URI scheme handled by this name resolver. @@ -165,7 +165,7 @@ pub trait ResolverBuilder: Send + Sync { /// /// By default, this method returns the path portion of the target URI, /// with the leading prefix removed and percent-encoded based on - /// https://datatracker.ietf.org/doc/html/rfc3986#section-3.2. + /// . fn default_authority(&self, target: &Target) -> String { static CUSTOM_AUTHORITY_SET: &AsciiSet = &NON_ALPHANUMERIC // Unreserved characters @@ -219,7 +219,7 @@ pub struct ResolverOptions { pub runtime: GrpcRuntime, /// A hook into the channel's work scheduler that allows the Resolver to - /// request the ability to perform operations on the ChannelController. + /// request the ability to perform operations on the `ChannelController`. pub work_scheduler: Arc, } @@ -264,13 +264,13 @@ pub trait ChannelController: Send + Sync { fn update(&mut self, update: ResolverUpdate) -> Result<(), String>; /// Parses the provided JSON service config and returns an instance of a - /// ParsedServiceConfig. + /// `ParsedServiceConfig`. fn parse_service_config(&self, config: &str) -> ParseResult; } #[derive(Clone, Debug)] #[non_exhaustive] -/// ResolverUpdate contains the current Resolver state relevant to the +/// `ResolverUpdate` contains the current Resolver state relevant to the /// channel. pub struct ResolverUpdate { /// Attributes contains arbitrary data about the resolver intended for @@ -289,7 +289,7 @@ pub struct ResolverUpdate { /// An optional human-readable note describing context about the /// resolution, to be passed along to the LB policy for inclusion in /// RPC failure status messages in cases where neither endpoints nor - /// service_config has a non-OK status. For example, a resolver that + /// `service_config` has a non-OK status. For example, a resolver that /// returns an empty endpoint list but a valid service config may set /// to this to something like "no DNS entries found for ". pub resolution_note: Option, diff --git a/grpc/src/client/name_resolution/proxy_resolver.rs b/grpc/src/client/name_resolution/proxy_resolver.rs index 3f6444a83..179003e3e 100644 --- a/grpc/src/client/name_resolution/proxy_resolver.rs +++ b/grpc/src/client/name_resolution/proxy_resolver.rs @@ -216,7 +216,7 @@ struct InterceptingController<'a> { proxy_options: &'a Arc, } -impl<'a> ChannelController for InterceptingController<'a> { +impl ChannelController for InterceptingController<'_> { fn update(&mut self, mut update: ResolverUpdate) -> Result<(), String> { if let Ok(endpoints) = &mut update.endpoints { for endpoint in endpoints { diff --git a/grpc/src/client/name_resolution/registry.rs b/grpc/src/client/name_resolution/registry.rs index 2bdb144e7..612f7073f 100644 --- a/grpc/src/client/name_resolution/registry.rs +++ b/grpc/src/client/name_resolution/registry.rs @@ -46,7 +46,7 @@ impl ResolverRegistry { } } - /// Add a name resolver into the registry. builder.scheme() will + /// Add a name resolver into the registry. `builder.scheme()` will /// be used as the scheme registered with this builder. If multiple /// resolvers are registered with the same name, the one registered last /// will take effect. @@ -58,7 +58,7 @@ impl ResolverRegistry { self.try_add_builder(builder).unwrap(); } - /// Add a name resolver into the registry. builder.scheme() will + /// Add a name resolver into the registry. `builder.scheme()` will /// be used as the scheme registered with this builder. If multiple /// resolvers are registered with the same name, the one registered last /// will take effect. diff --git a/grpc/src/client/name_resolution/test_utils.rs b/grpc/src/client/name_resolution/test_utils.rs index e75135208..dfe494b4b 100644 --- a/grpc/src/client/name_resolution/test_utils.rs +++ b/grpc/src/client/name_resolution/test_utils.rs @@ -70,7 +70,7 @@ impl TestChannelController { } pub(crate) fn set_update_result(&mut self, update_result: Result<(), String>) { - self.update_result = update_result + self.update_result = update_result; } } diff --git a/grpc/src/client/test_util.rs b/grpc/src/client/test_util.rs index 40066235e..3a978e0c1 100644 --- a/grpc/src/client/test_util.rs +++ b/grpc/src/client/test_util.rs @@ -41,7 +41,7 @@ use crate::client::SendStream; use crate::core::RecvMessage; use crate::core::SendMessage; -/// Implements a stream that sinks writes and only returns StreamClosed. +/// Implements a stream that sinks writes and only returns `StreamClosed`. pub(crate) struct NopStream; impl SendStream for NopStream { async fn send(&mut self, _item: &dyn SendMessage, _options: SendOptions) -> Result<(), ()> { @@ -54,7 +54,7 @@ impl RecvStream for NopStream { } } -/// Implements an Invoke which only returns NopStreams. +/// Implements an Invoke which only returns `NopStreams`. #[derive(Clone)] pub(crate) struct NopInvoker; impl Invoke for NopInvoker { @@ -69,7 +69,7 @@ impl Invoke for NopInvoker { } } -/// Implements an InvokeOnce which only returns NopStreams. +/// Implements an `InvokeOnce` which only returns `NopStreams`. pub(crate) struct NopOnceInvoker; impl InvokeOnce for NopOnceInvoker { type SendStream = NopStream; @@ -83,7 +83,7 @@ impl InvokeOnce for NopOnceInvoker { } } -/// Implements a RecvMessage that does not decode. +/// Implements a `RecvMessage` that does not decode. pub(crate) struct NopRecvMessage; impl RecvMessage for NopRecvMessage { fn decode(&mut self, _data: &mut dyn Buf) -> Result<(), String> { @@ -91,7 +91,7 @@ impl RecvMessage for NopRecvMessage { } } -/// Implements a RecvMessage that simply copies the data received into `data`. +/// Implements a `RecvMessage` that simply copies the data received into `data`. pub(crate) struct ByteRecvMsg { pub data: Option, } @@ -107,7 +107,7 @@ impl RecvMessage for ByteRecvMsg { } } -/// Implements a SendMessage that simply copies `data` as its output. +/// Implements a `SendMessage` that simply copies `data` as its output. pub(crate) struct ByteSendMsg<'a> { pub data: &'a Bytes, } @@ -116,7 +116,7 @@ impl<'a> ByteSendMsg<'a> { Self { data } } } -impl<'a> SendMessage for ByteSendMsg<'a> { +impl SendMessage for ByteSendMsg<'_> { fn encode(&self) -> Result, String> { Ok(Box::new(self.data.clone())) } @@ -177,7 +177,7 @@ impl Invoke for MockInvoker { } } -/// Implements the SendStream for MockInvoker. +/// Implements the `SendStream` for `MockInvoker`. pub(crate) struct MockSendStream(pub mpsc::Sender<(Bytes, SendOptions)>); impl SendStream for MockSendStream { async fn send(&mut self, item: &dyn SendMessage, options: SendOptions) -> Result<(), ()> { @@ -189,7 +189,7 @@ impl SendStream for MockSendStream { } } -/// Implements the RecvStream for MockInvoker. +/// Implements the `RecvStream` for `MockInvoker`. pub(crate) struct MockRecvStream(pub broadcast::Receiver); impl RecvStream for MockRecvStream { async fn recv(&mut self, _msg: &mut dyn RecvMessage) -> ResponseStreamItem { diff --git a/grpc/src/client/transport/registry.rs b/grpc/src/client/transport/registry.rs index bb9acec75..f68435951 100644 --- a/grpc/src/client/transport/registry.rs +++ b/grpc/src/client/transport/registry.rs @@ -42,7 +42,7 @@ impl Debug for TransportRegistry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let m = self.inner.lock().unwrap(); for key in m.keys() { - write!(f, "k: {key:?}")? + write!(f, "k: {key:?}")?; } Ok(()) } diff --git a/grpc/src/client/transport/tonic/test.rs b/grpc/src/client/transport/tonic/test.rs index 35d48dd9f..e5dae6307 100644 --- a/grpc/src/client/transport/tonic/test.rs +++ b/grpc/src/client/transport/tonic/test.rs @@ -1207,7 +1207,7 @@ async fn tonic_transport_recv_drop_sends_rst_stream() { None => { panic!("Expected RST_STREAM, got clean close (EOS)"); } - }; + } }); let builder = GLOBAL_TRANSPORT_REGISTRY @@ -1254,5 +1254,5 @@ async fn tonic_transport_recv_drop_sends_rst_stream() { // Verify the send stream has ended. let req = WrappedEchoRequest(EchoRequest::default()); - assert!(tx.send(&req, SendOptions::default()).await.is_err()) + assert!(tx.send(&req, SendOptions::default()).await.is_err()); } diff --git a/grpc/src/core/mod.rs b/grpc/src/core/mod.rs index 426998b62..889a0ac41 100644 --- a/grpc/src/core/mod.rs +++ b/grpc/src/core/mod.rs @@ -89,7 +89,7 @@ where } impl dyn SendMessage + '_ { - /// Downcasts the SendMessage to T::Target if the SendMessage contains a T. + /// Downcasts the `SendMessage` to `T::Target` if the `SendMessage` contains a T. pub fn downcast_ref(&self) -> Option<&T::Target<'_>> where T::Target<'static>: 'static, @@ -106,7 +106,7 @@ impl dyn SendMessage + '_ { #[allow(unused)] impl dyn RecvMessage + '_ { - /// Downcasts the RecvMessage to T::Target if the RecvMessage contains a T. + /// Downcasts the `RecvMessage` to `T::Target` if the `RecvMessage` contains a T. pub fn downcast_mut(&mut self) -> Option<&mut T::Target<'_>> where T::Target<'static>: 'static, @@ -126,7 +126,7 @@ impl dyn RecvMessage + '_ { #[derive(Debug, Clone, Default, PartialEq, Eq)] pub struct Address { /// The network type is used to identify what kind of transport to create - /// when connecting to this address. Typically TCP_IP_ADDRESS_TYPE. + /// when connecting to this address. Typically `TCP_IP_ADDRESS_TYPE`. pub network_type: &'static str, /// The address itself is passed to the transport in order to create a diff --git a/grpc/src/credentials/call.rs b/grpc/src/credentials/call.rs index 1145085e7..9aea7832f 100644 --- a/grpc/src/credentials/call.rs +++ b/grpc/src/credentials/call.rs @@ -22,7 +22,7 @@ * */ -//! Definitions and implementations for call credentials (e.g. OAuth2). +//! Definitions and implementations for call credentials (e.g. `OAuth2`). use std::fmt::Debug; use std::sync::Arc; @@ -107,7 +107,7 @@ impl ClientConnectionSecurityInfo { } /// A trait for credentials that need to attach security information to every -/// individual RPC (e.g., OAuth2 tokens, JWTs). +/// individual RPC (e.g., `OAuth2` tokens, JWTs). #[async_trait] pub trait CallCredentials: Send + Sync + Debug { /// Generates the authentication metadata for a specific call. diff --git a/grpc/src/credentials/client.rs b/grpc/src/credentials/client.rs index d15550cf3..f83a5e251 100644 --- a/grpc/src/credentials/client.rs +++ b/grpc/src/credentials/client.rs @@ -92,7 +92,7 @@ impl ClientHandshakeInfo { /// A credential that combines [`ChannelCredentials`] with [`CallCredentials`]. /// -/// This is used to attach per-call authentication (like OAuth2 tokens) to a +/// This is used to attach per-call authentication (like `OAuth2` tokens) to a /// secure channel (like TLS). pub struct CompositeChannelCredentials { channel_creds: T, diff --git a/grpc/src/credentials/local.rs b/grpc/src/credentials/local.rs index 31fe1daf8..16e0aa406 100644 --- a/grpc/src/credentials/local.rs +++ b/grpc/src/credentials/local.rs @@ -82,7 +82,7 @@ impl ValidateAuthority for LocalConnectionAuthorityValidator { /// Returns the security level for a local connection. /// It returns an error if a connection is not local. -/// Refer to L62: https://github.com/grpc/proposal/blob/master/L62-core-call-credential-security-level.md +/// Refer to L62: fn security_level_for_endpoint( peer_addr: &str, network_type: &str, diff --git a/grpc/src/credentials/mod.rs b/grpc/src/credentials/mod.rs index f3d5a48aa..bd3870447 100644 --- a/grpc/src/credentials/mod.rs +++ b/grpc/src/credentials/mod.rs @@ -22,7 +22,7 @@ * */ -//! Authentication and security credentials (e.g. TLS and OAuth2). +//! Authentication and security credentials (e.g. TLS and `OAuth2`). //! //! This module provides traits and types for handling credentials in gRPC, //! including channel credentials (for securing connections) and call @@ -65,7 +65,7 @@ use crate::rt::GrpcRuntime; /// [`CompositeChannelCredentials`]. #[async_trait] pub trait ChannelCredentials: Send + Sync + 'static { - /// Provides the ProtocolInfo of these credentials. + /// Provides the `ProtocolInfo` of these credentials. fn info(&self) -> &ProtocolInfo; /// Returns call credentials to be used for all RPCs made on a connection. @@ -101,7 +101,7 @@ pub trait ChannelCredentials: Send + Sync + 'static { /// transport security protocols (e.g., TLS, ALTS). #[async_trait] pub trait ServerCredentials: Send + Sync + 'static { - /// Provides the ProtocolInfo of these credentials. + /// Provides the `ProtocolInfo` of these credentials. fn info(&self) -> &ProtocolInfo; /// Performs the server-side authentication handshake. @@ -146,7 +146,7 @@ pub struct SecurityInfo { } impl SecurityInfo { - /// Creates a new SecurityInfo for the security protocol given. + /// Creates a new `SecurityInfo` for the security protocol given. pub fn new(security_protocol: &'static str) -> Self { Self { security_protocol, diff --git a/grpc/src/credentials/rustls/client/mod.rs b/grpc/src/credentials/rustls/client/mod.rs index adf112fc9..8d887ec4a 100644 --- a/grpc/src/credentials/rustls/client/mod.rs +++ b/grpc/src/credentials/rustls/client/mod.rs @@ -134,7 +134,7 @@ pub struct RustlsChannelCredentials { pub type RustlsChannelCredendials = RustlsChannelCredentials; impl RustlsChannelCredentials { - /// Constructs a new [RustlsChannelCredentials] instance from the provided + /// Constructs a new [`RustlsChannelCredentials`] instance from the provided /// configuration. pub fn new(config: ClientTlsConfig) -> Result { let provider = if let Some(p) = CryptoProvider::get_default() { @@ -188,7 +188,7 @@ impl RustlsChannelCredentials { client_config.alpn_protocols = vec![ALPN_PROTO_STR_H2.to_vec()]; client_config.resumption = rustls::client::Resumption::disabled(); if let Some(path) = config.key_log_path { - client_config.key_log = Arc::new(KeyLogFile::new(&path)) + client_config.key_log = Arc::new(KeyLogFile::new(&path)); } Ok(RustlsChannelCredentials { diff --git a/grpc/src/credentials/rustls/client/test.rs b/grpc/src/credentials/rustls/client/test.rs index ed4401fb8..ae390afb7 100644 --- a/grpc/src/credentials/rustls/client/test.rs +++ b/grpc/src/credentials/rustls/client/test.rs @@ -569,7 +569,7 @@ async fn setup_server_multi_connection( let _ = stream.shutdown().await; } Err(err) => { - println!("TLS handshake failed: {}", err) + println!("TLS handshake failed: {}", err); } } }); diff --git a/grpc/src/generated/grpc_examples_echo.rs b/grpc/src/generated/grpc_examples_echo.rs index 5545928b0..d4fccefe5 100644 --- a/grpc/src/generated/grpc_examples_echo.rs +++ b/grpc/src/generated/grpc_examples_echo.rs @@ -1,11 +1,11 @@ // This file is @generated by prost-build. -/// EchoRequest is the request for echo. +/// `EchoRequest` is the request for echo. #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct EchoRequest { #[prost(string, tag = "1")] pub message: ::prost::alloc::string::String, } -/// EchoResponse is the response for echo. +/// `EchoResponse` is the response for echo. #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct EchoResponse { #[prost(string, tag = "1")] @@ -92,7 +92,7 @@ pub mod echo_client { self.inner = self.inner.max_encoding_message_size(limit); self } - /// UnaryEcho is unary echo. + /// `UnaryEcho` is unary echo. pub async fn unary_echo( &mut self, request: impl tonic::IntoRequest, @@ -114,7 +114,7 @@ pub mod echo_client { .insert(GrpcMethod::new("grpc.examples.echo.Echo", "UnaryEcho")); self.inner.unary(req, path, codec).await } - /// ServerStreamingEcho is server side streaming. + /// `ServerStreamingEcho` is server side streaming. pub async fn server_streaming_echo( &mut self, request: impl tonic::IntoRequest, @@ -141,7 +141,7 @@ pub mod echo_client { ); self.inner.server_streaming(req, path, codec).await } - /// ClientStreamingEcho is client side streaming. + /// `ClientStreamingEcho` is client side streaming. pub async fn client_streaming_echo( &mut self, request: impl tonic::IntoStreamingRequest, @@ -165,7 +165,7 @@ pub mod echo_client { ); self.inner.client_streaming(req, path, codec).await } - /// BidirectionalStreamingEcho is bidi streaming. + /// `BidirectionalStreamingEcho` is bidi streaming. pub async fn bidirectional_streaming_echo( &mut self, request: impl tonic::IntoStreamingRequest, @@ -207,21 +207,21 @@ pub mod echo_server { clippy::let_unit_value, )] use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with EchoServer. + /// Generated trait containing gRPC methods that should be implemented for use with `EchoServer`. #[async_trait] pub trait Echo: std::marker::Send + std::marker::Sync + 'static { - /// UnaryEcho is unary echo. + /// `UnaryEcho` is unary echo. async fn unary_echo( &self, request: tonic::Request, ) -> std::result::Result, tonic::Status>; - /// Server streaming response type for the ServerStreamingEcho method. + /// Server streaming response type for the `ServerStreamingEcho` method. type ServerStreamingEchoStream: tonic::codegen::tokio_stream::Stream< Item = std::result::Result, > + std::marker::Send + 'static; - /// ServerStreamingEcho is server side streaming. + /// `ServerStreamingEcho` is server side streaming. async fn server_streaming_echo( &self, request: tonic::Request, @@ -229,18 +229,18 @@ pub mod echo_server { tonic::Response, tonic::Status, >; - /// ClientStreamingEcho is client side streaming. + /// `ClientStreamingEcho` is client side streaming. async fn client_streaming_echo( &self, request: tonic::Request>, ) -> std::result::Result, tonic::Status>; - /// Server streaming response type for the BidirectionalStreamingEcho method. + /// Server streaming response type for the `BidirectionalStreamingEcho` method. type BidirectionalStreamingEchoStream: tonic::codegen::tokio_stream::Stream< Item = std::result::Result, > + std::marker::Send + 'static; - /// BidirectionalStreamingEcho is bidi streaming. + /// `BidirectionalStreamingEcho` is bidi streaming. async fn bidirectional_streaming_echo( &self, request: tonic::Request>, diff --git a/grpc/src/inmemory/mod.rs b/grpc/src/inmemory/mod.rs index 18e9d304a..e64bfa857 100644 --- a/grpc/src/inmemory/mod.rs +++ b/grpc/src/inmemory/mod.rs @@ -255,9 +255,9 @@ pub struct InMemoryServerSendStream { } impl ServerSendStream for InMemoryServerSendStream { - async fn send<'a>( + async fn send( &mut self, - item: ServerResponseStreamItem<'a>, + item: ServerResponseStreamItem<'_>, _options: ServerSendOptions, ) -> Result<(), ()> { let inmemory_item = match item { diff --git a/grpc/src/macros.rs b/grpc/src/macros.rs index 91994842e..a92ad66a4 100644 --- a/grpc/src/macros.rs +++ b/grpc/src/macros.rs @@ -52,7 +52,7 @@ /// ``` /// /// If you have modified the output directory or message path, you should use -/// the include_generated_proto macro below instead of using this macro or +/// the `include_generated_proto` macro below instead of using this macro or /// manually include it yourself. /// /// ```rust,ignore @@ -111,7 +111,7 @@ macro_rules! include_proto { } /// Includes generated proto message, client, and server code. This macro is for -/// if you manually set output_dir instead of using the default OUT_DIR. +/// if you manually set `output_dir` instead of using the default `OUT_DIR`. /// /// You must specify the path to the `.proto` file **relative to the proto root /// directory**, without the `.proto` extension. diff --git a/grpc/src/metadata/encoding.rs b/grpc/src/metadata/encoding.rs index bea9e3bbb..a5bf5736d 100644 --- a/grpc/src/metadata/encoding.rs +++ b/grpc/src/metadata/encoding.rs @@ -39,7 +39,7 @@ use crate::private; pub struct InvalidMetadataValue {} pub trait ValueEncoding: Clone + Eq + PartialEq + Hash { - /// Returns true if the provided key is valid for this ValueEncoding type. + /// Returns true if the provided key is valid for this `ValueEncoding` type. /// For example, `Ascii::is_valid_key("a") == true`, /// `Ascii::is_valid_key("a-bin") == false`. fn is_valid_key(key: &str) -> bool; diff --git a/grpc/src/metadata/key.rs b/grpc/src/metadata/key.rs index 8a786235a..14789e8d7 100644 --- a/grpc/src/metadata/key.rs +++ b/grpc/src/metadata/key.rs @@ -143,7 +143,7 @@ impl MetadataKey { self.inner.as_str() } - /// Converts a HeaderName reference to a MetadataKey. This method assumes + /// Converts a `HeaderName` reference to a `MetadataKey`. This method assumes /// that the caller has made sure that the metadata key name has the correct /// "-bin" or non-"-bin" suffix, it does not validate its input. #[inline] diff --git a/grpc/src/metadata/map.rs b/grpc/src/metadata/map.rs index a6972011a..4be36e48c 100644 --- a/grpc/src/metadata/map.rs +++ b/grpc/src/metadata/map.rs @@ -103,7 +103,7 @@ where key: Option>, } -impl<'a, VE> Debug for ValueIter<'a, VE> +impl Debug for ValueIter<'_, VE> where VE: ValueEncoding, { @@ -124,7 +124,7 @@ pub struct GetAll<'a, VE> { key: Option>, } -impl<'a, VE> std::fmt::Debug for GetAll<'a, VE> +impl std::fmt::Debug for GetAll<'_, VE> where VE: ValueEncoding, { @@ -157,7 +157,7 @@ impl MetadataMap { MetadataMap::with_capacity(0) } - /// Convert an HTTP HeaderMap to a MetadataMap + /// Convert an HTTP `HeaderMap` to a `MetadataMap` /// /// # Errors /// @@ -186,7 +186,7 @@ impl MetadataMap { Ok(Self { headers: ret }) } - /// Convert a MetadataMap into a HTTP HeaderMap. + /// Convert a `MetadataMap` into a HTTP `HeaderMap`. /// /// Note that the "sensitive" field is not propagated as that will disable /// use of dynamic table in HPACK compression. Other gRPC implementations @@ -395,7 +395,7 @@ impl MetadataMap { /// Returns a reference to the value associated with the key. This method /// is for ascii metadata entries (those whose names don't end with - /// "-bin"). For binary entries, use get_bin. + /// "-bin"). For binary entries, use `get_bin`. /// /// If there are multiple values associated with the key, then the first one /// is returned. Use `get_all` to get all values associated with a given @@ -473,7 +473,7 @@ impl MetadataMap { /// Returns a view of all values associated with a key. This method is for /// ascii metadata entries (those whose names don't end with "-bin"). For - /// binary entries, use get_all_bin. + /// binary entries, use `get_all_bin`. /// /// The returned view does not incur any allocations and allows iterating /// the values associated with the key. See [`GetAll`] for more details. @@ -519,7 +519,7 @@ impl MetadataMap { key.get_all(self, private::Internal) } - /// Like get_all, but for Binary keys (for example "trace-proto-bin"). + /// Like `get_all`, but for Binary keys (for example "trace-proto-bin"). /// /// # Examples /// @@ -889,7 +889,7 @@ impl MetadataMap { where K: AsMetadataKey, { - key.remove_all(self, private::Internal) + key.remove_all(self, private::Internal); } /// Removes all entries matching the given binary key. @@ -901,7 +901,7 @@ impl MetadataMap { where K: AsMetadataKey, { - key.remove_all(self, private::Internal) + key.remove_all(self, private::Internal); } pub(crate) fn merge(&mut self, other: MetadataMap) { @@ -1317,7 +1317,7 @@ impl AsMetadataKey for String { #[doc(hidden)] #[inline] fn remove_all(self, map: &mut MetadataMap, token: private::Internal) { - AsMetadataKey::::remove_all(self.as_str(), map, token) + AsMetadataKey::::remove_all(self.as_str(), map, token); } } @@ -1343,7 +1343,7 @@ impl AsMetadataKey for &String { #[doc(hidden)] #[inline] fn remove_all(self, map: &mut MetadataMap, token: private::Internal) { - AsMetadataKey::::remove_all(self.as_str(), map, token) + AsMetadataKey::::remove_all(self.as_str(), map, token); } } diff --git a/grpc/src/metadata/mod.rs b/grpc/src/metadata/mod.rs index 1c4279c48..49caef00a 100644 --- a/grpc/src/metadata/mod.rs +++ b/grpc/src/metadata/mod.rs @@ -54,7 +54,7 @@ pub use value::AsciiMetadataValue; pub use value::BinaryMetadataValue; pub use value::MetadataValue; -/// The metadata::errors module contains types for errors that can occur +/// The `metadata::errors` module contains types for errors that can occur /// while handling gRPC custom metadata. pub mod errors { pub use super::encoding::InvalidMetadataValue; diff --git a/grpc/src/metadata/value.rs b/grpc/src/metadata/value.rs index 9a10e1747..2b7cbfc90 100644 --- a/grpc/src/metadata/value.rs +++ b/grpc/src/metadata/value.rs @@ -149,7 +149,7 @@ impl MetadataValue { } /// Mark that the metadata value represents sensitive information. Sensitive - /// values are not included in the [std::fmt::Debug] output. + /// values are not included in the [`std::fmt::Debug`] output. /// /// Metadata values are sensitive by default. /// @@ -171,7 +171,7 @@ impl MetadataValue { /// Returns `true` if the value represents sensitive data. /// - /// Sensitive values are not included in the [std::fmt::Debug] output. + /// Sensitive values are not included in the [`std::fmt::Debug`] output. /// /// Note that sensitivity is not factored into equality or ordering. /// @@ -562,13 +562,13 @@ impl Error for ToStrError {} impl Hash for MetadataValue { fn hash(&self, state: &mut H) { - self.inner.data.hash(state) + self.inner.data.hash(state); } } impl Hash for MetadataValue { fn hash(&self, state: &mut H) { - self.inner.data.hash(state) + self.inner.data.hash(state); } } diff --git a/grpc/src/rt/mod.rs b/grpc/src/rt/mod.rs index fcf87588e..3800f147f 100644 --- a/grpc/src/rt/mod.rs +++ b/grpc/src/rt/mod.rs @@ -70,9 +70,9 @@ pub trait Runtime: Send + Sync + Debug { /// Spawns the given asynchronous task to run in the background. fn spawn(&self, task: Pin + Send + 'static>>) -> BoxedTaskHandle; - /// Creates and returns an instance of a DNSResolver, optionally - /// configured by the ResolverOptions struct. This method may return an - /// error if it fails to create the DNSResolver. + /// Creates and returns an instance of a `DNSResolver`, optionally + /// configured by the `ResolverOptions` struct. This method may return an + /// error if it fails to create the `DNSResolver`. fn get_dns_resolver(&self, opts: ResolverOptions) -> Result, String>; /// Returns a future that completes after the specified duration. @@ -152,7 +152,7 @@ pub struct UnixSocketOptions { _priv: (), } -/// GrpcEndpoint is a generic stream-oriented network connection. +/// `GrpcEndpoint` is a generic stream-oriented network connection. // This trait is sealed since we may need to change the read and write // methods to align closely with the gRPC C++ implementations. For example, // the read method may be responsible for allocating the buffer and @@ -277,7 +277,7 @@ impl AsyncWrite for EndpointIoStream { } } -/// A wrapper that implements [GrpcEndpoint] for an asynchronous I/O stream. +/// A wrapper that implements [`GrpcEndpoint`] for an asynchronous I/O stream. pub(crate) struct StreamEndpoint { inner: T, peer_addr: Box, diff --git a/grpc/src/rt/tokio/hickory_resolver.rs b/grpc/src/rt/tokio/hickory_resolver.rs index 859b3cfab..464f61f86 100644 --- a/grpc/src/rt/tokio/hickory_resolver.rs +++ b/grpc/src/rt/tokio/hickory_resolver.rs @@ -155,7 +155,7 @@ mod tests { assert_eq!( ips_hickory, system_resolver_ips, "both resolvers should produce same IPs for localhost" - ) + ); } #[tokio::test] @@ -209,7 +209,7 @@ mod tests { let hickory_dns = super::DnsResolver::new(opts).unwrap(); let ips = hickory_dns.lookup_host_name("test.local").await.unwrap(); assert_eq!(ips, vec![Ipv4Addr::new(1, 2, 3, 4)]); - dns.shutdown().await + dns.shutdown().await; } struct FakeDns { diff --git a/grpc/src/rt/tokio/mod.rs b/grpc/src/rt/tokio/mod.rs index cdf4cc7ec..e1d1401ed 100644 --- a/grpc/src/rt/tokio/mod.rs +++ b/grpc/src/rt/tokio/mod.rs @@ -46,7 +46,7 @@ use crate::rt::TcpOptions; #[cfg(feature = "dns")] mod hickory_resolver; -/// A DNS resolver that uses tokio::net::lookup_host for resolution. It only +/// A DNS resolver that uses `tokio::net::lookup_host` for resolution. It only /// supports host lookups. struct TokioDefaultDnsResolver { _priv: (), @@ -79,7 +79,7 @@ pub(crate) struct TokioRuntime { impl TaskHandle for JoinHandle<()> { fn abort(&self) { - self.abort() + self.abort(); } } @@ -301,7 +301,7 @@ mod tests { assert!( !ips.is_empty(), "Expect localhost to resolve to more than 1 IPs." - ) + ); } #[tokio::test] @@ -309,7 +309,7 @@ mod tests { let default_resolver = TokioDefaultDnsResolver::new(ResolverOptions::default()).unwrap(); let txt = default_resolver.lookup_txt("google.com").await; - assert!(txt.is_err()) + assert!(txt.is_err()); } #[tokio::test] @@ -318,6 +318,6 @@ mod tests { server_addr: Some("8.8.8.8:53".parse().unwrap()), }; let default_resolver = TokioDefaultDnsResolver::new(opts); - assert!(default_resolver.is_err()) + assert!(default_resolver.is_err()); } } diff --git a/grpc/src/server/interceptor.rs b/grpc/src/server/interceptor.rs index f58eaa613..a1efa3401 100644 --- a/grpc/src/server/interceptor.rs +++ b/grpc/src/server/interceptor.rs @@ -104,9 +104,9 @@ mod test { struct MockSendStream; impl SendStream for MockSendStream { - async fn send<'a>( + async fn send( &mut self, - _item: ResponseStreamItem<'a>, + _item: ResponseStreamItem<'_>, _options: SendOptions, ) -> Result<(), ()> { Ok(()) diff --git a/grpc/src/server/mod.rs b/grpc/src/server/mod.rs index 99082162a..f3d4c2c9f 100644 --- a/grpc/src/server/mod.rs +++ b/grpc/src/server/mod.rs @@ -201,7 +201,7 @@ impl Server { where H: Handle + Send + Sync + 'static, { - self.handler = Some(Arc::new(h)) + self.handler = Some(Arc::new(h)); } /// Serves on the given listener until it stops producing connections. @@ -378,12 +378,8 @@ pub trait SendStream { /// /// This method is not intended to be cancellation safe. If the returned /// future is not polled to completion, the behavior of any subsequent calls - /// to the SendStream are undefined and data may be lost. - async fn send<'a>( - &mut self, - item: ResponseStreamItem<'a>, - options: SendOptions, - ) -> Result<(), ()>; + /// to the `SendStream` are undefined and data may be lost. + async fn send(&mut self, item: ResponseStreamItem<'_>, options: SendOptions) -> Result<(), ()>; } #[doc(hidden)] @@ -407,27 +403,19 @@ impl DynSendStream for T { } } -impl<'b> SendStream for &mut (dyn DynSendStream + 'b) { - async fn send<'a>( - &mut self, - item: ResponseStreamItem<'a>, - options: SendOptions, - ) -> Result<(), ()> { +impl SendStream for &mut (dyn DynSendStream + '_) { + async fn send(&mut self, item: ResponseStreamItem<'_>, options: SendOptions) -> Result<(), ()> { (**self).dyn_send(item, options).await } } -impl<'b> SendStream for Box { - async fn send<'a>( - &mut self, - item: ResponseStreamItem<'a>, - options: SendOptions, - ) -> Result<(), ()> { +impl SendStream for Box { + async fn send(&mut self, item: ResponseStreamItem<'_>, options: SendOptions) -> Result<(), ()> { (**self).dyn_send(item, options).await } } -/// Contains settings to configure a send operation on a SendStream. +/// Contains settings to configure a send operation on a `SendStream`. #[derive(Default)] #[non_exhaustive] pub struct SendOptions { @@ -452,7 +440,7 @@ pub trait RecvStream { /// /// This method is not intended to be cancellation safe. If the returned /// future is not polled to completion, the behavior of any subsequent calls - /// to the RecvStream are undefined and data may be lost. + /// to the `RecvStream` are undefined and data may be lost. async fn next(&mut self, msg: &mut dyn RecvMessage) -> Option>; } @@ -469,7 +457,7 @@ impl DynRecvStream for T { } } -impl<'a> RecvStream for Box { +impl RecvStream for Box { async fn next(&mut self, msg: &mut dyn RecvMessage) -> Option> { (**self).dyn_next(msg).await } @@ -482,7 +470,7 @@ pub struct ResponseHeaders { } impl ResponseHeaders { - /// Returns a default ResponseHeaders instance. + /// Returns a default `ResponseHeaders` instance. pub fn new() -> Self { Self::default() } @@ -520,7 +508,7 @@ pub struct RequestHeaders { } impl RequestHeaders { - /// Returns a default RequestHeaders instance. + /// Returns a default `RequestHeaders` instance. pub fn new(method_name: impl Into, connection_info: ConnectionInfo) -> Self { Self { method_name: method_name.into(), @@ -556,18 +544,18 @@ impl RequestHeaders { &mut self.metadata } - /// Replaces the connection_info of self with `connection_info`. + /// Replaces the `connection_info` of self with `connection_info`. pub fn with_connection_info(mut self, connection_info: ConnectionInfo) -> Self { self.connection_info = connection_info; self } - /// Returns a reference to the connection_info in these headers. + /// Returns a reference to the `connection_info` in these headers. pub fn connection_info(&self) -> &ConnectionInfo { &self.connection_info } - /// Returns the owned fields in the RequestHeaders. + /// Returns the owned fields in the `RequestHeaders`. // TODO: make public once fields are fixed. pub(crate) fn into_parts(self) -> (String, MetadataMap) { (self.method_name, self.metadata) @@ -918,9 +906,9 @@ mod tests { struct NopSendStream; impl SendStream for NopSendStream { - async fn send<'a>( + async fn send( &mut self, - _item: ResponseStreamItem<'a>, + _item: ResponseStreamItem<'_>, _options: SendOptions, ) -> Result<(), ()> { Ok(())