Struct nustify::Builder[][src]

pub struct Builder(_);

A builder helper used to create a simple notification or a more complex one (link, image).

Implementations

impl Builder[src]

pub fn new(message: String) -> Self[src]

Create a builder that will resolve to a notification with the provided content and an empty title.

pub fn title(self, title: String) -> Self[src]

Set the title of the notification.

Examples

let notification = Builder::new("Rusty content".to_owned())
    .title("Hello from Rust".to_owned())
    .build();

pub fn extra(self, extra: String) -> Self[src]

Set the value3 of the notification.

Examples

let notification = Builder::new("Rusty content".to_owned())
    .extra("https://i.imgur.com/SFmiPRo.png".to_owned())
   .build();

pub fn image_url(self, url: String) -> Self[src]

Set the image URL of the notification (same as calling extra).

Examples

let notification = Builder::new("Rusty content".to_owned())
    .image_url("https://i.imgur.com/SFmiPRo.png".to_owned())
    .build();

pub fn url(self, url: String) -> Self[src]

Set the link that the notification will follow when tapped (same as calling extra).

Examples

let notification = Builder::new("Rusty content".to_owned())
    .url("https://www.rust-lang.org".to_owned())
    .build();

pub async fn imgur_image<T>(
    self,
    client_id: &str,
    image: T
) -> Result<Self, Error> where
    T: Into<Cow<'static, [u8]>>, 
[src]

Upload an image to Imgur and use the URL returned by the API as the image URL.

Examples

let image_data = std::fs::read("crab.png")?;
let notification = Builder::new("A nice uploaded image".to_owned())
    .imgur_image("MY_IMGUR_KEY", image_data).await?
    .build();

Features

This method requires the imgur feature.

pub fn build(self) -> Notification[src]

Build the notification using all the settings previously provided.

Auto Trait Implementations

impl RefUnwindSafe for Builder

impl Send for Builder

impl Sync for Builder

impl Unpin for Builder

impl UnwindSafe for Builder

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.