diff --git a/src/chromium/policy.md b/src/chromium/policy.md index a08c5a9d..b3dfd24f 100644 --- a/src/chromium/policy.md +++ b/src/chromium/policy.md @@ -1,16 +1,29 @@ # Chromium Rust policy -Chromium does not yet allow first-party Rust except in rare cases as approved by -Chromium's -[Area Tech Leads](https://source.chromium.org/chromium/chromium/src/+/main:ATL_OWNERS). +Chromium's Rust policy can be found +[here](https://source.chromium.org/chromium/chromium/src/+/main:docs/rust.md;l=22). +Rust can be used for both first-party and third-party code. -Chromium's policy on third party libraries is outlined -[here](https://chromium.googlesource.com/chromium/src/+/main/docs/adding_to_third_party.md#rust) - -Rust is allowed for third party libraries under various circumstances, including -if they're the best option for performance or for security. +Using Rust for pure first-party code looks like this: -Very few Rust libraries directly expose a C/C++ API, so that means that nearly -all such libraries will require a small amount of first-party glue code. +```bob +"C++" Rust +.- - - - - - - - - -. .- - - - - - - - - - -. +: : : : +: Existing Chromium : : Chromium Rust : +: "C++" : : code : +: +---------------+ : : +----------------+ : +: | | : : | | : +: | o-----+-+-----------+-+-> | : +: | | : Language : | | : +: +---------------+ : boundary : +----------------+ : +: : : : +`- - - - - - - - - -' `- - - - - - - - - - -' +``` + +The third-party case is also common. It's likely that you'll also need a small +amount of first-party glue code, because very few Rust libraries directly expose +a C/C++ API. ```bob "C++" Rust @@ -27,12 +40,9 @@ all such libraries will require a small amount of first-party glue code. `- - - - - - - - - -' `- - - - - - - - - - - - - - - - - - - - - - -' ``` -> First-party Rust glue code for a particular third-party crate should normally -> be kept in `third_party/rust///wrapper`. - -Because of this, today's course will be heavily focused on: +The scenario of using a third-party crate is the more complex one, so today's +course will focus on: - Bringing in third-party Rust libraries ("crates") -- Writing glue code to be able to use those crates from Chromium C++. - -If this policy changes over time, the course will evolve to keep up. +- Writing glue code to be able to use those crates from Chromium C++. (The same + techniques are used when working with first-party Rust code).