Skip to main content

Impersonate

Struct Impersonate 

Source
pub struct Impersonate;
Expand description

Acts as the record’s user: an Action for a resource whose model is the panel’s user type, placed on its rows and record pages.

Its button shows only on a user the signed-in user may act as under the panel’s Impersonation rule, and never while they act as someone already. Running it lands on the panel root as that user. The resource’s policy must also allow Ability::Run on the record.

struct Users;

impl Resource for Users {
    type Model = AdminUser;
    type Form = NoForm<AdminUser>;

    fn declare() -> ResourceDef<Self> {
        ResourceDef::new().policy(Allow).action::<Impersonate>()
    }
}

Trait Implementations§

Source§

impl<R> Action<R> for Impersonate
where R: Resource, <R as Resource>::Model: PanelUser,

Source§

const NAME: &'static str = "impersonate"

The action’s URL segment, distinct among the resource’s actions. Read more
Source§

type Input = ()

What the action asks for before it runs: () for nothing, or an FormInput struct, such as a rejection’s reason.
Source§

fn declare() -> ActionDef<R>

Where the action’s button renders, how it reads on each record, and which records it runs on. Defaults to ActionDef::new: a gray button on each row, page header and the bulk bar, labelled after NAME, running without confirmation on every record the policy allows. Read more
Source§

async fn run( cx: &Cx, records: &[<R as Resource>::Model], __arg2: (), ex: &mut dyn Executor, ) -> Result<Outcome, WriteError<()>>

Perform the action on records, the records of the row or selection that passed Ability::Run and ActionDef::can_run, with the parsed input, through the framework’s transaction ex, and say what the response does once it commits: Outcome::done for the ActionDef::success notification, landing back where the action ran from. filter_keys writes one change to every record in one statement. Read more
Source§

fn validate_input(_cx: &Cx, _input: &Self::Input) -> FieldErrors<Self::Input>

Refuse an input run should not receive, such as a reason too short to act on: each error names a field of the input, picked off its Keys, and renders under its control. Defaults to none. Read more
Source§

fn submits(submits: Submits<Self::Input>) -> Submits<Self::Input>

The input dialog’s buttons beside the action’s own, each running the action with one checkbox of the input checked, such as “Ship and notify” beside “Ship”: see Submits. Defaults to none.
Source§

impl Clone for Impersonate

Source§

fn clone(&self) -> Impersonate

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 Copy for Impersonate

Source§

impl Debug for Impersonate

Source§

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

Formats the value using the given formatter. Read more

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
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<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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.

§

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