Skip to main content

Request

Struct Request 

Source
pub struct Request {
    pub method: Method,
    pub uri: Uri,
    pub version: Version,
    pub headers: HeaderMap,
    pub path_params: HashMap<String, String>,
    pub query_params: HashMap<String, String>,
    pub is_secure: bool,
    pub remote_addr: Option<SocketAddr>,
    pub extensions: Extensions,
    /* private fields */
}
Available on crate feature core and non-WebAssembly only.
Expand description

HTTP Request representation

Fields§

§method: Method

The HTTP method (GET, POST, PUT, etc.).

§uri: Uri

The request URI (path and query string).

§version: Version

The HTTP protocol version.

§headers: HeaderMap

The request headers.

§path_params: HashMap<String, String>

Path parameters extracted from the URL pattern.

§query_params: HashMap<String, String>

Query string parameters parsed from the URI.

§is_secure: bool

Indicates if this request came over HTTPS

§remote_addr: Option<SocketAddr>

Remote address of the client (if available)

§extensions: Extensions

Extensions for storing arbitrary typed data

Implementations§

Source§

impl Request

Source

pub fn body(&self) -> &Bytes

Get a reference to the request body

This is a non-consuming accessor that can be called multiple times. Useful for testing and inspection purposes.

§Examples
use reinhardt_http::Request;
use hyper::Method;
use bytes::Bytes;

let body = Bytes::from("test body");
let request = Request::builder()
    .method(Method::POST)
    .uri("/")
    .body(body.clone())
    .build()
    .unwrap();

assert_eq!(request.body(), &body);
Source

pub fn json<T>(&self) -> Result<T, Error>

Parse the request body as JSON

§Examples
use reinhardt_http::Request;
use hyper::Method;
use bytes::Bytes;
use serde::Deserialize;

#[derive(Deserialize, Debug, PartialEq)]
struct User {
    name: String,
    age: u32,
}

let json_body = r#"{"name": "Alice", "age": 30}"#;
let mut headers = hyper::HeaderMap::new();
headers.insert(hyper::header::CONTENT_TYPE, "application/json".parse().unwrap());
let request = Request::builder()
    .method(Method::POST)
    .uri("/api/users")
    .headers(headers)
    .body(Bytes::from(json_body))
    .build()
    .unwrap();

let user: User = request.json().unwrap();
assert_eq!(user.name, "Alice");
assert_eq!(user.age, 30);
Source

pub fn with_parsers(self, parsers: Vec<Box<dyn Parser>>) -> Request

Available on crate feature parsers only.

Set parsers for request body parsing

§Examples
use reinhardt_http::Request;
use hyper::Method;

let request = Request::builder()
    .method(Method::POST)
    .uri("/")
    .build()
    .unwrap();

// Set up parsers (empty vec for this example)
let request = request.with_parsers(vec![]);
assert_eq!(request.method, Method::POST);
Source

pub fn read_body(&self) -> Result<Bytes, Error>

Read and consume the request body This marks the body as consumed and subsequent parse attempts will fail

§Examples
use reinhardt_http::Request;
use hyper::Method;
use bytes::Bytes;

let request = Request::builder()
    .method(Method::POST)
    .uri("/")
    .body(Bytes::from("request body"))
    .build()
    .unwrap();

let body = request.read_body().unwrap();
assert_eq!(body, Bytes::from("request body"));

// Second read fails because body is consumed
assert!(request.read_body().is_err());
Source

pub async fn post(&self) -> Result<HashMap<String, Vec<String>>, Error>

Available on crate feature parsers only.

Get POST data (form-encoded data) Returns data only if using FormParser or MultiPartParser

§Examples
use reinhardt_http::Request;
use hyper::Method;

async fn example() {
    let request = Request::builder()
        .method(Method::POST)
        .uri("/")
        .build()
        .unwrap();

    // Without parsers, returns empty HashMap
    let post_data = request.post().await.unwrap();
    assert!(post_data.is_empty());
}
Source

pub async fn data(&self) -> Result<ParsedData, Error>

Available on crate feature parsers only.

Get parsed data This performs lazy parsing - only parses once and caches the result

§Examples
use reinhardt_http::Request;
use hyper::Method;

async fn example() {
    let request = Request::builder()
        .method(Method::POST)
        .uri("/")
        .build()
        .unwrap();

    // Without parsers, this will fail
    assert!(request.data().await.is_err());
}
Source§

impl Request

Source

pub fn is_secure(&self) -> bool

Returns true if the request was made over HTTPS

This can be determined either by:

  1. The actual connection being TLS (is_secure flag)
  2. X-Forwarded-Proto header indicating HTTPS (only from trusted proxies)
§Examples
use reinhardt_http::{Request, TrustedProxies};
use hyper::Method;
use std::net::{SocketAddr, IpAddr, Ipv4Addr};

// Direct HTTPS connection
let request = Request::builder()
    .method(Method::GET)
    .uri("/")
    .secure(true)
    .build()
    .unwrap();
assert!(request.is_secure());

// Behind trusted reverse proxy
let proxy_ip = IpAddr::V4(Ipv4Addr::new(10, 0, 0, 1));
let mut headers = hyper::HeaderMap::new();
headers.insert("x-forwarded-proto", "https".parse().unwrap());
let request = Request::builder()
    .method(Method::GET)
    .uri("/")
    .headers(headers)
    .remote_addr(SocketAddr::new(proxy_ip, 8080))
    .build()
    .unwrap();
request.set_trusted_proxies(TrustedProxies::new(vec![proxy_ip]));
assert!(request.is_secure());
Source

pub fn scheme(&self) -> &str

Returns the scheme of the request (http or https)

§Examples
use reinhardt_http::Request;
use hyper::{Method, Uri, Version, HeaderMap};
use bytes::Bytes;

let request = Request::builder()
    .method(Method::GET)
    .uri("/")
    .secure(true)
    .build()
    .unwrap();
assert_eq!(request.scheme(), "https");

let request = Request::builder()
    .method(Method::GET)
    .uri("/")
    .build()
    .unwrap();
assert_eq!(request.scheme(), "http");
Source

pub fn build_absolute_uri(&self, path: Option<&str>) -> String

Build an absolute URI for the request

Example: “https://example.com:8000/path?query=value

§Examples
use reinhardt_http::Request;
use hyper::{Method, Uri, Version, HeaderMap};
use bytes::Bytes;

let mut headers = hyper::HeaderMap::new();
headers.insert("host", "example.com".parse().unwrap());

let request = Request::builder()
    .method(Method::GET)
    .uri("/api/users")
    .headers(headers)
    .secure(true)
    .build()
    .unwrap();

let uri = request.build_absolute_uri(None);
assert_eq!(uri, "https://example.com/api/users");

let uri = request.build_absolute_uri(Some("/other/path"));
assert_eq!(uri, "https://example.com/other/path");
Source§

impl Request

Source

pub fn path(&self) -> &str

Get the request path

§Examples
use reinhardt_http::Request;
use hyper::Method;

let request = Request::builder()
    .method(Method::GET)
    .uri("/api/users")
    .build()
    .unwrap();

assert_eq!(request.path(), "/api/users");
Source

pub fn decoded_query_params(&self) -> HashMap<String, String>

Get URL-decoded query parameters

Returns a new HashMap with all query parameter keys and values URL-decoded. This is useful when query parameters contain special characters or Unicode.

§Examples
use reinhardt_http::Request;
use hyper::Method;

let request = Request::builder()
    .method(Method::GET)
    .uri("/test?name=John%20Doe")
    .build()
    .unwrap();

let decoded = request.decoded_query_params();
assert_eq!(decoded.get("name"), Some(&"John Doe".to_string()));
Source

pub fn set_path_param( &mut self, key: impl Into<String>, value: impl Into<String>, )

Set a path parameter (used by routers for path variable extraction)

This method is typically called by routers when extracting path parameters from URL patterns like /users/{id}/.

§Examples
use reinhardt_http::Request;
use hyper::{Method, Uri, Version, HeaderMap};
use bytes::Bytes;

let mut request = Request::builder()
    .method(Method::GET)
    .uri("/users/123")
    .build()
    .unwrap();

request.set_path_param("id", "123");
assert_eq!(request.path_params.get("id"), Some(&"123".to_string()));
Source

pub fn get_accepted_languages(&self) -> Vec<(String, f32)>

Parse Accept-Language header and return ordered list of language codes

