pub struct Report { /* private fields */ }Expand description
A failed-computation wrapper that promotes its occurrence to error.
Implementations§
Source§impl Report
impl Report
Sourcepub fn msg(message: impl Display) -> Self
pub fn msg(message: impl Display) -> Self
Creates a failed-computation report from an ad-hoc display message.
The message is formatted immediately, so it may borrow local values and does not need to satisfy the owned diagnostic transport bounds.
Sourcepub fn new<T>(diagnostic: T) -> Self
pub fn new<T>(diagnostic: T) -> Self
Creates a failed-computation report.
extern crate alloc;
use core::fmt;
use runic_diagnostics::{Diagnostic, Report};
#[derive(Debug)]
struct Borrowed<'a>(&'a str);
impl Diagnostic for Borrowed<'_> {
fn message(&self, out: &mut dyn fmt::Write) -> fmt::Result {
out.write_str(self.0)
}
}
let text = alloc::string::String::from("local");
let _ = Report::new(Borrowed(&text));extern crate alloc;
use alloc::rc::Rc;
use core::{cell::Cell, fmt};
use runic_diagnostics::{Diagnostic, Report};
#[derive(Debug)]
struct Local(Rc<Cell<u32>>);
impl Diagnostic for Local {
fn message(&self, out: &mut dyn fmt::Write) -> fmt::Result {
write!(out, "{}", self.0.get())
}
}
let _ = Report::new(Local(Rc::new(Cell::new(1))));pub fn from_diagnostic(diagnostic: OwnedDiagnostic) -> Self
pub fn from_error<E: Error + Send + Sync + 'static>(error: E) -> Self
pub fn as_diagnostic(&self) -> &dyn Diagnostic
pub fn severity(&self) -> Severity
pub fn descriptor(&self) -> Option<&'static DiagnosticDescriptor>
pub fn contexts(&self) -> &[ContextFrame]
pub fn context(self, context: impl Into<String>) -> Self
pub fn with_context<F, S>(self, context: F) -> Self
pub fn attach_sources<P>(self, sources: P) -> Self
Sourcepub fn attach_session_sources<P>(self, sources: P) -> Self
pub fn attach_session_sources<P>(self, sources: P) -> Self
Retains a session source provider with this report.
pub fn session_sources( &self, ) -> Option<&(dyn SourceProvider + Send + Sync + 'static)>
pub fn attached_sources( &self, ) -> Option<&(dyn SourceProvider + Send + Sync + 'static)>
Sourcepub fn prepare<'a>(
&'a self,
session_sources: &'a dyn SourceProvider,
) -> Result<PreparedDiagnostic<'a>, PrepareError>
pub fn prepare<'a>( &'a self, session_sources: &'a dyn SourceProvider, ) -> Result<PreparedDiagnostic<'a>, PrepareError>
Prepares this report with its occurrence metadata and source universes.
Sourcepub fn prepare_with_limits<'a>(
&'a self,
session_sources: &'a dyn SourceProvider,
limits: PreparationLimits,
) -> Result<PreparedDiagnostic<'a>, PrepareError>
pub fn prepare_with_limits<'a>( &'a self, session_sources: &'a dyn SourceProvider, limits: PreparationLimits, ) -> Result<PreparedDiagnostic<'a>, PrepareError>
Prepares this report with explicit resource limits.
Sourcepub fn prepare_attached(&self) -> Result<PreparedDiagnostic<'_>, PrepareError>
pub fn prepare_attached(&self) -> Result<PreparedDiagnostic<'_>, PrepareError>
Prepares this report using only sources attached to it.
Sourcepub fn prepare_attached_with_limits(
&self,
limits: PreparationLimits,
) -> Result<PreparedDiagnostic<'_>, PrepareError>
pub fn prepare_attached_with_limits( &self, limits: PreparationLimits, ) -> Result<PreparedDiagnostic<'_>, PrepareError>
Prepares this report using only attached sources and explicit limits.
Sourcepub fn display(&self) -> DiagnosticDisplay<'_>
pub fn display(&self) -> DiagnosticDisplay<'_>
Returns a rich-formatting adapter using attached sources and portable defaults.
Sourcepub fn display_with_sources<'a>(
&'a self,
session_sources: &'a dyn SourceProvider,
) -> DiagnosticDisplay<'a>
pub fn display_with_sources<'a>( &'a self, session_sources: &'a dyn SourceProvider, ) -> DiagnosticDisplay<'a>
Returns a rich-formatting adapter with an explicit session source provider.
pub fn is<T: 'static>(&self) -> bool
pub fn downcast_ref<T: 'static>(&self) -> Option<&T>
pub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T>
pub fn downcast<T: 'static>(self) -> Result<Box<T>, Self>
pub fn into_diagnostic(self) -> OwnedDiagnostic
Trait Implementations§
Source§impl Error for Report
impl Error for Report
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()