pub struct Notice { /* private fields */ }Available on crate feature
document only.Expand description
A one-line message with a level label, such as warning, and an optional
code.
The renderer draws the label, then the code if there is one, then the
message, separated by ·.
use ctl_core::document::{Notice, NoticeLevel};
let notice = Notice::new(NoticeLevel::Error, "no such row").code("not-found");
assert_eq!(notice.code_value(), Some("not-found"));Implementations§
Source§impl Notice
impl Notice
Sourcepub fn new(level: NoticeLevel, message: impl Into<Text>) -> Self
pub fn new(level: NoticeLevel, message: impl Into<Text>) -> Self
Build a notice of level with no code.
Sourcepub fn code(self, code: impl Into<String>) -> Self
pub fn code(self, code: impl Into<String>) -> Self
Attach a short code that stays the same for the same kind of notice, so a reader can search for it.
Sourcepub const fn level(&self) -> NoticeLevel
pub const fn level(&self) -> NoticeLevel
The severity, which picks the label and its style.
Sourcepub fn code_value(&self) -> Option<&str>
pub fn code_value(&self) -> Option<&str>
The code set by Self::code, if any.
Trait Implementations§
impl Eq for Notice
impl StructuralPartialEq for Notice
Auto Trait Implementations§
impl Forget for Notice
impl Freeze for Notice
impl Move for Notice
impl RefUnwindSafe for Notice
impl Send for Notice
impl Sync for Notice
impl Unpin for Notice
impl UnsafeUnpin for Notice
impl UnwindSafe for Notice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more