Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-std compatiblity for underlying traits #810

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make tower-layer no_std compatible.
TTWNO committed Jan 25, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 429d1b0600328ead8f5485733d82de8fd05dd7b5
2 changes: 1 addition & 1 deletion tower-layer/src/identity.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::Layer;
use std::fmt;
use core::fmt;

/// A no-op middleware.
///
10 changes: 5 additions & 5 deletions tower-layer/src/layer_fn.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::Layer;
use std::fmt;
use core::fmt;

/// Returns a new [`LayerFn`] that implements [`Layer`] by calling the
/// given function.
@@ -13,10 +13,10 @@ use std::fmt;
/// # Example
/// ```rust
/// # use tower::Service;
/// # use std::task::{Poll, Context};
/// # use core::task::{Poll, Context};
/// # use tower_layer::{Layer, layer_fn};
/// # use std::fmt;
/// # use std::convert::Infallible;
/// # use core::fmt;
/// # use core::convert::Infallible;
/// #
/// // A middleware that logs requests before forwarding them to another service
/// pub struct LogService<S> {
@@ -88,7 +88,7 @@ where
impl<F> fmt::Debug for LayerFn<F> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("LayerFn")
.field("f", &format_args!("{}", std::any::type_name::<F>()))
.field("f", &format_args!("{}", core::any::type_name::<F>()))
.finish()
}
}
6 changes: 4 additions & 2 deletions tower-layer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -16,6 +16,8 @@
//!
//! [`Service`]: https://docs.rs/tower/*/tower/trait.Service.html
#![no_std]

mod identity;
mod layer_fn;
mod stack;
@@ -41,9 +43,9 @@ pub use self::{
///
/// ```rust
/// # use tower_service::Service;
/// # use std::task::{Poll, Context};
/// # use core::task::{Poll, Context};
/// # use tower_layer::Layer;
/// # use std::fmt;
/// # use core::fmt;
///
/// pub struct LogLayer {
/// target: &'static str,
2 changes: 1 addition & 1 deletion tower-layer/src/stack.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::Layer;
use std::fmt;
use core::fmt;

/// Two middlewares chained together.
#[derive(Clone)]
1 change: 0 additions & 1 deletion tower-service/src/lib.rs
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@ extern crate std;

use alloc::boxed::Box;


use core::future::Future;
use core::marker::Sized;
use core::result::Result;