pub struct AlertSpec {
pub title: String,
pub message: String,
pub actions: Vec<AlertAction>,
pub cancelable: bool,
pub style: AlertStyle,
pub anchor: Option<AnchorRect>,
}Expand description
What an alert asks: a title, a message, up to MAX_ALERT_ACTIONS
actions, and how it is presented.
Validated when submitted (show_alert), before any platform API is
touched: at least one action and at most MAX_ALERT_ACTIONS actions,
every action id non-empty and unique (the id is what
AlertOutcome::Action reports back), at most one ActionRole::Cancel
action (UIKit raises on a second one), and an AnchorRect — when given
— finite with a non-negative size. An AlertStyle::ActionSheet on iPad
additionally requires anchor; that rule is the iOS arm’s, checked when
it presents (only it can tell an iPad from an iPhone).
Fields§
§title: StringThe alert’s title.
message: StringThe alert’s body text.
actions: Vec<AlertAction>The buttons, in presentation order.
cancelable: boolWhether the user may dismiss the alert without choosing an action
(back key / outside tap where the platform has one) — answered as
AlertOutcome::Cancelled.
style: AlertStyleCentered alert or action sheet.
anchor: Option<AnchorRect>Where an action sheet points from, in logical points of the presenting window’s coordinate space (origin top-left).
Implementations§
Source§impl AlertSpec
impl AlertSpec
Sourcepub fn new(title: impl Into<String>, message: impl Into<String>) -> Self
pub fn new(title: impl Into<String>, message: impl Into<String>) -> Self
A cancelable AlertStyle::Alert with no actions and no anchor —
add buttons with Self::with_action.
Sourcepub fn with_action(
self,
id: impl Into<String>,
label: impl Into<String>,
role: ActionRole,
) -> Self
pub fn with_action( self, id: impl Into<String>, label: impl Into<String>, role: ActionRole, ) -> Self
Append one action.
Sourcepub fn validate(&self) -> Result<(), PresentError>
pub fn validate(&self) -> Result<(), PresentError>
The submit-time validation described on AlertSpec.
§Errors
PresentError::InvalidSpec naming the first rule broken.
Trait Implementations§
impl StructuralPartialEq for AlertSpec
Auto Trait Implementations§
impl Freeze for AlertSpec
impl RefUnwindSafe for AlertSpec
impl Send for AlertSpec
impl Sync for AlertSpec
impl Unpin for AlertSpec
impl UnsafeUnpin for AlertSpec
impl UnwindSafe for AlertSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.