Reorg in preparation for UniFFI client #69
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Depends on #68
We discussed a need for a reorg and the goals of such a reorg.
The following is a summary:
Motivation
Research showed that we can introduce a Python API based on C libs that are compiled and facilitated by the UniFFI Rust package. Thinking ahead, UniFFI brings many great benefits in automation, exposing an interoperable client, and writing code that respects DRY principles with less boilerplate.
Restrictions to Consider
However, there are several design implications to be aware of. For instance, it was found during validation that anything exposed over the CFFI boundary with UniFFI needs to respect several rules (not exhaustive but relevant to us):
constvalues in traitsString,u8,bool,f32, etc.BtreeMapisn't supported butHashMapis.asyncfunctions must use the custom derive attribute from the async-trait crateArc<T>Limit Restrictions and Facilitate Maintenance
Given that there are a number of rules, the reorg's purpose is to confine them to be applicable only to a subset of the source. Confining them to a subset means it is easier to explain this (and write documentaton) for maintainers/contributors and grants us free reign of Rust's complete feature set in finding solutions outside of the
unifficontext.We decided to go with 2 top-level modules for the source:
coreanduniffi.As a side-effect of splitting things in this way, it means some features may need to be applied on both sides to be complete (or just entirely in
uniffi). For example inLocalFileStore, there is some pure Rust incoreand some that is exposed overuniffi. As a general practice, we could always just instruct contributors to targetcoreif they aren't comfortable working with UniFFI and treat the task of exposing it touniffiseparately; either by us or someone else.Visibility
Also, I've done my best in keeping the contents of
coreprivate sinceuniffiis the exposed client for Rust, Python, and anything in the future. However, there were some methods that we made public that we did not intend to expose overuniffie.g.to_yamlwhich is a generic and used in tests. To minimize the noise, I reorg'ed them as-is but we could always change that later e.g. gate-keep them behind afeatureflag that can be enabled during test runs. Since this update will be chaotic enough, this reorg PR is meant to only apply the reorg and not introduce any other change or functionality†.Footnote
† = The only exception to this was the last commit. The tests broke due to a new clippy lint added in a new version of Rust that had a bug in it. That commit bumped the Rust version and removed the manual getter method to avoid the bug since future PR's already had plans to remove it (see point
1. ii.in description of #71).