Skip to content

Commit ab2343e

Browse files
committed
v2
1 parent a684183 commit ab2343e

File tree

19 files changed

+92
-92
lines changed

19 files changed

+92
-92
lines changed

src/data_types/strs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,12 @@ impl CStr16 {
288288
}
289289

290290
/// Returns the inner pointer to this C string
291-
pub fn as_ptr(&self) -> *const Char16 {
291+
pub const fn as_ptr(&self) -> *const Char16 {
292292
self.0.as_ptr()
293293
}
294294

295295
/// Get the underlying [`Char16`] slice, including the trailing null.
296-
pub fn as_slice_with_nul(&self) -> &[Char16] {
296+
pub const fn as_slice_with_nul(&self) -> &[Char16] {
297297
&self.0
298298
}
299299

@@ -317,7 +317,7 @@ impl CStr16 {
317317
}
318318

319319
/// Get the number of bytes in the string (including the trailing null character).
320-
pub fn num_bytes(&self) -> usize {
320+
pub const fn num_bytes(&self) -> usize {
321321
self.0.len() * 2
322322
}
323323

src/data_types/unaligned_slice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ impl<'a, T: Copy> UnalignedSlice<'a, T> {
3636
}
3737

3838
/// Returns true if the slice has a length of 0.
39-
pub fn is_empty(&self) -> bool {
39+
pub const fn is_empty(&self) -> bool {
4040
self.len == 0
4141
}
4242

4343
/// Returns the number of elements in the slice.
44-
pub fn len(&self) -> usize {
44+
pub const fn len(&self) -> usize {
4545
self.len
4646
}
4747

src/proto/console/gop.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ impl<'boot> GraphicsOutput<'boot> {
294294
}
295295

296296
/// Returns the frame buffer information for the current mode.
297-
pub fn current_mode_info(&self) -> ModeInfo {
297+
pub const fn current_mode_info(&self) -> ModeInfo {
298298
*self.mode.info
299299
}
300300

@@ -377,12 +377,12 @@ impl Mode {
377377
/// The size of the info structure in bytes.
378378
///
379379
/// Newer versions of the spec might add extra information, in a backwards compatible way.
380-
pub fn info_size(&self) -> usize {
380+
pub const fn info_size(&self) -> usize {
381381
self.info_sz
382382
}
383383

384384
/// Returns a reference to the mode info structure.
385-
pub fn info(&self) -> &ModeInfo {
385+
pub const fn info(&self) -> &ModeInfo {
386386
&self.info
387387
}
388388
}
@@ -404,17 +404,17 @@ impl ModeInfo {
404404
/// Returns the (horizontal, vertical) resolution.
405405
///
406406
/// On desktop monitors, this usually means (width, height).
407-
pub fn resolution(&self) -> (usize, usize) {
407+
pub const fn resolution(&self) -> (usize, usize) {
408408
(self.hor_res as usize, self.ver_res as usize)
409409
}
410410

411411
/// Returns the format of the frame buffer.
412-
pub fn pixel_format(&self) -> PixelFormat {
412+
pub const fn pixel_format(&self) -> PixelFormat {
413413
self.format
414414
}
415415

416416
/// Returns the bitmask of the custom pixel format, if available.
417-
pub fn pixel_bitmask(&self) -> Option<PixelBitmask> {
417+
pub const fn pixel_bitmask(&self) -> Option<PixelBitmask> {
418418
match self.format {
419419
PixelFormat::Bitmask => Some(self.mask),
420420
_ => None,
@@ -425,7 +425,7 @@ impl ModeInfo {
425425
///
426426
/// Due to performance reasons, the stride might not be equal to the width,
427427
/// instead the stride might be bigger for better alignment.
428-
pub fn stride(&self) -> usize {
428+
pub const fn stride(&self) -> usize {
429429
self.stride as usize
430430
}
431431
}
@@ -582,7 +582,7 @@ impl<'gop> FrameBuffer<'gop> {
582582
}
583583

584584
/// Query the framebuffer size in bytes
585-
pub fn size(&self) -> usize {
585+
pub const fn size(&self) -> usize {
586586
self.size
587587
}
588588

src/proto/console/pointer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ impl<'boot> Pointer<'boot> {
4747

4848
/// Event to be used with `BootServices::wait_for_event()` in order to wait
4949
/// for input from the pointer device
50-
pub fn wait_for_input_event(&self) -> &Event {
50+
pub const fn wait_for_input_event(&self) -> &Event {
5151
&self.wait_for_input
5252
}
5353

5454
/// Returns a reference to the pointer device information.
55-
pub fn mode(&self) -> &PointerMode {
55+
pub const fn mode(&self) -> &PointerMode {
5656
self.mode
5757
}
5858
}

src/proto/console/serial.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl<'boot> Serial<'boot> {
4444
}
4545

4646
/// Returns the current I/O mode.
47-
pub fn io_mode(&self) -> &IoMode {
47+
pub const fn io_mode(&self) -> &IoMode {
4848
self.io_mode
4949
}
5050

src/proto/console/text/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl Input {
4444

4545
/// Event to be used with `BootServices::wait_for_event()` in order to wait
4646
/// for a key to be available
47-
pub fn wait_for_key_event(&self) -> &Event {
47+
pub const fn wait_for_key_event(&self) -> &Event {
4848
&self.wait_for_key
4949
}
5050
}

src/proto/console/text/output.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl<'boot> Output<'boot> {
129129
}
130130

131131
/// Returns whether the cursor is currently shown or not.
132-
pub fn cursor_visible(&self) -> bool {
132+
pub const fn cursor_visible(&self) -> bool {
133133
self.data.cursor_visible
134134
}
135135

@@ -142,7 +142,7 @@ impl<'boot> Output<'boot> {
142142
}
143143

144144
/// Returns the column and row of the cursor.
145-
pub fn cursor_position(&self) -> (usize, usize) {
145+
pub const fn cursor_position(&self) -> (usize, usize) {
146146
let column = self.data.cursor_column;
147147
let row = self.data.cursor_row;
148148
(column as usize, row as usize)
@@ -260,19 +260,19 @@ pub struct OutputMode {
260260
impl OutputMode {
261261
/// Returns the index of this mode.
262262
#[inline]
263-
pub fn index(&self) -> usize {
263+
pub const fn index(&self) -> usize {
264264
self.index
265265
}
266266

267267
/// Returns the width in columns.
268268
#[inline]
269-
pub fn columns(&self) -> usize {
269+
pub const fn columns(&self) -> usize {
270270
self.dims.0
271271
}
272272

273273
/// Returns the height in rows.
274274
#[inline]
275-
pub fn rows(&self) -> usize {
275+
pub const fn rows(&self) -> usize {
276276
self.dims.1
277277
}
278278
}

src/proto/debug/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub struct DebugSupport {
5757

5858
impl DebugSupport {
5959
/// Returns the processor architecture of the running CPU.
60-
pub fn arch(&self) -> ProcessorArch {
60+
pub const fn arch(&self) -> ProcessorArch {
6161
self.isa
6262
}
6363

src/proto/device_path/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,22 @@ impl DevicePathNode {
136136
}
137137

138138
/// Type of device
139-
pub fn device_type(&self) -> DeviceType {
139+
pub const fn device_type(&self) -> DeviceType {
140140
self.header.device_type
141141
}
142142

143143
/// Sub type of device
144-
pub fn sub_type(&self) -> DeviceSubType {
144+
pub const fn sub_type(&self) -> DeviceSubType {
145145
self.header.sub_type
146146
}
147147

148148
/// Tuple of the node's type and subtype.
149-
pub fn full_type(&self) -> (DeviceType, DeviceSubType) {
149+
pub const fn full_type(&self) -> (DeviceType, DeviceSubType) {
150150
(self.header.device_type, self.header.sub_type)
151151
}
152152

153153
/// Size (in bytes) of the full [`DevicePathNode`], including the header.
154-
pub fn length(&self) -> u16 {
154+
pub const fn length(&self) -> u16 {
155155
self.header.length
156156
}
157157

@@ -281,7 +281,7 @@ impl DevicePath {
281281
}
282282

283283
/// Cast to a [`FfiDevicePath`] pointer.
284-
pub fn as_ffi_ptr(&self) -> *const FfiDevicePath {
284+
pub const fn as_ffi_ptr(&self) -> *const FfiDevicePath {
285285
let p = self as *const Self;
286286
p.cast()
287287
}
@@ -615,22 +615,22 @@ const HARD_DRIVE_MEDIA_DEVICE_PATH_LENGTH: u16 = 42;
615615

616616
impl HardDriveMediaDevicePath {
617617
/// Returns the format of the partition (MBR, GPT, or unknown).
618-
pub fn partition_format(&self) -> PartitionFormat {
618+
pub const fn partition_format(&self) -> PartitionFormat {
619619
self.partition_format
620620
}
621621

622622
/// Returns the 1-based index of the partition.
623-
pub fn partition_number(&self) -> u32 {
623+
pub const fn partition_number(&self) -> u32 {
624624
self.partition_number
625625
}
626626

627627
/// Returns the partition size in logical blocks.
628-
pub fn partition_size(&self) -> u64 {
628+
pub const fn partition_size(&self) -> u64 {
629629
self.partition_size
630630
}
631631

632632
/// Returns the starting LBA of the partition.
633-
pub fn partition_start(&self) -> u64 {
633+
pub const fn partition_start(&self) -> u64 {
634634
self.partition_start
635635
}
636636

@@ -729,7 +729,7 @@ mod tests {
729729
raw_data
730730
}
731731

732-
/// Check that `node` has the expected content.
732+
/// Check that `node` has the expected content.
733733
fn check_node(node: &DevicePathNode, device_type: u8, sub_type: u8, node_data: &[u8]) {
734734
assert_eq!(node.device_type().0, device_type);
735735
assert_eq!(node.sub_type().0, sub_type);

src/proto/loaded_image.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub enum LoadOptionsError {
5252

5353
impl LoadedImage {
5454
/// Returns a handle to the storage device on which the image is located.
55-
pub fn device(&self) -> Handle {
55+
pub const fn device(&self) -> Handle {
5656
self.device_handle
5757
}
5858

@@ -164,7 +164,7 @@ impl LoadedImage {
164164
}
165165

166166
/// Returns the base address and the size in bytes of the loaded image.
167-
pub fn info(&self) -> (*const c_void, u64) {
167+
pub const fn info(&self) -> (*const c_void, u64) {
168168
(self.image_base, self.image_size)
169169
}
170170
}

src/proto/media/block.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,64 +128,64 @@ pub struct BlockIOMedia {
128128

129129
impl BlockIOMedia {
130130
/// The current media ID.
131-
pub fn media_id(&self) -> u32 {
131+
pub const fn media_id(&self) -> u32 {
132132
self.media_id
133133
}
134134

135135
/// True if the media is removable.
136-
pub fn is_removable_media(&self) -> bool {
136+
pub const fn is_removable_media(&self) -> bool {
137137
self.removable_media
138138
}
139139

140140
/// True if there is a media currently present in the device.
141-
pub fn is_media_present(&self) -> bool {
141+
pub const fn is_media_present(&self) -> bool {
142142
self.media_present
143143
}
144144

145145
/// True if block IO was produced to abstract partition structure.
146-
pub fn is_logical_partition(&self) -> bool {
146+
pub const fn is_logical_partition(&self) -> bool {
147147
self.logical_partition
148148
}
149149

150150
/// True if the media is marked read-only.
151-
pub fn is_read_only(&self) -> bool {
151+
pub const fn is_read_only(&self) -> bool {
152152
self.read_only
153153
}
154154

155155
/// True if `writeBlocks` function writes data.
156-
pub fn is_write_caching(&self) -> bool {
156+
pub const fn is_write_caching(&self) -> bool {
157157
self.write_caching
158158
}
159159

160160
/// The intrinsic block size of the device.
161161
///
162162
/// If the media changes, then this field is updated. Returns the number of bytes per logical block.
163-
pub fn block_size(&self) -> u32 {
163+
pub const fn block_size(&self) -> u32 {
164164
self.block_size
165165
}
166166

167167
/// Supplies the alignment requirement for any buffer used in a data transfer.
168-
pub fn io_align(&self) -> u32 {
168+
pub const fn io_align(&self) -> u32 {
169169
self.io_align
170170
}
171171

172172
/// The last LBA on the device. If the media changes, then this field is updated.
173-
pub fn last_block(&self) -> Lba {
173+
pub const fn last_block(&self) -> Lba {
174174
self.last_block
175175
}
176176

177177
/// Returns the first LBA that is aligned to a physical block boundary.
178-
pub fn lowest_aligned_lba(&self) -> Lba {
178+
pub const fn lowest_aligned_lba(&self) -> Lba {
179179
self.lowest_aligned_lba
180180
}
181181

182182
/// Returns the number of logical blocks per physical block.
183-
pub fn logical_blocks_per_physical_block(&self) -> u32 {
183+
pub const fn logical_blocks_per_physical_block(&self) -> u32 {
184184
self.logical_blocks_per_physical_block
185185
}
186186

187187
/// Returns the optimal transfer length granularity as a number of logical blocks.
188-
pub fn optimal_transfer_length_granularity(&self) -> u32 {
188+
pub const fn optimal_transfer_length_granularity(&self) -> u32 {
189189
self.optimal_transfer_length_granularity
190190
}
191191
}

0 commit comments

Comments
 (0)