Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b0a2ed2

Browse files
committed
rename crate features
1 parent 1068d2e commit b0a2ed2

File tree

24 files changed

+106
-70
lines changed

24 files changed

+106
-70
lines changed

‎CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
### Changed
2121

22+
- renamed crate feature `alloc` to `global_allocator`
23+
- renamed crate feature `exts` to `alloc`
2224
- Fixed the definition of `AllocateType` so that `MaxAddress` and
2325
`Address` always take a 64-bit value, regardless of target platform.
2426
- The conversion methods on `DevicePathToText` and `DevicePathFromText`
@@ -34,7 +36,7 @@
3436
replaced with a derived `Debug` impl.
3537
- `CStr16::from_u16_with_nul_unchecked` and `cstr16!` are now allowed in
3638
`const` contexts.
37-
39+
3840
### Removed
3941

4042
- Removed `UnalignedCStr16`; use `UnalignedSlice` instead. An

‎Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ license = "MPL-2.0"
2121
[features]
2222
default = ["panic-on-logger-errors"]
2323
alloc = []
24-
exts = []
24+
global_allocator = []
2525
logger = []
2626
# Ignore text output errors in logger as a workaround for firmware issues that
2727
# were observed on the VirtualBox UEFI implementation (see uefi-rs#121).

‎README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,20 @@ Check out [the UEFI application template](template) for a quick start.
3131
This project contains multiple sub-crates:
3232

3333
- `uefi` (top directory): defines the standard UEFI tables / interfaces.
34-
The objective is to stay unopionated and safely wrap most interfaces.
35-
36-
Optional features:
37-
- `alloc`: implements a global allocator using UEFI functions.
38-
- This allows you to allocate objects on the heap.
34+
The objective is to stay opinionated and safely wrap most interfaces.
35+
36+
**Optional Crate Features:**
37+
- `alloc`: Enables functionality requiring the `alloc` crate from the Rust standard library.
38+
- For example, this allows many convenient `uefi-rs` functions to operate on heap data (`Box`).
39+
- It is up to the user to provide a `#[global allocator]`.
40+
- `global_allocator`: implements a `#[global allocator]` using UEFI functions.
41+
- This allows you to use all abstractions from the `alloc` crate from the Rust standard library
42+
during runtime. Hence, `Vec`, `Box`, etc. will be able to allocate memory.
43+
**This is optional**, so you can provide a custom `#[global allocator]` as well.
3944
- There's no guarantee of the efficiency of UEFI's allocator.
40-
- `logger`: logging implementation for the standard [log] crate.
41-
- Prints output to console.
45+
- `logger`: logging implementation for the standard [`log`] crate.
46+
- Prints output to UEFI console.
4247
- No buffering is done: this is not a high-performance logger.
43-
- `exts`: extensions providing utility functions for common patterns.
44-
- Requires the `alloc` crate (either enable the `alloc` optional feature or your own custom allocator).
4548

4649
- `uefi-macros`: procedural macros that are used to derive some traits in `uefi`.
4750

‎book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [Running in a VM](tutorial/vm.md)
88
- [How-to](how_to/introduction.md)
99
- [Using Protocols](how_to/protocols.md)
10+
- [Crate Features](how_to/crate_features.md)
1011
- [Concepts](concepts/introduction.md)
1112
- [Boot Stages](concepts/boot_stages.md)
1213
- [Tables](concepts/tables.md)

‎book/src/how_to/crate_features.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Optional Crate Features
2+
3+
There are several optional crate features provided by the `uefi` crate.
4+
5+
## Optional Crate Features:
6+
- `alloc`: Enables functionality requiring the `alloc` crate from the Rust standard library.
7+
- For example, this allows many convenient `uefi-rs` functions to operate on heap data (`Box`).
8+
- It is up to the user to provide a `#[global allocator]`.
9+
- `global_allocator`: implements a `#[global allocator]` using UEFI functions.
10+
- This allows you to use all abstractions from the `alloc` crate from the Rust standard library
11+
during runtime. Hence, `Vec`, `Box`, etc. will be able to allocate memory.
12+
**This is optional**, so you can provide a custom `#[global allocator]` as well.
13+
- There's no guarantee of the efficiency of UEFI's allocator.
14+
- `logger`: logging implementation for the standard [`log`] crate.
15+
- Prints output to UEFI console.
16+
- No buffering is done: this is not a high-performance logger.

