Skip to content

Commit 665300e

Browse files
adetaylordjmitche
andauthored
Update Chromium Rust policy (#2530)
Co-authored-by: Dustin J. Mitchell <[email protected]>
1 parent 7f0c591 commit 665300e

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

src/chromium/policy.md

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
# Chromium Rust policy
22

3-
Chromium does not yet allow first-party Rust except in rare cases as approved by
4-
Chromium's
5-
[Area Tech Leads](https://source.chromium.org/chromium/chromium/src/+/main:ATL_OWNERS).
3+
Chromium's Rust policy can be found
4+
[here](https://source.chromium.org/chromium/chromium/src/+/main:docs/rust.md;l=22).
5+
Rust can be used for both first-party and third-party code.
66

7-
Chromium's policy on third party libraries is outlined
8-
[here](https://chromium.googlesource.com/chromium/src/+/main/docs/adding_to_third_party.md#rust) -
9-
Rust is allowed for third party libraries under various circumstances, including
10-
if they're the best option for performance or for security.
7+
Using Rust for pure first-party code looks like this:
118

12-
Very few Rust libraries directly expose a C/C++ API, so that means that nearly
13-
all such libraries will require a small amount of first-party glue code.
9+
```bob
10+
"C++" Rust
11+
.- - - - - - - - - -. .- - - - - - - - - - -.
12+
: : : :
13+
: Existing Chromium : : Chromium Rust :
14+
: "C++" : : code :
15+
: +---------------+ : : +----------------+ :
16+
: | | : : | | :
17+
: | o-----+-+-----------+-+-> | :
18+
: | | : Language : | | :
19+
: +---------------+ : boundary : +----------------+ :
20+
: : : :
21+
`- - - - - - - - - -' `- - - - - - - - - - -'
22+
```
23+
24+
The third-party case is also common. It's likely that you'll also need a small
25+
amount of first-party glue code, because very few Rust libraries directly expose
26+
a C/C++ API.
1427

1528
```bob
1629
"C++" Rust
@@ -27,12 +40,9 @@ all such libraries will require a small amount of first-party glue code.
2740
`- - - - - - - - - -' `- - - - - - - - - - - - - - - - - - - - - - -'
2841
```
2942

30-
> First-party Rust glue code for a particular third-party crate should normally
31-
> be kept in `third_party/rust/<crate>/<version>/wrapper`.
32-
33-
Because of this, today's course will be heavily focused on:
43+
The scenario of using a third-party crate is the more complex one, so today's
44+
course will focus on:
3445

3546
- Bringing in third-party Rust libraries ("crates")
36-
- Writing glue code to be able to use those crates from Chromium C++.
37-
38-
If this policy changes over time, the course will evolve to keep up.
47+
- Writing glue code to be able to use those crates from Chromium C++. (The same
48+
techniques are used when working with first-party Rust code).

0 commit comments

Comments
 (0)