Replies: 3 comments 1 reply
-
API Code example: use std::cell::RefCell;
use std::sync::{Arc};
use tokio::{sync::Mutex};
pub struct Database {
db: Arc<Mutex<libsql::Database>>,
conn: RefCell<Option<Arc<Mutex<libsql::Connection>>>>,
stmts: Arc<Mutex<Vec<Arc<Mutex<libsql::Statement>>>>>,
default_safe_integers: RefCell<bool>,
} |
Beta Was this translation helpful? Give feedback.
-
Totally agree - It would make the usage much easier if there is no need to manually handle any mirroring. Looking forward to your PR! IIRC, the main difficulty may be that, we have to correctly figure out the source code of that external type. There seems to have been some discussions but a quick search does not reveal that. However, this is surely implementable (and hopefully even with an existing crate now). Another problem is that, how to allow users to customize the behavior. But this is - as you can see - a quite minor problem, since there can be a ton of ways to specify config. The simplest one may be adding |
Beta Was this translation helpful? Give feedback.
-
I haven't used this project in over a year, so my involvement is a bit rusty (no pun intended). One way I can think about getting the sources:
Another, perhaps more straightforward, way of doing could be to download the crate in a temp directory. Then, a graph or whatever dark magic needs to be built from the crate's sources to find the correct struct (say in the source code you have an internal Some libraries may re-export from internal crates too which complicates it even more. Regardless of how the above is done, I think manual struct mirroring should remain an option as it can be used to control what is exposed of a type. |
Beta Was this translation helpful? Give feedback.
-
As has been mentioned previously #1161, #1179, #1305, etc., manually mirroring external crate types can become quite tedious with nested types. Are there any alternatives to this? It was mentioned to CC @Unoqwy who implemented the awesome mirroring feature :)
For context, I am looking to create a Dart API for a large external crate (libsql).
Regarding handling types from other crates automatically and moving to remove the need for mirroring, what do you see as some of the largest roadblocks? I would love to work on a PR for any of those issues.
Beta Was this translation helpful? Give feedback.
All reactions