Skip to content

Improve Time struct #395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2022

Conversation

nicholasbishop
Copy link
Member

  • Add a TimeParams struct with public fields corresponding to all the
    non-padding fields of Time, and change Time::new to take that as
    input. That improves callsites of Time::new so that you can see what
    the numeric values correspond to. See known_disk.rs for an example.

  • Add Time::invalid for use with File::set_info. When setting file
    info, a fully-zero-time indicates the attribute should not be
    updated. I think ideally we'd have Time always represent a valid
    value, and use Option<Time>::None to represent an invalid time
    similar to what we do with Handles, but I don't think Rust currently
    allows us to indicate that all-zero-Time can be used for the
    Option::None niche.

  • Add Time::is_invalid to check that all fields are in the valid range.

  • Update Time's docstring to be more general. Although EFI_TIME in the
    spec says it's for the current time, it's used elsewhere too (like
    EFI_FILE_INFO).

  • Fix the docstring for Daylight, which was accidentally copied from
    MemoryAttribute.

* Add a `TimeParams` struct with public fields corresponding to all the
  non-padding fields of `Time`, and change `Time::new` to take that as
  input. That improves callsites of `Time::new` so that you can see what
  the numeric values correspond to. See `known_disk.rs` for an example.

* Add `Time::invalid` for use with `File::set_info`. When setting file
  info, a fully-zero-time indicates the attribute should not be
  updated. I think ideally we'd have `Time` always represent a valid
  value, and use `Option<Time>::None` to represent an invalid time
  similar to what we do with `Handle`s, but I don't think Rust currently
  allows us to indicate that all-zero-Time can be used for the
  Option::None niche.

* Add `Time::is_invalid` to check that all fields are in the valid range.

* Update Time's docstring to be more general. Although `EFI_TIME` in the
  spec says it's for the current time, it's used elsewhere too (like
  `EFI_FILE_INFO`).

* Fix the docstring for `Daylight`, which was accidentally copied from
  `MemoryAttribute`.
@GabrielMajeri
Copy link
Collaborator

LGTM!

@GabrielMajeri GabrielMajeri merged commit c0bd89a into rust-osdev:main Mar 24, 2022
@nicholasbishop nicholasbishop deleted the bishop-time-cleanup branch March 27, 2022 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants