pub struct ClientInfo { /* private fields */ }Expand description
Client request context: IP address, user-agent, and fingerprint.
Implements FromRequestParts for automatic extraction in handlers.
Requires ClientIpLayer for the ip field;
if the layer is absent, ip will be None.
For non-HTTP contexts (background jobs, CLI tools), use the builder:
use modo::extractor::ClientInfo;
let info = ClientInfo::new()
.ip("1.2.3.4")
.user_agent("my-script/1.0");Implementations§
Source§impl ClientInfo
impl ClientInfo
Sourcepub fn user_agent(self, ua: impl Into<String>) -> Self
pub fn user_agent(self, ua: impl Into<String>) -> Self
Set the user-agent string.
Sourcepub fn fingerprint(self, fp: impl Into<String>) -> Self
pub fn fingerprint(self, fp: impl Into<String>) -> Self
Set the client fingerprint (from the x-fingerprint header).
Sourcepub fn user_agent_value(&self) -> Option<&str>
pub fn user_agent_value(&self) -> Option<&str>
The client user-agent string, if available.
Sourcepub fn fingerprint_value(&self) -> Option<&str>
pub fn fingerprint_value(&self) -> Option<&str>
The client fingerprint, if available.
Trait Implementations§
Source§impl Clone for ClientInfo
impl Clone for ClientInfo
Source§fn clone(&self) -> ClientInfo
fn clone(&self) -> ClientInfo
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ClientInfo
impl Debug for ClientInfo
Source§impl Default for ClientInfo
impl Default for ClientInfo
Source§fn default() -> ClientInfo
fn default() -> ClientInfo
Returns the “default value” for a type. Read more
Source§impl<S: Send + Sync> FromRequestParts<S> for ClientInfo
impl<S: Send + Sync> FromRequestParts<S> for ClientInfo
Auto Trait Implementations§
impl Freeze for ClientInfo
impl RefUnwindSafe for ClientInfo
impl Send for ClientInfo
impl Sync for ClientInfo
impl Unpin for ClientInfo
impl UnsafeUnpin for ClientInfo
impl UnwindSafe for ClientInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
Source§fn from_request(
req: Request<Body>,
state: &S,
) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
Perform the extraction.