‎book/src/tutorial/building.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Create `.cargo/config.toml` with these contents:
4949
target = "x86_64-unknown-uefi"
5050

5151
[unstable]
52-
build-std = ["core", "compiler_builtins", "alloc"]
52+
build-std = ["core", "compiler_builtins", "global_allocator"]
5353
build-std-features = ["compiler-builtins-mem"]
5454
```
5555

‎src/data_types/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ pub use self::strs::{
132132
CStr16, CStr8, EqStrUntilNul, FromSliceWithNulError, FromStrWithBufError, UnalignedCStr16Error,
133133
};
134134

135-
#[cfg(feature = "exts")]
135+
#[cfg(feature = "alloc")]
136136
mod owned_strs;
137-
#[cfg(feature = "exts")]
137+
#[cfg(feature = "alloc")]
138138
pub use self::owned_strs::{CString16, FromStrError};
139139

140140
mod unaligned_slice;

‎src/data_types/owned_strs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::chars::{Char16, NUL_16};
22
use super::strs::{CStr16, FromSliceWithNulError};
3-
use crate::alloc_api::vec::Vec;
3+
use crate::alloc::vec::Vec;
44
use crate::data_types::strs::EqStrUntilNul;
55
use crate::data_types::UnalignedSlice;
66
use core::fmt;
@@ -138,8 +138,8 @@ impl<StrType: AsRef<str>> EqStrUntilNul<StrType> for CString16 {
138138
#[cfg(test)]
139139
mod tests {
140140
use super::*;
141-
use crate::alloc_api::string::String;
142-
use crate::alloc_api::vec;
141+
use crate::alloc::string::String;
142+
use crate::alloc::vec;
143143

144144
#[test]
145145
fn test_cstring16_from_str() {

‎src/data_types/strs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use core::mem::MaybeUninit;
66
use core::result::Result;
77
use core::slice;
88

9-
#[cfg(feature = "exts")]
9+
#[cfg(feature = "alloc")]
1010
use super::CString16;
1111

1212
/// Errors which can occur during checked `[uN]` -> `CStrN` conversions
@@ -397,7 +397,7 @@ impl fmt::Display for CStr16 {
397397
}
398398
}
399399

400-
#[cfg(feature = "exts")]
400+
#[cfg(feature = "alloc")]
401401
impl PartialEq<CString16> for &CStr16 {
402402
fn eq(&self, other: &CString16) -> bool {
403403
PartialEq::eq(*self, other.as_ref())
@@ -447,7 +447,7 @@ where
447447
#[cfg(test)]
448448
mod tests {
449449
use super::*;
450-
use crate::alloc_api::string::String;
450+
use crate::alloc::string::String;
451451
use uefi_macros::{cstr16, cstr8};
452452

453453
#[test]

‎src/data_types/unaligned_slice.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use core::marker::PhantomData;
22
use core::mem::MaybeUninit;
33

4-
#[cfg(feature = "exts")]
5-
use crate::alloc_api::vec::Vec;
4+
#[cfg(feature = "alloc")]
5+
use crate::alloc::vec::Vec;
66

77
/// Slice backed by a potentially-unaligned pointer.
88
///
@@ -110,7 +110,7 @@ impl<'a, T: Copy> UnalignedSlice<'a, T> {
110110
}
111111

112112
/// Copies `self` into a new `Vec`.
113-
#[cfg(feature = "exts")]
113+
#[cfg(feature = "alloc")]
114114
pub fn to_vec(&self) -> Vec<T> {
115115
let len = self.len();
116116
let mut v = Vec::with_capacity(len);
@@ -122,7 +122,7 @@ impl<'a, T: Copy> UnalignedSlice<'a, T> {
122122
}
123123
}
124124

125-
#[cfg(feature = "exts")]
125+
#[cfg(feature = "alloc")]
126126
impl<'a, T: Copy> From<UnalignedSlice<'a, T>> for Vec<T> {
127127
fn from(input: UnalignedSlice<'a, T>) -> Self {
128128
input.to_vec()
@@ -185,7 +185,7 @@ impl<'a, T: Copy> Iterator for UnalignedSliceIter<'a, T> {
185185
#[cfg(test)]
186186
mod tests {
187187
use super::*;
188-
use alloc_api::vec::Vec;
188+
use alloc::vec::Vec;
189189

190190
#[test]
191191
fn test_unaligned_slice() {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /