Skip to main content

DatastarRequest

Struct DatastarRequest 

#[non_exhaustive]
pub struct DatastarRequest;
Available on crate features http and std only.
Expand description

Datastar-Request header, sent by the ๐Ÿš€ Datastar client on every request it makes (e.g. through @get or @post actions).

Servers use it to tell Datastar fetches apart from regular browser navigations, e.g. to reply with a 401 instead of a redirect to a sign-in page, or to only read Datastar signals when present.

Datastar always sends the value true, but this header is treated as a presence marker: decoding succeeds for any value, as the mere presence of the header is what identifies a Datastar request. Encoding always writes true.

ยงExample values

  • โ€œtrueโ€

ยงExamples

use rama_http_headers::{DatastarRequest, HeaderMapExt};
use rama_http_types::HeaderMap;

let mut headers = HeaderMap::new();
assert!(headers.typed_get::<DatastarRequest>().is_none());

headers.typed_insert(DatastarRequest::new());
assert!(headers.typed_get::<DatastarRequest>().is_some());

Implementationsยง

ยง

impl DatastarRequest

pub fn new() -> DatastarRequest

Create a new DatastarRequest typed header.

Trait Implementationsยง

ยง

impl Clone for DatastarRequest

ยง

fn clone(&self) -> DatastarRequest

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) ยท Sourceยง

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

Performs copy-assignment from source. Read more
ยง

impl Copy for DatastarRequest

ยง

impl Debug for DatastarRequest

ยง

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

Formats the value using the given formatter. Read more
ยง

impl Default for DatastarRequest

ยง

fn default() -> DatastarRequest

Returns the โ€œdefault valueโ€ for a type. Read more
ยง

impl Eq for DatastarRequest

ยง

impl HeaderDecode for DatastarRequest

ยง

fn decode<'i, I>(values: &mut I) -> Result<DatastarRequest, Error>
where I: Iterator<Item = &'i HeaderValue>,

Decode this type from an iterator of HeaderValues.
ยง

impl HeaderEncode for DatastarRequest

ยง

fn encode<E>(&self, values: &mut E)
where E: Extend<HeaderValue>,

Encode this type to a HeaderValue, and add it to a container which has HeaderValue type as each element. Read more
ยง

fn encode_to_value(&self) -> Option<HeaderValue>

Encode this header to HeaderValue. Read more
ยง

impl PartialEq for DatastarRequest

ยง

fn eq(&self, other: &DatastarRequest) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
ยง

impl StructuralPartialEq for DatastarRequest

ยง

impl TypedHeader for DatastarRequest

ยง

fn name() -> &'static HeaderName

The name of this header.

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

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

ยง

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

ยง

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

ยง

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

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

ยง

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Sourceยง

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

Sourceยง

unsafe fn clone_to_uninit(&self, dest: *mut u8)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
ยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

ยง

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
ยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

ยง

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
ยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

ยง

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

ยง

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

ยง

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
ยง

impl<T> FutureExt for T

ยง

fn with_context(self, otel_cx: Context) -> WithContext<Self> โ“˜

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
ยง

fn with_current_context(self) -> WithContext<Self> โ“˜

Attaches the current Context to this type, returning a WithContext wrapper. Read more
ยง

impl<T> Instrument for T

ยง

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

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
ยง

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

impl<T> IntoRequest<T> for T

ยง

fn into_request(self) -> Request<T>

Wrap the input message T in a rama_grpc::Request
ยง

impl<L> LayerExt<L> for L

ยง

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.
ยง

impl<T> Pointable for T

ยง

const ALIGN: usize

The alignment of pointer.
ยง

type Init = T

The type for initializers.
ยง

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

Initializes a with the given initializer. Read more
ยง

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

Dereferences the given pointer. Read more
ยง

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

Mutably dereferences the given pointer. Read more
ยง

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
ยง

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

ยง

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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
ยง

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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
ยง

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

ยง

fn rama_from(value: T) -> U

ยง

impl<T, U, CrateMarker> RamaInto<U, CrateMarker> for T
where U: RamaFrom<T, CrateMarker>,

ยง

fn rama_into(self) -> U

ยง

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

ยง

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

ยง

fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>

ยง

impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for T
where U: RamaTryFrom<T, CrateMarker>,

ยง

type Error = <U as RamaTryFrom<T, CrateMarker>>::Error

ยง

fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>

ยง

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Sourceยง

impl<T> Same for T

Sourceยง

type Output = T

Should always be Self
Sourceยง

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

Sourceยง

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

Sourceยง

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
ยง

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

ยง

fn vzip(self) -> V

ยง

impl<V, F> ValueFormatter<&V> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

ยง

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
ยง

fn format_value(writer: impl ValueWriter, value: &&V)

Write value to writer
ยง

impl<V, F> ValueFormatter<Arc<V>> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

ยง

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
ยง

fn format_value(writer: impl ValueWriter, value: &Arc<V>)

Write value to writer
ยง

impl<V, F> ValueFormatter<Box<V>> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

ยง

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
ยง

fn format_value(writer: impl ValueWriter, value: &Box<V>)

Write value to writer
ยง

impl<V, F> ValueFormatter<Cow<'_, V>> for F
where V: ToOwned + ?Sized, F: ValueFormatter<V> + ?Sized,

ยง

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
ยง

fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)

Write value to writer
ยง

impl<V, F> ValueFormatter<Option<V>> for F
where F: ValueFormatter<V> + ?Sized,

ยง

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
ยง

fn format_value(writer: impl ValueWriter, value: &Option<V>)

Write value to writer
ยง

impl<T> WithSubscriber for T

ยง

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

fn with_current_subscriber(self) -> WithDispatch<Self> โ“˜

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