Struct worker::Cf

source ·
pub struct Cf { /* private fields */ }
Expand description

In addition to the methods on the Request struct, the Cf struct on an inbound Request contains information about the request provided by Cloudflare’s edge.

Details

Implementations§

source§

impl Cf

source

pub fn colo(&self) -> String

The three-letter airport code (e.g. ATX, LUX) representing the colocation which processed the request

source

pub fn asn(&self) -> u32

The Autonomous System Number (ASN) of the request, e.g. 395747

source

pub fn as_organization(&self) -> String

The Autonomous System organization name of the request, e.g. Cloudflare, Inc.

source

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

The two-letter country code of origin for the request. This is the same value as that provided in the CF-IPCountry header, e.g. "US"

source

pub fn http_protocol(&self) -> String

The HTTP Protocol (e.g. “HTTP/2”) used by the request

source

pub fn request_priority(&self) -> Option<RequestPriority>

The browser-requested prioritization information in the request object,

See this blog post for details.

source

pub fn tls_cipher(&self) -> String

The cipher for the connection to Cloudflare, e.g. “AEAD-AES128-GCM-SHA256”.

source

pub fn tls_client_auth(&self) -> Option<TlsClientAuth>

Information about the client’s authorization. Only set when using Cloudflare Access or API Shield.

source

pub fn tls_version(&self) -> String

The TLS version of the connection to Cloudflare, e.g. TLSv1.3.

source

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

City of the incoming request, e.g. “Austin”.

source

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

Continent of the incoming request, e.g. “NA”

source

pub fn coordinates(&self) -> Option<(f32, f32)>

Latitude and longitude of the incoming request, e.g. (30.27130, -97.74260)

source

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

Postal code of the incoming request, e.g. “78701”

source

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

Metro code (DMA) of the incoming request, e.g. “635”

source

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

If known, the ISO 3166-2 name for the first level region associated with the IP address of the incoming request, e.g. “Texas”.

source

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

If known, the ISO 3166-2 code for the first level region associated with the IP address of the incoming request, e.g. “TX”.

source

pub fn timezone(&self) -> Result<impl TimeZone>

Requires timezone feature. Timezone of the incoming request

source

pub fn timezone_name(&self) -> String

Timezone name of the incoming request

source

pub fn is_eu_country(&self) -> bool

Whether the country of the incoming request is in the EU

Trait Implementations§

source§

impl Clone for Cf

source§

fn clone(&self) -> Cf

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Cf

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<IncomingRequestCfProperties> for Cf

source§

fn from(inner: IncomingRequestCfProperties) -> Self

Converts to this type from the input type.
source§

impl Send for Cf

source§

impl Sync for Cf

Auto Trait Implementations§

§

impl Freeze for Cf

§

impl RefUnwindSafe for Cf

§

impl Unpin for Cf

§

impl UnwindSafe for Cf

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> 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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromRef<T> for T
where T: Clone,

source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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<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