Skip to content

Commit

Permalink
chore(interceptor)!: Rename Interceptor call method to intercept
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto committed Dec 14, 2024
1 parent 40fb659 commit fd433bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/src/interceptor/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn intercept(req: Request<()>) -> Result<Request<()>, Status> {
struct MyInterceptor;

impl Interceptor for MyInterceptor {
fn call(&mut self, request: tonic::Request<()>) -> Result<tonic::Request<()>, Status> {
fn intercept(&mut self, request: tonic::Request<()>) -> Result<tonic::Request<()>, Status> {
Ok(request)
}
}
Expand Down
6 changes: 3 additions & 3 deletions tonic/src/service/interceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ use tower_service::Service;
/// [tower-example]: https://github.com/hyperium/tonic/tree/master/examples/src/tower
pub trait Interceptor {
/// Intercept a request before it is sent, optionally cancelling it.
fn call(&mut self, request: crate::Request<()>) -> Result<crate::Request<()>, Status>;
fn intercept(&mut self, request: crate::Request<()>) -> Result<crate::Request<()>, Status>;
}

impl<F> Interceptor for F
where
F: FnMut(crate::Request<()>) -> Result<crate::Request<()>, Status>,
{
fn call(&mut self, request: crate::Request<()>) -> Result<crate::Request<()>, Status> {
fn intercept(&mut self, request: crate::Request<()>) -> Result<crate::Request<()>, Status> {
self(request)
}
}
Expand Down Expand Up @@ -140,7 +140,7 @@ where

match self
.interceptor
.call(crate::Request::from_parts(metadata, extensions, ()))
.intercept(crate::Request::from_parts(metadata, extensions, ()))
{
Ok(req) => {
let (metadata, extensions, _) = req.into_parts();
Expand Down

0 comments on commit fd433bb

Please sign in to comment.