Skip to main content

ToastNotification

Struct ToastNotification 

Source
pub struct ToastNotification(/* private fields */);

Implementations§

Source§

impl ToastNotification

Source

pub fn Content(&self) -> Result<XmlDocument, Error>

Source

pub fn SetExpirationTime<'a, Param0>(&self, value: Param0) -> Result<(), Error>
where Param0: IntoParam<'a, IReference<DateTime>>,

Source

pub fn ExpirationTime(&self) -> Result<IReference<DateTime>, Error>

Source

pub fn Dismissed<'a, Param0>( &self, handler: Param0, ) -> Result<EventRegistrationToken, Error>

Source

pub fn RemoveDismissed<'a, Param0>(&self, token: Param0) -> Result<(), Error>
where Param0: IntoParam<'a, EventRegistrationToken>,

Source

pub fn Activated<'a, Param0>( &self, handler: Param0, ) -> Result<EventRegistrationToken, Error>
where Param0: IntoParam<'a, TypedEventHandler<ToastNotification, IInspectable>>,

Source

pub fn RemoveActivated<'a, Param0>(&self, token: Param0) -> Result<(), Error>
where Param0: IntoParam<'a, EventRegistrationToken>,

Source

pub fn Failed<'a, Param0>( &self, handler: Param0, ) -> Result<EventRegistrationToken, Error>

Source

pub fn RemoveFailed<'a, Param0>(&self, token: Param0) -> Result<(), Error>
where Param0: IntoParam<'a, EventRegistrationToken>,

Source

pub fn SetTag<'a, Param0>(&self, value: Param0) -> Result<(), Error>
where Param0: IntoParam<'a, HSTRING>,

Source

pub fn Tag(&self) -> Result<HSTRING, Error>

Source

pub fn SetGroup<'a, Param0>(&self, value: Param0) -> Result<(), Error>
where Param0: IntoParam<'a, HSTRING>,

Source

pub fn Group(&self) -> Result<HSTRING, Error>

Source

pub fn SetSuppressPopup(&self, value: bool) -> Result<(), Error>

Source

pub fn SuppressPopup(&self) -> Result<bool, Error>

Source

pub fn CreateToastNotification<'a, Param0>( content: Param0, ) -> Result<ToastNotification, Error>
where Param0: IntoParam<'a, XmlDocument>,

Examples found in repository?
examples/without_library.rs (line 51)
29fn do_toast() -> windows::runtime::Result<()> {
30    let toast_xml = XmlDocument::new()?;
31
32    toast_xml.LoadXml(HSTRING::from(
33        format!(r#"<toast duration="long">
34                <visual>
35                    <binding template="ToastGeneric">
36                        <text id="1">title</text>
37                        <text id="2">first line</text>
38                        <text id="3">third line</text>
39                        <image placement="appLogoOverride" hint-crop="circle" src="file:///c:/path_to_image_above_toast.jpg" alt="alt text" />
40                        <image placement="Hero" src="file:///C:/path_to_image_in_toast.jpg" alt="alt text2" />
41                        <image id="1" src="file:///{}" alt="another_image" />
42                    </binding>
43                </visual>
44                <audio src="ms-winsoundevent:Notification.SMS" />
45                <!-- <audio silent="true" /> -->
46            </toast>"#,
47        escape_str_attribute(&Path::new("C:\\path_to_image_in_toast.jpg").display().to_string()),
48    ))).expect("the xml is malformed");
49
50    // Create the toast and attach event listeners
51    let toast_template = ToastNotification::CreateToastNotification(toast_xml)?;
52
53    // If you have a valid app id, (ie installed using wix) then use it here.
54    let toast_notifier = ToastNotificationManager::CreateToastNotifierWithId(HSTRING::from(
55        "{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe",
56    ))?;
57
58    // Show the toast.
59    // Note this returns success in every case, including when the toast isn't shown.
60    toast_notifier.Show(&toast_template)
61}
Source

pub fn NotificationMirroring(&self) -> Result<NotificationMirroring, Error>

Source

pub fn SetNotificationMirroring( &self, value: NotificationMirroring, ) -> Result<(), Error>

Source

pub fn RemoteId(&self) -> Result<HSTRING, Error>

Source

pub fn SetRemoteId<'a, Param0>(&self, value: Param0) -> Result<(), Error>
where Param0: IntoParam<'a, HSTRING>,

Source

pub fn Data(&self) -> Result<NotificationData, Error>

Source

pub fn SetData<'a, Param0>(&self, value: Param0) -> Result<(), Error>
where Param0: IntoParam<'a, NotificationData>,

Source

pub fn Priority(&self) -> Result<ToastNotificationPriority, Error>

Source

pub fn SetPriority(&self, value: ToastNotificationPriority) -> Result<(), Error>

Source

pub fn ExpiresOnReboot(&self) -> Result<bool, Error>

Source

pub fn SetExpiresOnReboot(&self, value: bool) -> Result<(), Error>

Source

pub fn IToastNotificationFactory<R, F>(callback: F) -> Result<R, Error>
where F: FnOnce(&IToastNotificationFactory) -> Result<R, Error>,

Trait Implementations§

Source§

impl Clone for ToastNotification

Source§

fn clone(&self) -> ToastNotification

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 Debug for ToastNotification

Source§

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

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

impl Eq for ToastNotification

Source§

impl Interface for ToastNotification

Source§

const IID: GUID

A unique identifier representing this interface.
Source§

fn cast<T>(&self) -> Result<T, Error>
where T: Interface,

Attempts to cast the current interface to another interface using QueryInterface. The name cast is preferred to query because there is a WinRT method named query but not one named cast.
Source§

fn downgrade(&self) -> Result<Weak<Self>, Error>

Attempts to create a Weak reference to this object.
Source§

impl PartialEq for ToastNotification

Source§

fn eq(&self, other: &ToastNotification) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Send for ToastNotification

Source§

impl StructuralPartialEq for ToastNotification

Source§

impl Sync for ToastNotification

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<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.