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>
impl<'a> TypedMessage<'a>
Sourcepub fn styled(ty: &'a str, type_style: &'a str, message: &'a str) -> Self
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.
Sourcepub fn naked_text(ty: &'a str, message: &'a str) -> Self
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>"}Sourcepub fn with_code(self, code: &'a str) -> Self
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.