type SR = Result<(),SE>;
pub trait Piece : Send + Debug {
+ // #[throws] doesn't work here for some reason
fn svg_piece(&self, f: &mut String, pri: &PieceRenderInstructions) -> SR;
+
#[throws(SE)]
fn outline_path(&self, pri : &PieceRenderInstructions) -> String;
+
#[throws(SE)]
fn surround_path(&self, pri : &PieceRenderInstructions) -> String;
- fn svg_x_defs(&self, pri : &PieceRenderInstructions) -> String;
+
+ fn svg_x_defs(&self, f: &mut String, pri : &PieceRenderInstructions) -> SR;
+
#[throws(SE)]
fn thresh_dragraise(&self, pri : &PieceRenderInstructions)
-> Option<Coord>;
write!(defs,
r##"<path id="select{}" stroke="black" fill="none" d="{}"/>"##,
pri.id, pr.p.surround_path(&pri)?)?;
- write!(defs, "{}", pr.p.svg_x_defs(&pri))?;
+ pr.p.svg_x_defs(&mut defs, &pri)?;
defs
}
-> Option<Coord> {
Some(self.approx_dia / 2)
}
- fn svg_x_defs(&self, _pri : &PieceRenderInstructions) -> String {
- "".to_owned()
+ #[throws(SE)]
+ fn svg_x_defs(&self, _f: &mut String, _pri : &PieceRenderInstructions) {
}
#[throws(SE)]
fn describe_html(&self, face : Option<FaceId>) -> String {