[go: up one dir, main page]

logo
pub enum Transform<T, B = T> {
    Owned(T),
    Borrowed(B),
}
Expand description

Indicates how incoming data should be transformed before being parsed and validated by a data guard.

See the documentation for FromData for usage details.

Variants

Owned(T)

Indicates that data should be or has been transformed into the FromData::Owned variant.

Borrowed(B)

Indicates that data should be or has been transformed into the FromData::Borrowed variant.

Implementations

Returns the Owned value if self is Owned.

Panics

Panics if self is Borrowed.

Example
use rocket::data::Transform;

let owned: Transform<usize, &[usize]> = Transform::Owned(10);
assert_eq!(owned.owned(), 10);

Returns the Borrowed value if self is Borrowed.

Panics

Panics if self is Owned.

use rocket::data::Transform;

let borrowed: Transform<usize, &[usize]> = Transform::Borrowed(&[10]);
assert_eq!(borrowed.borrowed(), &[10]);

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts self into a collection.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Get the TypeId of this object.