Returns languages sorted by quality value (q parameter), highest first. Example: “en-US,en;q=0.9,ja;q=0.8” -> [“en-US”, “en”, “ja”]

§Examples
use reinhardt_http::Request;
use hyper::{Method, Uri, Version, HeaderMap};
use bytes::Bytes;

let mut headers = HeaderMap::new();
headers.insert("accept-language", "en-US,en;q=0.9,ja;q=0.8".parse().unwrap());

let request = Request::builder()
    .method(Method::GET)
    .uri("/")
    .headers(headers)
    .build()
    .unwrap();

let languages = request.get_accepted_languages();
assert_eq!(languages[0].0, "en-US");
assert_eq!(languages[0].1, 1.0);
assert_eq!(languages[1].0, "en");
assert_eq!(languages[1].1, 0.9);
Source

pub fn get_preferred_language(&self) -> Option<String>

Get the most preferred language from Accept-Language header

§Examples
use reinhardt_http::Request;
use hyper::{Method, Uri, Version, HeaderMap};
use bytes::Bytes;

let mut headers = HeaderMap::new();
headers.insert("accept-language", "ja;q=0.8,en-US,en;q=0.9".parse().unwrap());

let request = Request::builder()
    .method(Method::GET)
    .uri("/")
    .headers(headers)
    .build()
    .unwrap();

assert_eq!(request.get_preferred_language(), Some("en-US".to_string()));

Get language from cookie

Looks for a language cookie (typically named “reinhardt_language” or similar)

§Examples
use reinhardt_http::Request;
use hyper::{Method, Uri, Version, HeaderMap};
use bytes::Bytes;

let mut headers = HeaderMap::new();
headers.insert("cookie", "session_id=abc123; language=ja; theme=dark".parse().unwrap());

let request = Request::builder()
    .method(Method::GET)
    .uri("/")
    .headers(headers)
    .build()
    .unwrap();

assert_eq!(request.get_language_from_cookie("language"), Some("ja".to_string()));
assert_eq!(request.get_language_from_cookie("nonexistent"), None);
Source§

impl Request

Source

pub fn builder() -> RequestBuilder

Create a new RequestBuilder.

§Examples
use reinhardt_http::Request;
use hyper::Method;

let request = Request::builder()
    .method(Method::GET)
    .uri("/api/users")
    .build()
    .unwrap();

assert_eq!(request.method, Method::GET);
Source

pub fn set_di_context<T>(&mut self, ctx: T)
where T: Send + Sync + 'static,

Set the DI context for this request (used by routers with dependency injection)

This method stores the DI context in the request’s extensions, allowing handlers to access dependency injection services.

The context will be wrapped in an Arc internally for efficient sharing. The DI context type is generic to avoid circular dependencies.

§Examples
use reinhardt_http::Request;
use hyper::Method;

let mut request = Request::builder()
    .method(Method::GET)
    .uri("/")
    .build()
    .unwrap();

let di_ctx = DummyDiContext;
request.set_di_context(di_ctx);
Source

pub fn get_di_context<T>(&self) -> Option<Arc<T>>
where T: Send + Sync + 'static,

Get the DI context from this request

Returns None if no DI context was set.

The DI context type is generic to avoid circular dependencies. Returns a reference to the context.

§Examples
use reinhardt_http::Request;
use hyper::Method;

let mut request = Request::builder()
    .method(Method::GET)
    .uri("/")
    .build()
    .unwrap();

let di_ctx = DummyDiContext;
request.set_di_context(di_ctx);

let ctx = request.get_di_context::<DummyDiContext>();
assert!(ctx.is_some());
Source

pub fn extract_bearer_token(&self) -> Option<String>

Extract Bearer token from Authorization header

Extracts JWT or other bearer tokens from the Authorization header. Returns None if the header is missing or not in “Bearer <token>” format.

§Examples
use reinhardt_http::Request;
use hyper::{Method, Version, HeaderMap, header};
use bytes::Bytes;

let mut headers = HeaderMap::new();
headers.insert(
    header::AUTHORIZATION,
    "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9".parse().unwrap()
);

let request = Request::builder()
    .method(Method::GET)
    .uri("/")
    .version(Version::HTTP_11)
    .headers(headers)
    .body(Bytes::new())
    .build()
    .unwrap();

