pub gen: Generation,
pub lastclient: ClientId,
pub gen_before_lastclient: Generation,
+ pub xdata: Option<Box<dyn PieceXData>>,
}
#[derive(Debug,Serialize,Deserialize)]
// ---------- piece trait, and rendering ----------
+#[typetag::serde(tag="type")]
+pub trait PieceXData: Any + Debug + Send + 'static {
+ fn default() -> Box<dyn PieceXData> where Self: Default {
+ Box::new(<Self as Default>::default())
+ }
+}
+
#[typetag::serde]
pub trait Outline: Send + Debug {
fn surround_path(&self, pri: &PieceRenderInstructions) -> Result<Html, IE>;
uos : p.ui_operations()?,
}
}
+
+ #[throws(IE)]
+ pub fn xdata<T:PieceXData+Default>(&mut self) -> &mut T {
+ let m = format!("piece xdata unexpectedly {:?}", &self.xdata);
+ let xdata = self.xdata
+ .get_or_insert_with(|| <T as PieceXData>::default());
+ Any::downcast_mut(xdata).ok_or_else(|| internal_logic_error(m))?
+ }
}
pub trait PieceExt {
// SPDX-License-Identifier: AGPL-3.0-or-later
// There is NO WARRANTY.
+pub use std::any::Any;
pub use std::borrow::Borrow;
pub use std::borrow::Cow;
pub use std::cmp::{self, max, min, Ordering};