use serde::Serialize;
use std::error::Error;
use crate::{
modules::types::{
property::Property,
exception::BaseException
}
};
pub trait ExceptionUtils<T: Transform<T>> {
fn get_property(&self) -> Box<Property<T>>;
fn set_property(&mut self, property: Box<Property<T>>);
fn get_ptr(&self) -> T;
fn set_ptr(&mut self, ptr: T);
}
pub trait Transform<T>:
ExceptionUtils<T> + 'static
+ Error
+ Serialize
+ Clone
where T: Transform<T>
{
fn down(this: T) -> BaseException<T> {
let mut inner = this.clone();
inner.set_property(Box::new(Property {
name: "".to_string(),
..Default::default()
}));
BaseException {
property : this.get_property(),
target_ptr: inner
}
}
fn up(this: BaseException<T>) -> T {
let mut result = this.target_ptr;
result.set_property(this.property.clone());
result
}
}