let token = request.extract_bearer_token();
assert_eq!(token, Some("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9".to_string()));
§Missing or invalid header
use reinhardt_http::Request;
use hyper::{Method, Version, HeaderMap};
use bytes::Bytes;

let request = Request::builder()
    .method(Method::GET)
    .uri("/")
    .version(Version::HTTP_11)
    .headers(HeaderMap::new())
    .body(Bytes::new())
    .build()
    .unwrap();

let token = request.extract_bearer_token();
assert_eq!(token, None);
Source

pub fn get_header(&self, name: &str) -> Option<String>

Get a specific header value from the request

Returns None if the header is missing or cannot be converted to a string.

§Examples
use reinhardt_http::Request;
use hyper::{Method, Version, HeaderMap, header};
use bytes::Bytes;

let mut headers = HeaderMap::new();
headers.insert(
    header::USER_AGENT,
    "Mozilla/5.0".parse().unwrap()
);

let request = Request::builder()
    .method(Method::GET)
    .uri("/")
    .version(Version::HTTP_11)
    .headers(headers)
    .body(Bytes::new())
    .build()
    .unwrap();

let user_agent = request.get_header("user-agent");
assert_eq!(user_agent, Some("Mozilla/5.0".to_string()));
§Missing header
use reinhardt_http::Request;
use hyper::{Method, Version, HeaderMap};
use bytes::Bytes;

let request = Request::builder()
    .method(Method::GET)
    .uri("/")
    .version(Version::HTTP_11)
    .headers(HeaderMap::new())
    .body(Bytes::new())
    .build()
    .unwrap();

let header = request.get_header("x-custom-header");
assert_eq!(header, None);
Source

pub fn get_client_ip(&self) -> Option<IpAddr>

Extract client IP address from the request

Only trusts proxy headers (X-Forwarded-For, X-Real-IP) when the request originates from a configured trusted proxy. Without trusted proxies, falls back to the actual connection address.

§Examples
use reinhardt_http::{Request, TrustedProxies};
use hyper::{Method, Version, HeaderMap, header};
use bytes::Bytes;
use std::net::{SocketAddr, IpAddr, Ipv4Addr};

let proxy_ip = IpAddr::V4(Ipv4Addr::new(10, 0, 0, 1));
let mut headers = HeaderMap::new();
headers.insert(
    header::HeaderName::from_static("x-forwarded-for"),
    "203.0.113.1, 198.51.100.1".parse().unwrap()
);

let request = Request::builder()
    .method(Method::GET)
    .uri("/")
    .version(Version::HTTP_11)
    .headers(headers)
    .remote_addr(SocketAddr::new(proxy_ip, 8080))
    .body(Bytes::new())
    .build()
    .unwrap();

// Configure trusted proxies to honor X-Forwarded-For
request.set_trusted_proxies(TrustedProxies::new(vec![proxy_ip]));

let ip = request.get_client_ip();
assert_eq!(ip, Some("203.0.113.1".parse().unwrap()));
§No trusted proxy, fallback to remote_addr
use reinhardt_http::Request;
use hyper::{Method, Version, HeaderMap};
use bytes::Bytes;
use std::net::{SocketAddr, IpAddr, Ipv4Addr};

let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
let request = Request::builder()
    .method(Method::GET)
    .uri("/")
    .version(Version::HTTP_11)
    .headers(HeaderMap::new())
    .remote_addr(addr)
    .body(Bytes::new())
    .build()
    .unwrap();

let ip = request.get_client_ip();
assert_eq!(ip, Some(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1))));
Source

pub fn is_from_trusted_proxy(&self) -> bool

Check if the request originates from a trusted proxy.

Returns true only if TrustedProxies are configured (via set_trusted_proxies) and the remote address of the connection is contained in the trusted set.

§Security

This method gates whether proxy-forwarded headers (e.g. X-Forwarded-For, X-Forwarded-Proto) should be honoured. Trusting headers from a non-proxy source allows clients to spoof their IP address or protocol, which can bypass IP-based access controls and HTTPS enforcement.

Callers must ensure that TrustedProxies is configured only with IP addresses of reverse proxies actually deployed in front of the application. Misconfiguration (e.g. trusting 0.0.0.0/0) re-introduces header-spoofing vulnerabilities.

§Examples
use reinhardt_http::Request;
use reinhardt_http::TrustedProxies;
use bytes::Bytes;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use hyper::Method;

