-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import Intent from android-intent crate #63
Conversation
Ah, we might have been a little unclear in that discussion - I think @MarijnS95 and I were initially thinking about seeing if you'd like to move your repo to the Tighter integration with E.g. another architecture for utilizing Rust code on Android is to have a If this crate were merged into |
Integration like this does also open this can of worms with exposing the E.g. this currently uses If the |
Oh ok I misunderstood - the repo is now live at https://github.com/rust-mobile/android-intent-rs But huh that dylib stuff is interesting I hadn't heard of that before - I'll look into tighter integration with maybe an optional |
Also that's an interesting side effect of re-exporting jni |
There's maybe some other better illustration of this, but here's one blog post that shows someone following that kind of architecture: https://blog.devgenius.io/integrating-rust-with-android-development-ef341c2f9cca The key bits being that they have something like this in their Cargo.toml: [lib]
name = "rust_lib"
crate-type = ["cdylib"] And then they load that library explicitly within their class MainActivity : ComponentActivity() {
companion object {
init {
System.loadLibrary("rust_lib")
RustLog.initialiseLogging()
}
}
// ...
} So they treat the Java/Kotlin That particular blog post uses some bindgen stuff I'm not familiar with, instead of directly working with the |
It's not so much the effect of re-exporting So if As it is currently, individual crates can be more orthogonal with what version of the This means it's more practical to let crates migrate to new versions of the If we remove those raw pointers in favor of stronger |
}) | ||
} | ||
|
||
/// Builds a new [`Action::Chooser`](Action) Intent that wraps the given target intent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Builds a new [`Action::Chooser`](Action) Intent that wraps the given target intent. | |
/// Builds a new [`Action::Chooser`] Intent that wraps the given target intent. |
Let's link directly to the desired enum variant instead of to the type?
Yes the main point was to keep utility crates under one roof, and merge them if the brunt of it is duplicate/shared (or have a "base" utility crate that provides this, which is subsequently inherited by other utility crates); without being coupled to I'm partly in favour of using
But yes, I've been working on Rust long enough to know that breaking version releases of crates are a pain to propagate through the ecosystem. Ranging from simply bumping internal utilities to stop That said, perhaps JNI should push through with as many breaking improvements now and then postpone breaking changes for some time; I've done the same with |
In other words, should this PR be closed as we intend for this |
Yeah, we kind of did this with the 0.21 release. We already had a few notable changes that required breaking API changes and took the opportunity to make some other breaking changes at the same time. So we effectively bunched the breaking changes together since we knew it was going to take some work to migrate to 0.21 anyway. I can't be entirely sure yet if we'll manage to minimize breaking changes for 0.22 but it would be my preference that 0.22 is a bit more conservative. I can think of at least one breaking change (that we ideally need to rework That said though, I have found that working on the jni crate has sometimes felt a bit like pulling on a lose thread, the more you look at it the more issues you realize there are. With 0.21 we sometimes consciously decided to be incremental with changes because otherwise we'd get stuck boiling the ocean. (For example the Yeah we can use the semver trick where that helps but at least for 0.21 that kind of issue wasn't really the source of breakages. The majority of API breakage comes from making reference types (like |
yep, I think it makes sense to close this issue for now. @matthunz was added as a member of the rust-mobile org yesterday and was able to migrate the It's possible that we can consider tighter integration with the |
Not too concerned with breaking changes as long as they're behind a breaking semver bump... Which are typically the problem themselves, especially when only breaking minimal API surface while still requiring everyone to bump the version of their JNI dependency and itself provide a breaking release if they publicly expose (That was the main complaint with
That's true for any software project, IMO, for better or for worse. Let's just keep going for now, use JNI in crate's public API, and see where we end up? The semver trick is indeed only relevant once you start adjusting function signatures but leave the underlying types mostly the same.
As mentioned in rust-mobile/android-intent#1 (comment) the |
Yeah I'm a bit concerned the The For standalone apps based on Whenever a semver incompatible Maybe the semver trick will be able to avoid the worst case scenario in some instances though. |
Sounds like we should just try it out and see how it fares? |
This adds support for android intents from my
android-intent
crate. I saw there was some interest to merge the two in rust-mobile/cargo-apk#18I think
Intent
s need better integration with this crate's API but I'm not sure how to get there. My current ideas areor
I prefer the first example because it specifies how the
JNIEnv
comes from anAndroidApp
right away. The env has to be included in theIntent
struct so each JNI method can be called without storing all of the arguments in rust first (e.g. using aVec
of methods to call and then doing so one by one after we have an env. This uses the builder pattern where errors are handle on the build methodstart_activity
(similar to how thehttp
crate keeps an error and handles it onbuild
).