Skip to main content

Transformation

Struct Transformation 

Source
pub struct Transformation<T> { /* private fields */ }
Expand description

A data object or collection with the partials, additional data and wrap of one transformation: what PHP’s include(), additional() and wrap() return.

Implementations§

Source§

impl<T: Serialize> Transformation<T>

Source

pub fn include<S: AsRef<str>>(self, paths: impl IntoIterator<Item = S>) -> Self

Includes lazy properties: include('songs', 'songs.{name, artist}').

Source

pub fn exclude<S: AsRef<str>>(self, paths: impl IntoIterator<Item = S>) -> Self

Excludes lazy properties included by default: exclude().

Source

pub fn only<S: AsRef<str>>(self, paths: impl IntoIterator<Item = S>) -> Self

Keeps only these properties: only().

Source

pub fn except<S: AsRef<str>>(self, paths: impl IntoIterator<Item = S>) -> Self

Leaves these properties out: except().

Source

pub fn additional(self, additional: impl Serialize) -> Self

Adds properties to the output: additional().

Source

pub fn wrap(self, key: impl Into<String>) -> Self

Wraps the response in a key, such as data: wrap().

Source

pub fn without_wrapping(self) -> Self

Doesn’t wrap the response: withoutWrapping().

Source

pub fn to_value(&self) -> Value

The transformed value: toArray().

Source

pub fn to_array(&self) -> Map<String, Value>

The transformed object, as a map: toArray().

Source

pub fn to_json(&self) -> String

The JSON text: toJson().

Source

pub fn to_response_value(&self) -> Value

The value a response sends: the transformed value, wrapped in the data’s or the configured key.

Trait Implementations§

Source§

impl<T: Clone> Clone for Transformation<T>

Source§

fn clone(&self) -> Self

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

impl<T: Debug> Debug for Transformation<T>

Source§

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

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

impl<T: Serialize> IntoResponse for Transformation<T>

Source§

fn into_response(self) -> Response

Turn this into a Response. Read more
Source§

fn with_status(self, status: impl IntoStatusCode) -> Response

Respond with another status, such as 201 or StatusCode::CREATED. Read more
Send a cookie with this response, replacing any cookie the response already sends with the same name, path, and domain. Read more
Remove a browser cookie. Pass the cookie’s name, or a Cookie with the path and domain that set it. Read more
Source§

fn with_header<K, V>(self, name: K, value: V) -> Response

Send a header with the response, replacing any header with the same name. A name or value that isn’t a valid header makes the response a 500 error.
Source§

fn with_headers<K, V>( self, headers: impl IntoIterator<Item = (K, V)>, ) -> Response

Send several headers with the response, each replacing any header with the same name. A name or value that isn’t a valid header makes the response a 500 error.

Auto Trait Implementations§

§

impl<T> Forget for Transformation<T>

§

impl<T> Freeze for Transformation<T>
where T: Freeze, *const LeafNode<String, Partials> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, Partials)>>: Freeze, *const u8 is !null: Freeze, PhantomData<usize>: Freeze, PhantomData<Bucket<String, Value>>: Freeze, PhantomData<u8>: Freeze,

§

impl<T> Move for Transformation<T>

§

impl<T> RefUnwindSafe for Transformation<T>
where T: RefUnwindSafe,

§

impl<T> Send for Transformation<T>
where T: Send, NodeRef<Owned, String, Partials, LeafOrInternal>: Send, BoxRaw<(String, Partials)>: Send, RawTable<usize>: Send, RawVecInner: Send,

§

impl<T> Sync for Transformation<T>
where T: Sync, NodeRef<Owned, String, Partials, LeafOrInternal>: Sync, BoxRaw<(String, Partials)>: Sync, RawTable<usize>: Sync, RawVecInner: Sync,

§

impl<T> Unpin for Transformation<T>
where T: Unpin, *const LeafNode<String, Partials> is !null: Unpin, Box<(String, Partials)>: Unpin, *const u8 is !null: Unpin,

§

impl<T> UnsafeUnpin for Transformation<T>

§

impl<T> UnwindSafe for Transformation<T>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

impl<T> ErasedDestructor for T
where T: 'static,

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<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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, N> NotifiedBy<T> for N
where T: Notification<N>,

Source§

fn __routes(&self) -> Vec<Route>

Source§

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

Source§

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

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

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