let proxy_ip: IpAddr = Ipv4Addr::new(10, 0, 0, 1).into();
let request = Request::builder()
    .method(Method::GET)
    .uri("/")
    .remote_addr(SocketAddr::new(proxy_ip, 8080))
    .body(Bytes::new())
    .build()
    .unwrap();
request.set_trusted_proxies(TrustedProxies::new(vec![proxy_ip]));

assert!(request.is_from_trusted_proxy());
Source

pub fn set_trusted_proxies(&self, proxies: TrustedProxies)

Set trusted proxy configuration for this request.

This is typically called by the server/middleware layer to configure which proxy IPs are trusted for header forwarding.

Source

pub fn validate_content_type(&self, expected: &str) -> Result<(), Error>

Validate Content-Type header

Checks if the Content-Type header matches the expected value. Returns an error if the header is missing or doesn’t match.

§Examples
use reinhardt_http::Request;
use hyper::{Method, Version, HeaderMap, header};
use bytes::Bytes;

let mut headers = HeaderMap::new();
headers.insert(
    header::CONTENT_TYPE,
    "application/json".parse().unwrap()
);

let request = Request::builder()
    .method(Method::POST)
    .uri("/")
    .version(Version::HTTP_11)
    .headers(headers)
    .body(Bytes::new())
    .build()
    .unwrap();

assert!(request.validate_content_type("application/json").is_ok());
§Content-Type mismatch
use reinhardt_http::Request;
use hyper::{Method, Version, HeaderMap, header};
use bytes::Bytes;

let mut headers = HeaderMap::new();
headers.insert(
    header::CONTENT_TYPE,
    "text/plain".parse().unwrap()
);

let request = Request::builder()
    .method(Method::POST)
    .uri("/")
    .version(Version::HTTP_11)
    .headers(headers)
    .body(Bytes::new())
    .build()
    .unwrap();

let result = request.validate_content_type("application/json");
assert!(result.is_err());
§Missing Content-Type header
use reinhardt_http::Request;
use hyper::{Method, Version, HeaderMap};
use bytes::Bytes;

let request = Request::builder()
    .method(Method::POST)
    .uri("/")
    .version(Version::HTTP_11)
    .headers(HeaderMap::new())
    .body(Bytes::new())
    .build()
    .unwrap();

let result = request.validate_content_type("application/json");
assert!(result.is_err());
Source

pub fn query_as<T>(&self) -> Result<T, Error>

Parse query parameters into typed struct

Deserializes query string parameters into the specified type T. Returns an error if deserialization fails.

§Examples
use reinhardt_http::Request;
use hyper::{Method, Version, HeaderMap};
use bytes::Bytes;
use serde::Deserialize;

#[derive(Deserialize, Debug, PartialEq)]
struct Pagination {
    page: u32,
    limit: u32,
}

let request = Request::builder()
    .method(Method::GET)
    .uri("/api/users?page=2&limit=10")
    .version(Version::HTTP_11)
    .headers(HeaderMap::new())
    .body(Bytes::new())
    .build()
    .unwrap();

let params: Pagination = request.query_as().unwrap();
assert_eq!(params, Pagination { page: 2, limit: 10 });
§Type mismatch error
use reinhardt_http::Request;
use hyper::{Method, Version, HeaderMap};
use bytes::Bytes;
use serde::Deserialize;

#[derive(Deserialize)]
struct Pagination {
    page: u32,
    limit: u32,
}

let request = Request::builder()
    .method(Method::GET)
    .uri("/api/users?page=invalid")
    .version(Version::HTTP_11)
    .headers(HeaderMap::new())
    .body(Bytes::new())
    .build()
    .unwrap();

let result: Result<Pagination, _> = request.query_as();
assert!(result.is_err());
Source

pub fn clone_for_di(&self) -> Request

Creates a lightweight copy of this request for dependency injection.

The clone shares the same extensions store (via internal Arc), so AuthState and other extensions set on the original request are accessible in the clone. Body and parsers are not copied as they are not needed for DI resolution.

Trait Implementations§

Source§

impl RequestVersionExt for Request

Source§

fn version(&self) -> Option<String>

Get the API version from request extensions
Source§

fn version_or(&self, default: &str) -> String

Get the API version or return default

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> IntoResult<T> for T

Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more