Skip to main content

Report

Struct Report 

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

A failed-computation wrapper that promotes its occurrence to error.

Implementations§

Source§

impl Report

Source

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.

Source

pub fn new<T>(diagnostic: T) -> Self
where T: Diagnostic + Send + Sync + 'static,

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))));
Source

pub fn from_diagnostic(diagnostic: OwnedDiagnostic) -> Self

Source

pub fn from_error<E: Error + Send + Sync + 'static>(error: E) -> Self

Source

pub fn as_diagnostic(&self) -> &dyn Diagnostic

Source

pub fn severity(&self) -> Severity

Source

pub fn descriptor(&self) -> Option<&'static DiagnosticDescriptor>

Source

pub fn contexts(&self) -> &[ContextFrame]

Source

pub fn context(self, context: impl Into<String>) -> Self

Source

pub fn with_context<F, S>(self, context: F) -> Self
where F: FnOnce() -> S, S: Into<String>,

Source

pub fn attach_sources<P>(self, sources: P) -> Self
where P: SourceProvider + Send + Sync + 'static,

Source

pub fn attach_session_sources<P>(self, sources: P) -> Self
where P: SourceProvider + Send + Sync + 'static,

Retains a session source provider with this report.

Source

pub fn session_sources( &self, ) -> Option<&(dyn SourceProvider + Send + Sync + 'static)>

Source

pub fn attached_sources( &self, ) -> Option<&(dyn SourceProvider + Send + Sync + 'static)>

Source

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.

Source

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.

Source

pub fn prepare_attached(&self) -> Result<PreparedDiagnostic<'_>, PrepareError>

Prepares this report using only sources attached to it.

Source

pub fn prepare_attached_with_limits( &self, limits: PreparationLimits, ) -> Result<PreparedDiagnostic<'_>, PrepareError>

Prepares this report using only attached sources and explicit limits.

Source

pub fn display(&self) -> DiagnosticDisplay<'_>

Returns a rich-formatting adapter using attached sources and portable defaults.

Source

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.

Source

pub fn is<T: 'static>(&self) -> bool

Source

pub fn downcast_ref<T: 'static>(&self) -> Option<&T>

Source

pub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T>

Source

pub fn downcast<T: 'static>(self) -> Result<Box<T>, Self>

Source

pub fn into_diagnostic(self) -> OwnedDiagnostic

Trait Implementations§

Source§

impl Debug for Report

Source§

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

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

impl Display for Report

Source§

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

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

impl Error for Report

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Report> for OwnedDiagnostic

Source§

fn from(report: Report) -> Self

Converts to this type from the input type.
Source§

impl<T: Diagnostic + Send + Sync + 'static> From<T> for Report

Source§

fn from(value: T) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Report

§

impl !UnwindSafe for Report

§

impl Forget for Report

§

impl Freeze for Report

§

impl Move for Report

§

impl Send for Report

§

impl Sync for Report

§

impl Unpin for Report

§

impl UnsafeUnpin for Report

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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.