TypedMessage

Struct TypedMessage 

Source
pub struct TypedMessage<'a> { /* private fields */ }
Expand description

Generic textual message with type prefix.

Use this message type to display any kinds of warnings, errors etc. The type prefix can be stylized in text mode.

Implementations§

Source§

impl<'a> TypedMessage<'a>

Source

pub fn styled(ty: &'a str, type_style: &'a str, message: &'a str) -> Self

Create a message with the given type, its style and the message text proper.

Source

pub fn naked_text(ty: &'a str, message: &'a str) -> Self

Create a message that does not print type prefix in text mode.

§Example

Scarb uses this for emitting Cairo compiler diagnostics. In text mode it prints the diagnostic as-is, while in JSON mode it wraps it as:

{"type":"diagnostic","message":"<diagnostic>"}
Source

pub fn with_code(self, code: &'a str) -> Self

Sometimes, a message may be associated with a short machine-readable descriptor. For example, some compilers associate numerical codes with various kinds of errors that can be produced. The optional code field allows carrying this information. This will be shown as suffix in text mode, and as a code field in structured mode.

Trait Implementations§

Source§

impl Message for TypedMessage<'_>

Source§

fn text(self) -> String

Return textual representation of this message. Read more
Source§

fn structured<S: Serializer>(self, ser: S) -> Result<S::Ok, S::Error>

Serialize this structured message to a serializer which is routed to Ui output stream. Read more
Source§

impl<'a> Serialize for TypedMessage<'a>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for TypedMessage<'a>

§

impl<'a> RefUnwindSafe for TypedMessage<'a>

§

impl<'a> Send for TypedMessage<'a>

§

impl<'a> Sync for TypedMessage<'a>

§

impl<'a> Unpin for TypedMessage<'a>

§

impl<'a> UnwindSafe for TypedMessage<'a>

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, 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, 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.