Open asafyish opened 6 years ago
I'm not sure I understand the question. Does something like the following solve your problem?
enum SquareOrCircle<'a> {
Square(Square::Builder<'a>),
Circle(Circle::Builder<'a>),
}
fn get_square<'a>(messge: &'a mut capnp::message::Builder) -> capnp::Result<SquareOrCircle<'a>> {
let mut root: Shape::Builder = message.get_root()?;
match root.which()? {
Shape::Square(square) => SquareOrCircle::Square(square?),
Shape::Circle(circl) => SquareOrCircle::Circle(circle?),
}
}
Hi,
I have this schema:
I am trying to write a function that returns a mutable square or circle but don't want the caller to know about shape (not even sure it's possible in rust, because of ownership).
I tried:
What I am trying to achieve is, having a module that expose several functions that let me create a square or circle, but without knowing about the internal parts of capnp.