Skip to main content

Msg

Struct Msg 

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

§Message.

The Msg struct provides a partitioned, contiguous byte source to hold arbitrary messages of the “Error: Oh no!” variety. They can be modified efficiently in place (per-part) and printed to STDOUT with Msg::print or STDERR with Msg::eprint (or via Display).

There are two crate feature gates that augment this struct (at the expense of additional dependencies):

Everything else comes stock!

§Examples

use fyi_msg::{Msg, MsgKind};

Msg::new(MsgKind::Success, "You did it!")
    .with_newline(true)
    .print();

There are a bunch of built-in prefix types (MsgKind), each of which (except MsgKind::None and MsgKind::Confirm) has a corresponding “quick” method on this struct to save the effort of chaining Msg::new and Msg::with_newline.

use fyi_msg::{Msg, MsgKind};

// Same as before, but more concise.
Msg::success("You did it!").print();

Confirmations have a convenience macro instead, confirm, that handles all the setup and prompting, returning a simple bool indicating the yes/noness of the user response.

Take a look at examples/msg.rs for a breakdown of the various options.

§Conversion

Msg objects are essentially just fancy strings.

You can borrow the the result with Msg::as_str/Msg::as_bytes or steal it with Msg::into_string/Msg::into_bytes.

Implementations§

Source§

impl Msg

One-Shots.
Source

pub fn aborted<S: AsRef<str>>(msg: S) -> Self

§New Aborted.

Create a new Msg with a built-in MsgKind::Aborted prefix and trailing line break.

§Examples.
use fyi_msg::{Msg, MsgKind};

assert_eq!(
    Msg::aborted("Hello World"),
    Msg::new(MsgKind::Aborted, "Hello World").with_newline(true),
);
Source

pub fn crunched<S: AsRef<str>>(msg: S) -> Self

§New Crunched.

Create a new Msg with a built-in MsgKind::Crunched prefix and trailing line break.

§Examples.
use fyi_msg::{Msg, MsgKind};

assert_eq!(
    Msg::crunched("Hello World"),
    Msg::new(MsgKind::Crunched, "Hello World").with_newline(true),
);
Source

pub fn debug<S: AsRef<str>>(msg: S) -> Self

§New Debug.

Create a new Msg with a built-in MsgKind::Debug prefix and trailing line break.

§Examples.
use fyi_msg::{Msg, MsgKind};

assert_eq!(
    Msg::debug("Hello World"),
    Msg::new(MsgKind::Debug, "Hello World").with_newline(true),
);
Source

pub fn done<S: AsRef<str>>(msg: S) -> Self

§New Done.

Create a new Msg with a built-in MsgKind::Done prefix and trailing line break.

§Examples.
use fyi_msg::{Msg, MsgKind};

assert_eq!(
    Msg::done("Hello World"),
    Msg::new(MsgKind::Done, "Hello World").with_newline(true),
);
Source

pub fn error<S: AsRef<str>>(msg: S) -> Self

§New Error.

Create a new Msg with a built-in MsgKind::Error prefix and trailing line break.

§Examples.
use fyi_msg::{Msg, MsgKind};

assert_eq!(
    Msg::error("Hello World"),
    Msg::new(MsgKind::Error, "Hello World").with_newline(true),
);
Source

pub fn found<S: AsRef<str>>(msg: S) -> Self

§New Found.

Create a new Msg with a built-in MsgKind::Found prefix and trailing line break.

§Examples.
use fyi_msg::{Msg, MsgKind};

assert_eq!(
    Msg::found("Hello World"),
    Msg::new(MsgKind::Found, "Hello World").with_newline(true),
);
Source

pub fn info<S: AsRef<str>>(msg: S) -> Self

§New Info.

Create a new Msg with a built-in MsgKind::Info prefix and trailing line break.

§Examples.
use fyi_msg::{Msg, MsgKind};

assert_eq!(
    Msg::info("Hello World"),
    Msg::new(MsgKind::Info, "Hello World").with_newline(true),
);
Source

pub fn notice<S: AsRef<str>>(msg: S) -> Self

§New Notice.

Create a new Msg with a built-in MsgKind::Notice prefix and trailing line break.

§Examples.
use fyi_msg::{Msg, MsgKind};

assert_eq!(
    Msg::notice("Hello World"),
    Msg::new(MsgKind::Notice, "Hello World").with_newline(true),
);
Source

pub fn review<S: AsRef<str>>(msg: S) -> Self

§New Review.

