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: Resource> Action<R> for Impersonate
where R::Model: PanelUser,

Source§

const NAME: &'static str = "impersonate"

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

const PLACES: Places = Places::RECORD

Where the action’s button renders. Defaults to Places::ALL: each row, the detail and edit pages’ headers, and the bulk bar. Read more
Source§

const ICON: Option<IconData>

The icon before the button’s label, in every place. Defaults to none. 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 label() -> Text

The button text. Defaults to the message action-{NAME} of the panel’s catalogs, else NAME in sentence case: "publish" reads “Publish”, and "send-invite" reads “Send invite”.
Source§

fn can_run(cx: &Cx, record: &R::Model) -> bool

Whether record’s state lets the action run on it: a published post refuses “publish”. Defaults to true. Read more
Source§

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

Perform the action on records, the records of the row or selection that passed Ability::Run and 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 success notification, landing back where the action ran from. filter_keys writes one change to every record in one statement. Read more
Source§

fn success(_count: usize) -> Text

The success notification after a commit. Defaults to the label and the record count: "Publish: 3 records". A bulk run the action refused on some records appends their count out of the selection: "Publish: 3 records (2 of 5 skipped)".
Source§

const CONFIRM: bool = false

Whether the action asks first through a confirmation dialog sharing the delete dialog’s mechanism and destructive wording. Defaults to false. Read more
Source§

const COLOR: Color = Color::Gray

The colour the button is tinted in, as Delete’s is in Color::Danger. Defaults to Color::Gray, the untinted button. Read more
Source§

fn confirmation() -> Text

The question the confirmation dialog asks when CONFIRM is set. Defaults to the message tablo-confirm-run, “Run this action?”. An action with input confirms in its input dialog instead, which its label titles.
Source§

fn label_for(_cx: &Cx, _record: &R::Model) -> Text

The text of the button on one record: its row’s, or its record page’s. Defaults to label, which the bulk bar, the input dialogs and the messages use. Read more
Source§

fn icon_for(_cx: &Cx, _record: &R::Model) -> Option<IconData>

The icon of the button on one record, in its row and on its record page. Defaults to ICON.
Source§

fn tooltip() -> Option<Text>

The hint a row’s button shows on hover, for an action whose label says too little. Defaults to none. Read more
Source§

fn disabled_reason(_cx: &Cx, _record: &R::Model) -> Option<Text>

Why the button shows disabled on a record can_run refuses, rather than hidden: “Already published” for a published post. Defaults to none, which hides it. Read more
Source§

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

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

impl Clone for Impersonate

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

Source§

impl Debug for Impersonate

Source§

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

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