You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
struct Square {
width @0 :Int64;
height @1 :Text;
}
struct Circle {
radius @0 :Int64;
}
struct Shape {
union {
square @0 :Square;
circle @1 :Circle;
}
}
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:
pubfnget_square() -> ?? {letmut message = capnp::message::Builder::new_default();letmut message2 = capnp::message::Builder::new_default();letmut shape = message2.init_root::<Shape::Builder>();{let square = message.init_root::<Square::Builder>();
shape.set_square(square.borrow_as_reader());}// How to return square ?? Is it possible ?}
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: