Skip to main content

IntoReportCollection

Trait IntoReportCollection 

Source
pub trait IntoReportCollection<T> {
    type Context: ?Sized + 'static;

    // Required method
    fn into_report_collection(self) -> ReportCollection<Self::Context, T>;
}
Expand description

Converts errors and reports into ReportCollection instances.

This trait is primarily used internally by the rootcause library for trait bounds. While it’s available for direct use, most applications will find the From trait or iterator methods more convenient for creating collections of reports.

§Internal Usage

This trait provides trait bounds for generic conversions to ReportCollection, similar to how IntoReport works for single reports.

§Automatic Implementations

This trait is automatically implemented for:

  • All types implementing std::error::Error (creates single-item collection)
  • Report instances (creates single-item collection)
  • ReportCollection instances (identity or marker conversion)

§Typical Usage

Most applications won’t need to call this trait directly. Instead, consider:

  • Using iterator methods: iter.map(|e| report!(e)).collect()
  • Using From trait implementations for type conversions
  • Using ReportCollection::new() or builder methods

§Examples

Direct usage is possible, though the alternatives above are often more ergonomic:

use std::io;

use rootcause::{IntoReportCollection, prelude::*, report_collection::ReportCollection};

// Direct usage
let error: io::Error = io::Error::other("An error occurred");
let collection: ReportCollection<io::Error> = error.into_report_collection();
assert_eq!(collection.len(), 1);

// Alternative using iterators (often more convenient for multiple errors)
let errors: Vec<io::Error> = vec![io::Error::other("error 1")];
let collection2: ReportCollection = errors.into_iter().map(|e| report!(e)).collect();

Required Associated Types§

Source

type Context: ?Sized + 'static

The context type of the resulting report collection.

Required Methods§

Source

fn into_report_collection(self) -> ReportCollection<Self::Context, T>

Converts self into a ReportCollection with the specified thread-safety marker.

Most applications will find iterator methods or the From trait more convenient for creating collections.

Implementors§