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::ip::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
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
Source§impl<S: Send + Sync> FromRequestParts<S> for ClientInfo
impl<S: Send + Sync> FromRequestParts<S> for ClientInfo
Source§async fn from_request_parts(
parts: &mut Parts,
_state: &S,
) -> Result<Self, Self::Rejection>
async fn from_request_parts( parts: &mut Parts, _state: &S, ) -> Result<Self, Self::Rejection>
Builds ClientInfo from request extensions and headers.
Reads the IP from the ClientIp extension (inserted by
ClientIpLayer), the User-Agent header,
and the X-Fingerprint header. Any field that cannot be read is None.
§Errors
This extractor never fails — the Result type is required by
FromRequestParts but the implementation always returns Ok.