Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,17 @@ jobs:
if: matrix.features == ''
run: cargo build --all-features

- name: Test all features (other)
if: matrix.features == '' && runner.os != 'Linux'
run: cargo test --all-features -- --skip set_deadline_policy
- name: Test all features (macos)
if: matrix.features == '' && runner.os == 'macOS'
run: sudo -E /Users/runner/.cargo/bin/cargo test --all-features

- name: Test all features (Windows)
if: matrix.features == '' && runner.os == 'Windows'
run: cargo test --all-features

- name: Test all features (non-linux and non-macOS)
if: matrix.features == '' && runner.os != 'Linux' && runner.os != 'macOS' && runner.os != 'Windows'
run: sudo -E /home/runner/.cargo/bin/cargo test --all-features -- --skip set_deadline_policy

- name: Test all features (Linux)
if: matrix.features == '' && runner.os == 'Linux'
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "thread-priority"
version = "0.8.2"
version = "0.9.0"
authors = ["Victor Polevoy <[email protected]>"]
description = "Library for managing threads priority and schedule policies"
repository = "https://github.com/vityafx/thread-priority"
Expand All @@ -12,7 +12,7 @@ categories = ["concurrency", "asynchronous", "os"]
edition = "2018"

[dev-dependencies]
rstest = "0.12"
rstest = "0.13"

[dependencies]
log = "0.4"
Expand Down
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,18 @@ pub enum Error {
/// ```
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ThreadPriorityValue(u8);
impl ThreadPriorityValue {
/// The maximum value for a thread priority.
pub const MAX: u8 = 100;
/// The minimum value for a thread priority.
pub const MIN: u8 = 0;
}

impl std::convert::TryFrom<u8> for ThreadPriorityValue {
type Error = &'static str;

fn try_from(value: u8) -> Result<Self, Self::Error> {
if (0..=99).contains(&value) {
if (Self::MIN..Self::MAX).contains(&value) {
Ok(Self(value))
} else {
Err("The value is not in the range of [0;99]")
Expand Down
Loading
Loading