foreign_callback!

You can also use a trait to describe a callback from Rust to Java/C++:

trait EnumObserver {
    fn on_state_changed(&self, item: MyEnum, is_ok: bool);
}

foreign_callback!(callback EnumObserver {
    self_type EnumObserver;
    onStateUpdate = EnumObserver::on_state_changed(&self, item: MyEnum, is_ok: bool);
});

foreign_class!(class TestEnumClass {
    self_type Moo;
    constructor Moo::default() -> Moo;
    fn Moo::f1(&mut self, v: MyEnum) -> i32;
    fn Moo::next_enum(v: MyEnum) -> MyEnum;
    fn call_cb(cb: Box<dyn EnumObserver>) {
        let mut state = false;
        for e in &[MyEnum::Item1, MyEnum::Item2, MyEnum::Item3] {
            cb.on_state_changed(*e, state);
            state = !state;
        }
    }
});

As a result of flapigen processing foreign_callback! it generates an interface for Java and an abstract class for C++, so you can implement methods in Java/C++ and pass a pointer/reference to Rust, and for Rust it would be represented as a trait implementation.