1
1
# Chromium Rust policy
2
2
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 .
6
6
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:
11
8
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.
14
27
15
28
``` bob
16
29
"C++" Rust
@@ -27,12 +40,9 @@ all such libraries will require a small amount of first-party glue code.
27
40
`- - - - - - - - - -' `- - - - - - - - - - - - - - - - - - - - - - -'
28
41
```
29
42
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:
34
45
35
46
- 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