OwnedSource

Struct OwnedSource 

Source
pub struct OwnedSource<S>(/* private fields */);
Expand description

Wrapper for owned source content.

OwnedSource wraps any type that can be viewed as bytes (AsRef<[u8]>), such as Vec<u8>, Box<[u8]>, or custom buffer types. The content is stored directly in the cache’s internal memory managed by the C library.

§Example

let buffer = vec![b'c', b'o', b'd', b'e'];
let cache = Cache::new()
    .with_source((OwnedSource::new(buffer), "data.bin"));

let mut report = Report::new()
    .with_title(Level::Error, "Error in binary data")
    .with_label(0..4)
    .render_to_string(&cache)?;

Implementations§

Source§

impl<S: AsRef<[u8]>> OwnedSource<S>

Source

pub fn new(owned: S) -> Self

Create a new owned source from any type implementing AsRef<[u8]>.

Trait Implementations§

Source§

impl<S: AsRef<[u8]>> AddToCache for OwnedSource<S>

Source§

fn add_to_cache(self, cache: &mut *mut mu_Cache) -> *mut mu_Source

Add this source to the cache. Read more
Source§

impl<S: AsRef<[u8]>> From<S> for OwnedSource<S>

Source§

fn from(value: S) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<S> Freeze for OwnedSource<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for OwnedSource<S>
where S: RefUnwindSafe,

§

impl<S> Send for OwnedSource<S>
where S: Send,

§

impl<S> Sync for OwnedSource<S>
where S: Sync,

§

impl<S> Unpin for OwnedSource<S>
where S: Unpin,

§

impl<S> UnwindSafe for OwnedSource<S>
where S: UnwindSafe,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.