Skip to content

Commit

Permalink
Rename chain to handle
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-zahner committed Apr 22, 2024
1 parent ddcca65 commit f2b1c29
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lychee-lib/src/chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<T, R> Chain<T, R> {
pub(crate) async fn traverse(&self, mut input: T) -> ChainResult<T, R> {
use ChainResult::{Done, Next};
for e in self.0.lock().await.iter_mut() {
match e.chain(input).await {
match e.handle(input).await {
Next(r) => input = r,
Done(r) => {
return Done(r);
Expand Down Expand Up @@ -131,7 +131,7 @@ pub trait Handler<T, R>: Debug {
///
/// #[async_trait]
/// impl Handler<Request, Status> for AddHeader {
/// async fn chain(&mut self, mut request: Request) -> ChainResult<Request, Status> {
/// async fn handle(&mut self, mut request: Request) -> ChainResult<Request, Status> {
/// // You can modify the request however you like here
/// request.headers_mut().append("X-Header", "value".parse().unwrap());
///
Expand All @@ -140,7 +140,7 @@ pub trait Handler<T, R>: Debug {
/// }
/// }
/// ```
async fn chain(&mut self, input: T) -> ChainResult<T, R>;
async fn handle(&mut self, input: T) -> ChainResult<T, R>;
}

/// Client request chains
Expand Down Expand Up @@ -195,7 +195,7 @@ mod test {

#[async_trait]
impl Handler<Result, Result> for Add {
async fn chain(&mut self, req: Result) -> ChainResult<Result, Result> {
async fn handle(&mut self, req: Result) -> ChainResult<Result, Result> {
let added = req.0 + self.0;
if added > 100 {
Done(Result(req.0))
Expand Down
2 changes: 1 addition & 1 deletion lychee-lib/src/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn clone_unwrap(request: &Request) -> Request {

#[async_trait]
impl Handler<Request, Status> for Checker {
async fn chain(&mut self, input: Request) -> ChainResult<Request, Status> {
async fn handle(&mut self, input: Request) -> ChainResult<Request, Status> {
ChainResult::Done(self.retry_request(input).await)
}
}
2 changes: 1 addition & 1 deletion lychee-lib/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ mod tests {

#[async_trait]
impl Handler<Request, Status> for ExampleHandler {
async fn chain(&mut self, _: Request) -> ChainResult<Request, Status> {
async fn handle(&mut self, _: Request) -> ChainResult<Request, Status> {
ChainResult::Done(Status::Excluded)
}
}
Expand Down
2 changes: 1 addition & 1 deletion lychee-lib/src/quirks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl Quirks {

#[async_trait]
impl Handler<Request, Status> for Quirks {
async fn chain(&mut self, input: Request) -> ChainResult<Request, Status> {
async fn handle(&mut self, input: Request) -> ChainResult<Request, Status> {
ChainResult::Next(self.apply(input))
}
}
Expand Down
2 changes: 1 addition & 1 deletion lychee-lib/src/types/basic_auth/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl BasicAuthCredentials {

#[async_trait]
impl Handler<Request, Status> for Option<BasicAuthCredentials> {
async fn chain(&mut self, mut request: Request) -> ChainResult<Request, Status> {
async fn handle(&mut self, mut request: Request) -> ChainResult<Request, Status> {
if let Some(credentials) = self {
request
.headers_mut()
Expand Down

0 comments on commit f2b1c29

Please sign in to comment.