Skip to content

Commit

Permalink
add missing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sunli829 committed Aug 28, 2023
1 parent 06c8bc7 commit 87a443a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions poem-openapi/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ impl Deref for UrlQuery {
}

impl UrlQuery {
#[allow(missing_docs)]
pub fn get_all<'a, 'b: 'a>(&'b self, name: &'a str) -> impl Iterator<Item = &'b String> + 'a {
/// Returns all values with the specified name.
pub fn get_all<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a String> + 'a {
self.0
.iter()
.filter(move |(n, _)| n == name)
.map(|(_, value)| value)
}

#[allow(missing_docs)]
/// Returns the first value with the specified name.
pub fn get(&self, name: &str) -> Option<&String> {
self.get_all(name).next()
}
Expand Down
11 changes: 6 additions & 5 deletions poem/src/middleware/tower_compat.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
fmt,
sync::Arc,
task::{Context, Poll},
};
Expand All @@ -11,11 +12,11 @@ use crate::{Endpoint, Error, IntoResponse, Middleware, Request, Result};

#[doc(hidden)]
#[derive(Debug, thiserror::Error)]
#[error("wrapper error")]
pub struct WrapperError(Error);
#[error("{0}")]
pub struct WrappedError(Error);

fn boxed_err_to_poem_err(err: BoxError) -> Error {
match err.downcast::<WrapperError>() {
match err.downcast::<WrappedError>() {
Ok(err) => (*err).0,
Err(err) => Error::from_string(err.to_string(), StatusCode::INTERNAL_SERVER_ERROR),
}
Expand Down Expand Up @@ -65,7 +66,7 @@ where
E: Endpoint + 'static,
{
type Response = E::Output;
type Error = WrapperError;
type Error = WrappedError;
type Future = BoxFuture<'static, Result<Self::Response, Self::Error>>;

fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Expand All @@ -74,7 +75,7 @@ where

fn call(&mut self, req: Request) -> Self::Future {
let ep = self.0.clone();
async move { ep.call(req).await.map_err(WrapperError) }.boxed()
async move { ep.call(req).await.map_err(WrappedError) }.boxed()
}
}

Expand Down

0 comments on commit 87a443a

Please sign in to comment.