Create a new Msg with a built-in MsgKind::Review prefix and trailing line break.

§Examples.
use fyi_msg::{Msg, MsgKind};

assert_eq!(
    Msg::review("Hello World"),
    Msg::new(MsgKind::Review, "Hello World").with_newline(true),
);
Source

pub fn skipped<S: AsRef<str>>(msg: S) -> Self

§New Skipped.

Create a new Msg with a built-in MsgKind::Skipped prefix and trailing line break.

§Examples.
use fyi_msg::{Msg, MsgKind};

assert_eq!(
    Msg::skipped("Hello World"),
    Msg::new(MsgKind::Skipped, "Hello World").with_newline(true),
);
Source

pub fn success<S: AsRef<str>>(msg: S) -> Self

§New Success.

Create a new Msg with a built-in MsgKind::Success prefix and trailing line break.

§Examples.
use fyi_msg::{Msg, MsgKind};

assert_eq!(
    Msg::success("Hello World"),
    Msg::new(MsgKind::Success, "Hello World").with_newline(true),
);
Source

pub fn task<S: AsRef<str>>(msg: S) -> Self

§New Task.

Create a new Msg with a built-in MsgKind::Task prefix and trailing line break.

§Examples.
use fyi_msg::{Msg, MsgKind};

assert_eq!(
    Msg::task("Hello World"),
    Msg::new(MsgKind::Task, "Hello World").with_newline(true),
);
Source

pub fn warning<S: AsRef<str>>(msg: S) -> Self

§New Warning.

Create a new Msg with a built-in MsgKind::Warning prefix and trailing line break.

§Examples.
use fyi_msg::{Msg, MsgKind};

assert_eq!(
    Msg::warning("Hello World"),
    Msg::new(MsgKind::Warning, "Hello World").with_newline(true),
);
Source§

impl Msg

§Construction.
Source

pub fn new<P, S>(prefix: P, msg: S) -> Self
where P: IntoMsgPrefix, S: AsRef<str>,

§New Message.

This creates a new Msg with prefix and message parts.

The prefix can be a built-in MsgKind, or something custom, with or without ANSI formatting.

Custom prefixes can be any of the usual string types — &str, String/&String, or Cow<str>/&Cow<str> — optionally tupled with an AnsiColor for sex appeal.

Custom prefixes should not include the ": " separator, as that is appended automatically to all non-empty values.

To create a message without a prefix, just pass the content to Msg::from instead.

§Examples
use fyi_msg::{
    AnsiColor,
    Msg,
    MsgKind,
};

// Built-in prefix. Easy!
assert_eq!(
    Msg::new(MsgKind::Info, "This is a message."),
    "\x1b[1;95mInfo:\x1b[0m This is a message.",
);

// Custom prefix, no formatting.
assert_eq!(
    Msg::new("Best Picture", "C.H.U.D."),
    "Best Picture: C.H.U.D.",
);

// Custom prefix, red and bold.
assert_eq!(
    Msg::new(("Crap", AnsiColor::Red), "Something broke!"),
    "\x1b[1;31mCrap:\x1b[0m Something broke!"
);

// Same as above, but with the color as a `u8`.
assert_eq!(
    Msg::new(("Crap", 1), "Something broke!"),
    "\x1b[1;31mCrap:\x1b[0m Something broke!"
);

// If for some reason you pass an empty string, the prefix will be
// omitted.
assert_eq!(
    Msg::new(("", AnsiColor::Misc199), "Plain Jane."),
    "Plain Jane.",
);
Source§

impl Msg

§Getters.
Source

pub const fn as_bytes(&self) -> &[u8]

§As Byte Slice.

Return the formatted message as a byte slice.

§Examples
use fyi_msg::Msg;

assert_eq!(
    Msg::from("Hello world").as_bytes(),
    b"Hello world",
);
Source

pub const fn as_str(&self) -> &str

§As String Slice.

Return the formatted message as a string slice.

§Examples
use fyi_msg::Msg;

assert_eq!(
    Msg::from("Hello world").as_str(),
    "Hello world",
);
Source

pub fn fitted(&self, width: usize) -> Cow<'_, str>

Available on crate feature fitted only.
§Fit to Width.

Return the message as a string with its lines capped to the given display width.

This is essentially just a convenience wrapper around fit_to_width; refer to that method documentation for more details.

§Examples
use fyi_msg::{AnsiColor, Msg};

