Open MrKekovichPersonal opened 8 months ago
@MrKekovichPersonal
Is there any way to solve this problem without copying?
You can copy, but use something like std::sync::Arc
for this to make it cheap.
The problem is that in callback you call Java code from Rust. So there is need to pass reference to Rust object to Java with restricted lifetime.
But Java has no such thing as reference with restrited lifetime.
So I can no see how to create "safe" way to do it.
For example If flapigen
generates Java class like NeuralNetworkReference
,
how can anybody prevent situation, when Java side user save object of type NeuralNetworkReference
, somewhere and try to reuse it later?
That's why default binding require to pass ownership to Java side.
When I am trying to create callback with pointers, flapigen cannot convert &Type to java: rust code:
generated interface:
error:
However, when I am using references wtih class method - it works:
Copying network is a compute-intense process. Is there any way to solve this problem without copying?