use alloc::borrow::Cow;
use core::panic::Location;
use crate::errors::BunsenErrorKind;
#[derive(Clone, Debug)]
pub struct Frame {
message: Cow<'static, str>,
details: Option<Cow<'static, str>>,
location: &'static Location<'static>,
}
impl Frame {
pub(crate) fn new(
message: Cow<'static, str>,
details: Option<Cow<'static, str>>,
location: &'static Location<'static>,
) -> Self {
Self {
message,
details,
location,
}
}
pub fn message(&self) -> &str {
&self.message
}
pub fn details(&self) -> Option<&str> {
self.details.as_deref()
}
pub fn location(&self) -> &'static Location<'static> {
self.location
}
}
#[derive(Clone, Copy, Debug)]
pub struct Remark {
from: BunsenErrorKind,
to: BunsenErrorKind,
location: &'static Location<'static>,
}
impl Remark {
pub(crate) fn new(
from: BunsenErrorKind,
to: BunsenErrorKind,
location: &'static Location<'static>,
) -> Self {
Self { from, to, location }
}
pub fn from(&self) -> BunsenErrorKind {
self.from
}
pub fn to(&self) -> BunsenErrorKind {
self.to
}
pub fn location(&self) -> &'static Location<'static> {
self.location
}
}