let msg = Msg::new(("Name", AnsiColor::Blue), "Björk")
    .with_suffix(" (the Great)")
    .with_newline(true); // Trailing line breaks are fine.

// As it is:
assert_eq!(
    msg.as_str(),
    "\x1b[1;34mName:\x1b[0m Björk (the Great)\n",
);

// Fitting to 20 columns loses some of the suffix, but the trailing
// line break is preserved.
assert_eq!(
    msg.fitted(20),
    "\x1b[1;34mName:\x1b[0m Björk (the Gre\n",
);

// Fitting to 10 columns drops the suffix entirely, loses a bit of
// the message part, but the line break hangs on.
// the trailing line break.
assert_eq!(
    msg.fitted(10),
    "\x1b[1;34mName:\x1b[0m Björ\n",
);

// Fitting to 4 columns kills most everything, but the ANSI reset and
// line break are preserved.
assert_eq!(
    msg.fitted(4),
    "\x1b[1;34mName\x1b[0m\n",
);
Source

pub fn into_bytes(self) -> Vec<u8>

§Into Bytes.

Consume self, returning an owned byte vector.

§Examples
use fyi_msg::Msg;

assert_eq!(
    Msg::from("Hello world").into_bytes(),
    b"Hello world",
);
Source

pub fn into_string(self) -> String

§Into String.

Consume self, returning the inner string.

§Examples
use fyi_msg::Msg;

assert_eq!(
    Msg::from("Hello world").into_string(),
    "Hello world",
);
Source

pub const fn is_empty(&self) -> bool

§Is Empty?

Returns true if the message is empty.

§Examples
use fyi_msg::Msg;

// One way to get an empty message.
assert!(Msg::from("").is_empty());
Source

pub const fn len(&self) -> usize

§Message Length.

Return the total number of bytes in the formatted message.

§Examples
use fyi_msg::Msg;

assert_eq!(Msg::from("ABC").len(), 3);
assert_eq!(
    Msg::done("Goodbye.").len(),
    26,
); // Don't forget about ANSI…
Source§

impl Msg

§Setters.
Source

pub fn set_indent(&mut self, tabs: u8)

§Set Indentation.

(Re)set the message’s indentation level to tabs “tabs” (four spaces each), up to a maximum depth of eight (thirty-two spaces total).

§Examples
use fyi_msg::Msg;

let mut msg = Msg::from("Hello world.");

msg.set_indent(1);
assert_eq!(msg, "    Hello world.");

msg.set_indent(2);
assert_eq!(msg, "        Hello world.");

msg.set_indent(3);
assert_eq!(msg, "            Hello world.");

// …

msg.set_indent(7);
assert_eq!(msg, "                            Hello world.");

msg.set_indent(8);
assert_eq!(msg, "                                Hello world.");

msg.set_indent(9);
assert_eq!(msg, "                                Hello world."); // Same as 8.

// …

msg.set_indent(u8::MAX);
assert_eq!(msg, "                                Hello world."); // Same as 8.

// Back to zero!
msg.set_indent(0);
assert_eq!(msg, "Hello world.");
Source

pub fn set_msg<S: AsRef<str>>(&mut self, msg: S)

§Set Message Content.

(Re)set the actual message part of the message.

use fyi_msg::Msg;

let mut msg = Msg::from("Hello");
assert_eq!(msg, "Hello");

msg.set_msg("Goodbye");
assert_eq!(msg, "Goodbye");
Source

pub fn set_newline(&mut self, enabled: bool)

§Set Trailing Linebreak.

Add/remove the message’s trailing line break.

§Examples

Messages created with Msg::from, Msg::new, and MsgKind::into_msg have no trailing line break by default:

use fyi_msg::Msg;

let mut msg = Msg::from("Hello World!");
assert_eq!(msg, "Hello World!");

msg.set_newline(true); // Add it.
assert_eq!(msg, "Hello World!\n");

Messages created with the kind-specific helper methods, however, do have a line break by default:

use fyi_msg::Msg;

let mut msg = Msg::info("Hello World!");
assert_eq!(msg, "\x1b[1;95mInfo:\x1b[0m Hello World!\n");

msg.set_newline(false); // Remove it.
assert_eq!(msg, "\x1b[1;95mInfo:\x1b[0m Hello World!");
Source

pub fn set_prefix<P: IntoMsgPrefix>(&mut self, prefix: P)

§Set Prefix.

(Re/un)set the message prefix.

As with Msg::new, prefixes can be a built-in MsgKind or custom string, with or without formatting.

