Msg

Struct Msg 

Source
pub struct Msg { /* private fields */ }
Expand description

Push Notification Message structure.

This struct represents a push notification message that can be sent to devices. It contains various fields to customize the notification’s behavior and appearance.

§Example

use bark::msg::Msg;

// new a simple message with title and body
let msg = Msg::new("title", "body");

// new a message with title = Notification and body
let mut msg = Msg::with_body("body");

// set some fields
msg.set_level(Level::ACTIVE);
msg.set_badge(1);
// and so on

Implementations§

Source§

impl Msg

Source

pub fn new(title: &str, body: &str) -> Self

Creates a new Msg instance with a title and body.

§Arguments
  • title: The title of the notification.
  • body: The content/body of the notification.
§Returns

A new Msg instance.

Source

pub fn with_body(body: &str) -> Self

Creates a new Msg instance with only a body.

§Arguments
  • body: The content/body of the notification.
§Returns

A new Msg instance with the title set to “Notification”.

Source

pub fn get_id(&self) -> Option<String>

Source

pub fn is_deleted(&self) -> bool

Source

pub fn set_level(&mut self, level: Level) -> &mut Self

Sets the interruption level of the notification.

§Arguments
  • level: The interruption level Level
§Returns

A mutable reference to self for method chaining.

Source

pub fn set_badge(&mut self, badge: u64) -> &mut Self

Sets the badge number.

§Arguments
  • badge: The badge number to display on the app icon.
§Returns

A mutable reference to self for method chaining.

Source

pub fn set_auto_copy(&mut self, auto_copy: bool) -> &mut Self

Sets whether to automatically copy the notification content.

§Arguments
  • auto_copy: false to disable, true to enable.
§Returns

A mutable reference to self for method chaining.

Source

pub fn set_copy(&mut self, copy: &str) -> &mut Self

Sets specific content to copy when the notification is copied.

§Arguments
  • copy: The content to copy.
§Returns

A mutable reference to self for method chaining.

Source

pub fn set_sound(&mut self, sound: &str) -> &mut Self

Sets the sound file to play with the notification.

§Arguments
  • sound: The sound file name.
§Returns

A mutable reference to self for method chaining.

Source

pub fn set_icon(&mut self, icon: &str) -> &mut Self

Sets a custom icon URL for the notification.

§Arguments
  • icon: The icon URL.
§Returns

A mutable reference to self for method chaining.

Source

pub fn set_group(&mut self, group: &str) -> &mut Self

Sets the group identifier for notifications.

§Arguments
  • group: The group identifier.
§Returns

A mutable reference to self for method chaining.

Source

pub fn set_is_archive(&mut self, is_archive: bool) -> &mut Self

Sets whether to archive the notification.

§Arguments
  • is_archive: true to save, false to not save.
§Returns

A mutable reference to self for method chaining.

Source

pub fn set_url(&mut self, url: &str) -> &mut Self

Sets the URL to open when the notification is clicked.

§Arguments
  • url: The URL.
§Returns

A mutable reference to self for method chaining.

Source

pub fn set_iv(&mut self, iv: &str) -> &mut Self

Sets the initialization vector for encryption.

§Arguments
  • iv: The initialization vector.
§Returns

A mutable reference to self for method chaining.

Source

pub fn gen_iv(&mut self) -> &mut Self

Generates a random initialization vector.

§Returns

A mutable reference to self for method chaining.

Source

pub fn set_enc_type(&mut self, enc_type: EncryptType) -> &mut Self

Sets the encryption type and updates the cipher.

§Arguments
§Panics

Panics if the encryption type already set.

§Returns

A mutable reference to self for method chaining.

Source

pub fn set_mode(&mut self, mode: EncryptMode) -> &mut Self

Sets the encryption mode and updates the cipher.

§Arguments
§Panics

Panics if the encryption mode already set.

§Returns

A mutable reference to self for method chaining.

Source

pub fn set_key(&mut self, key: &str) -> &mut Self

Sets the encryption key.

§Arguments
  • key: The encryption key.
§Returns

A mutable reference to self for method chaining.

Source

pub fn set_id(&mut self, msg_id: &str) -> &mut Self

Source

pub fn set_deleted(&mut self) -> &mut Self

Source

pub fn serialize(&self) -> String

Serializes the message into a JSON string, encrypting the message if necessary.

§Returns

A String containing the serialized message.

Auto Trait Implementations§

§

impl Freeze for Msg

§

impl RefUnwindSafe for Msg

§

impl Send for Msg

§

impl Sync for Msg

§

impl Unpin for Msg

§

impl UnwindSafe for Msg

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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.
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