Skip to content

Commit

Permalink
add some inline attributes for other modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexilee committed Mar 4, 2020
1 parent bc3501a commit 2f8a419
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions roa-juniper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ impl<S: State> juniper::Context for JuniperContext<S> {}

impl<S> Deref for JuniperContext<S> {
type Target = SyncContext<S>;
#[inline]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<S> DerefMut for JuniperContext<S> {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
Expand Down Expand Up @@ -54,6 +56,7 @@ where
QueryT::TypeInfo: Send + Sync,
MutationT::TypeInfo: Send + Sync,
{
#[inline]
async fn handle(self: Arc<Self>, mut ctx: Context<S>, _next: Next) -> Result {
let request: GraphQLRequest<Sca> = ctx.read_json().await?;
let juniper_ctx = JuniperContext(ctx.clone());
Expand Down
4 changes: 4 additions & 0 deletions roa-multipart/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ struct WrapStream(Option<Body>);

impl Multipart {
/// Construct multipart from Context.
#[inline]
pub fn new<S: State>(ctx: &mut Context<S>) -> Self {
let mut map = HeaderMap::new();
if let Some(value) = ctx.req().headers.get(CONTENT_TYPE) {
Expand Down Expand Up @@ -166,18 +167,21 @@ impl Stream for Field {

impl Deref for Field {
type Target = ActixField;
#[inline]
fn deref(&self) -> &Self::Target {
&self.0
}
}

impl From<WrapError> for Error {
#[inline]
fn from(err: WrapError) -> Self {
Error::new(StatusCode::BAD_REQUEST, err, true)
}
}

impl Display for WrapError {
#[inline]
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_fmt(format_args!("{}\nmultipart form read error.", self.0))
}
Expand Down
4 changes: 4 additions & 0 deletions roa-router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ impl<S: State> RouteTable<S> {
}

/// Handle request.
#[inline]
async fn end(&self, mut ctx: Context<S>) -> Result {
let uri = ctx.uri();
// standardize path
Expand Down Expand Up @@ -460,6 +461,7 @@ impl<S: State> RouteTable<S> {

#[async_trait(?Send)]
impl<S: State> Middleware<S> for RouteEndpoint<S> {
#[inline]
async fn handle(self: Arc<Self>, ctx: Context<S>, _next: Next) -> Result {
match self.0.get(&ctx.method()) {
None => throw!(
Expand All @@ -472,6 +474,7 @@ impl<S: State> Middleware<S> for RouteEndpoint<S> {
}

impl<S: State> RouterParam for Context<S> {
#[inline]
fn must_param<'a>(&self, name: &'a str) -> Result<Variable<'a, String>> {
self.param(name).ok_or_else(|| {
Error::new(
Expand All @@ -481,6 +484,7 @@ impl<S: State> RouterParam for Context<S> {
)
})
}
#[inline]
fn param<'a>(&self, name: &'a str) -> Option<Variable<'a, String>> {
self.load_scoped::<RouterScope, String>(name)
}
Expand Down

0 comments on commit 2f8a419

Please sign in to comment.