To remove the prefix entirely, pass MsgKind::None or "".

§Examples
use fyi_msg::{
    AnsiColor,
    Msg,
    MsgKind,
};

let mut msg = Msg::new(MsgKind::Error, "Uh oh!");
assert_eq!(
    msg,
    "\x1b[1;91mError:\x1b[0m Uh oh!"
);

// Downgrade to warning.
msg.set_prefix(MsgKind::Warning);
assert_eq!(
    msg,
    "\x1b[1;93mWarning:\x1b[0m Uh oh!"
);

// Escalate it to profanity.
msg.set_prefix(("Shit", AnsiColor::Misc199));
assert_eq!(
    msg,
    "\x1b[1;38;5;199mShit:\x1b[0m Uh oh!"
);

// Remove the prefix altogether.
msg.set_prefix(MsgKind::None);
assert_eq!(msg, "Uh oh!");
Source

pub fn set_suffix<S: AsRef<str>>(&mut self, suffix: S)

§Set Suffix.

(Re)set the message suffix.

Unlike prefixes, no automatic formatting is applied to suffixes. For example, if you want a space separating the message content and suffix, the suffix should start with a leading space.

§Examples
use fyi_msg::Msg;

let mut msg = Msg::from("Checked!");
msg.set_suffix(" ✓");

assert_eq!(
    msg,
    "Checked! ✓",
);
Source

pub fn set_timestamp(&mut self, enabled: bool)

Available on crate feature timestamps only.
§Set Timestamp.

Add/remove a timestamp to/from the beginning the of the message.

§Examples.
use fyi_msg::Msg;

let mut msg = Msg::from("Parsed log.");
msg.set_timestamp(true); // [YYYY-MM-DD hh:mm:ss] Parsed log.
Source

pub fn strip_ansi(&mut self) -> bool

§Strip ANSI Formatting.

Remove colors, bold, etc. from the message.

This is best called last, as changes made after this might reintroduce fancy formatting.

See also Msg::without_ansi.

Returns true if the content was modified.

§Examples
use fyi_msg::Msg;

let mut msg = Msg::info("5,000 matching files were found.");
assert!(msg.strip_ansi());

// Now it reads:
assert_eq!(
    msg,
    "Info: 5,000 matching files were found.\n",
);
Source§

impl Msg

§Builder Setters.
Source

pub fn with_indent(self, tabs: u8) -> Self

§With/Without Indentation.

(Re)set the message’s indentation level to tabs “tabs” (four spaces each), up to a maximum depth of eight (thirty-two spaces total).

§Examples
use fyi_msg::Msg;

let msg = Msg::from("Hello world.").with_indent(1);
assert_eq!(msg, "    Hello world.");

let msg = Msg::from("Hello world.").with_indent(2);
assert_eq!(msg, "        Hello world.");

let msg = Msg::from("Hello world.").with_indent(3);
assert_eq!(msg, "            Hello world.");

// …

let msg = Msg::from("Hello world.").with_indent(7);
assert_eq!(msg, "                            Hello world.");

let msg = Msg::from("Hello world.").with_indent(8);
assert_eq!(msg, "                                Hello world.");

let msg = Msg::from("Hello world.").with_indent(9);
assert_eq!(msg, "                                Hello world."); // Same as 8.

// …

let msg = Msg::from("Hello world.").with_indent(u8::MAX);
assert_eq!(msg, "                                Hello world."); // Same as 8.
Source

pub fn with_msg<S: AsRef<str>>(self, msg: S) -> Self

§With Message Content.

In most cases where the message content needs to change, Msg::set_msg probably makes more sense, but everything else gets a builder method, so why not?

use fyi_msg::Msg;

let msg = Msg::from("Hello")
    .with_msg("Goodbye");
assert_eq!(msg, "Goodbye");
Source

pub fn with_newline(self, enabled: bool) -> Self

§With/Without Trailing Linebreak.

Add/remove the message’s trailing line break.

§Examples

Messages created with Msg::from, Msg::new, and MsgKind::into_msg have no trailing line break by default:

use fyi_msg::Msg;

let mut msg = Msg::from("Hello World!");
assert_eq!(
    msg,
    "Hello World!",
);

assert_eq!(
    msg.with_newline(true), // Add line break.
    "Hello World!\n",
);

Messages created with the built-in helper methods, however, do:

use fyi_msg::Msg;

let mut msg = Msg::info("Hello World!");
assert_eq!(
    msg,
    "\x1b[1;95mInfo:\x1b[0m Hello World!\n",
);

assert_eq!(
    msg.with_newline(false), // Remove line break.
    "\x1b[1;95mInfo:\x1b[0m Hello World!",
);
Source

pub fn with_prefix<P: IntoMsgPrefix>(self, prefix: P) -> Self

§With Prefix.

(Re/un)set the message prefix.

As with Msg::new, prefixes can be a built-in MsgKind or custom string, with or without formatting.

To remove the prefix entirely, pass MsgKind::None or "".

§Examples
use fyi_msg::{Msg, MsgKind};

// A built-in.
assert_eq!(
    Msg::from("Uh oh!").with_prefix(MsgKind::Error),
    "\x1b[1;91mError:\x1b[0m Uh oh!",
);

// A custom and plain prefix.
assert_eq!(
    Msg::from("Uh oh!").with_prefix("Nope"),
    "Nope: Uh oh!",
);

// A custom and blue prefix.
assert_eq!(
    Msg::from("Uh oh!").with_prefix(("Meh", 4)),
    "\x1b[1;34mMeh:\x1b[0m Uh oh!",
);
Source

pub fn with_suffix<S: AsRef<str>>(self, suffix: S) -> Self

§With Suffix.

(Re)set the message suffix.

Unlike prefixes, no automatic formatting is applied to suffixes. For example, if you want a space separating the message content and suffix, the suffix should start with a leading space.

§Examples
use fyi_msg::Msg;

let msg = Msg::from("Checked!")
    .with_suffix(" ✓");

assert_eq!(
    msg,
    "Checked! ✓",
);
Source

pub fn with_timestamp(self, enabled: bool) -> Self

Available on crate feature timestamps only.
§With/Without Timestamp.

Add/remove a timestamp to/from the beginning the of the message.

§Examples.
use fyi_msg::Msg;

let msg = Msg::from("Parsed log.")
    .with_timestamp(true); // [YYYY-MM-DD hh:mm:ss] Parsed log.
Source

pub fn without_ansi(self) -> Self

§Without ANSI Formatting.

Remove colors, bold, etc. from the message.

This is best called last, as changes made after this might reintroduce fancy formatting.

For unchained usage, see Msg::strip_ansi.

§Examples
use fyi_msg::Msg;

assert_eq!(
    Msg::info("5,000 matching files were found.").without_ansi(),
    "Info: 5,000 matching files were found.\n",
);
Source§

impl Msg

§Printing.
Source

pub fn print(&self)

This is a convenience method for printing a message to STDOUT without having to go through the standard library’s print macro.

§Examples
use fyi_msg::Msg;

let msg = Msg::info("Hello World!");

// You've got two choices to print.
print!("{msg}"); // \x1b[1;95mInfo:\x1b[0m Hello World!\n
msg.print();     // \x1b[1;95mInfo:\x1b[0m Hello World!\n
// This line break is embedded in the message itself.   ^

// As such, you probably don't want to do this:
println!("{msg}"); // \x1b[1;95mInfo:\x1b[0m Hello World!\n\n

// Of course, messages don't _have to_ embed the break:
let msg = Msg::info("Hello World!").with_newline(false);
println!("{msg}"); // \x1b[1;95mInfo:\x1b[0m Hello World!\n
Source

pub fn eprint(&self)

This is a convenience method for printing a message to STDERR without having to go through the standard library’s eprint macro.

§Examples
use fyi_msg::Msg;

let msg = Msg::info("Hello World!");

// You've got two choices to print.
eprint!("{msg}"); // \x1b[1;95mInfo:\x1b[0m Hello World!\n
msg.eprint();     // \x1b[1;95mInfo:\x1b[0m Hello World!\n
// This line break is embedded in the message itself.   ^

// As such, you probably don't want to do this:
eprintln!("{msg}"); // \x1b[1;95mInfo:\x1b[0m Hello World!\n\n

// Of course, messages don't _have to_ embed the break:
let msg = Msg::info("Hello World!").with_newline(false);
eprintln!("{msg}"); // \x1b[1;95mInfo:\x1b[0m Hello World!\n
Source

pub fn prompt(&self) -> bool

§Prompt.

This produces a simple y/N input prompt, requiring the user type “Y” or “N” to proceed. Positive values return true, negative values return false. The default (if the user just hits <ENTER>) is “N”.

Note: the prompt normalizes the suffix and newline parts for display. If your message contains these parts, they will be ignored by the prompt action, but will be retained in the original struct should you wish to use it in some other manner later in your code.

Every example in the docs shows this in combination with the built-in MsgKind::Confirm prefix, but this can be called on any Msg object.

§Example
use fyi_msg::{confirm, Msg, MsgKind};

// The manual way:
if Msg::new(MsgKind::Confirm, "Do you like chickens?").prompt() {
    println!("That's great! They like you too!");
}

// The macro way:
if confirm!("Do you like chickens?") {
    println!("That's great! They like you too!");
}
Source

pub fn prompt_with_default(&self, default: bool) -> bool

§Prompt (w/ Default).

Same as Msg::prompt, but with the option of specifying the default return value — true for Yes, false for No — that will be returned if the user just hits <ENTER>.

Source

pub fn eprompt(&self) -> bool

§Prompt (STDERR).

Same as Msg::prompt, but printed to STDERR instead of STDOUT.

Source

pub fn eprompt_with_default(&self, default: bool) -> bool

§Prompt (w/ Default, STDERR).

Same as Msg::prompt_with_default, but printed to STDERR instead of STDOUT.

Source§

impl Msg

§Miscellaneous.
Source

pub fn with_bytes_saved(self, state: BeforeAfter) -> Self

Available on crate feature progress only.
§Bytes Saved Suffix.

A lot of our own programs using this lib crunch data and report the savings as a suffix. This method just provides a quick way to generate that.

Trait Implementations§

Source§

impl AsRef<[u8]> for Msg

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<str> for Msg

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<str> for Msg

Source§

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
Source§

impl Clone for Msg

Source§

fn clone(&self) -> Msg

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Msg

Source§

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

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

impl Default for Msg

Source§

fn default() -> Msg

Returns the “default value” for a type. Read more
Source§

impl Display for Msg

Source§

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

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

impl From<&String> for Msg

Source§

fn from(src: &String) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for Msg

Source§

fn from(src: &str) -> Self

Converts to this type from the input type.
Source§

impl From<Cow<'_, str>> for Msg

Source§

fn from(src: Cow<'_, str>) -> Self

Converts to this type from the input type.
Source§

impl From<Msg> for String

Source§

fn from(src: Msg) -> Self

Converts to this type from the input type.
Source§

impl From<Progless> for Msg

Available on crate feature progress only.
Source§

fn from(src: Progless) -> Self

§Into Msg

This provides a simple way to convert a (finished) Progless instance into a generic summary Msg that can e.g. be printed.

For a more advanced summary, use the Progless::summary method.

Source§

impl From<String> for Msg

Source§

fn from(src: String) -> Self

Converts to this type from the input type.
Source§

impl Hash for Msg

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Msg

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq<&[u8]> for Msg

Source§

fn eq(&self, other: &&[u8]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&Box<[u8]>> for Msg

Source§

fn eq(&self, other: &&Box<[u8]>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&Box<str>> for Msg

Source§

fn eq(&self, other: &&Box<str>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&Cow<'_, [u8]>> for Msg

Source§

fn eq(&self, other: &&Cow<'_, [u8]>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&Cow<'_, str>> for Msg

Source§

fn eq(&self, other: &&Cow<'_, str>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&String> for Msg

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&Vec<u8>> for Msg

Source§

fn eq(&self, other: &&Vec<u8>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&str> for Msg

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<[u8]> for Msg

Source§

fn eq(&self, other: &[u8]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Box<[u8]>> for Msg

Source§

fn eq(&self, other: &Box<[u8]>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Box<str>> for Msg

Source§

fn eq(&self, other: &Box<str>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Cow<'_, [u8]>> for Msg

Source§

fn eq(&self, other: &Cow<'_, [u8]>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Cow<'_, str>> for Msg

Source§

fn eq(&self, other: &Cow<'_, str>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Msg> for &[u8]

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Msg> for &Box<[u8]>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Msg> for &Box<str>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Msg> for &Cow<'_, [u8]>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Msg> for &Cow<'_, str>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Msg> for &String

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Msg> for &Vec<u8>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Msg> for &str

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Msg> for [u8]

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Msg> for Box<[u8]>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Msg> for Box<str>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Msg> for Cow<'_, [u8]>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Msg> for Cow<'_, str>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Msg> for String

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Msg> for Vec<u8>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Msg> for str

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<String> for Msg

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Vec<u8>> for Msg

Source§

fn eq(&self, other: &Vec<u8>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<str> for Msg

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Msg

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Msg

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for Msg

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.