Skip to content
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

Interface newtypes #879

Merged
merged 27 commits into from
Oct 22, 2024
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9ceeae1
Implement newtypes for UserId, GroupId, ProcessId and DeviceId
van-sprundel Oct 13, 2024
4d09d20
Fix breaking changes in test env
van-sprundel Oct 13, 2024
479ee49
Return docs
van-sprundel Oct 13, 2024
41b0e08
Formatting
van-sprundel Oct 13, 2024
99adc61
Don't use newtypes for groups_buffer
van-sprundel Oct 13, 2024
037f45a
Format
van-sprundel Oct 13, 2024
74a329d
Don't dereference pointer when type is not equal
van-sprundel Oct 13, 2024
fcdf3f1
Merge branch 'main' into interface-newtypes
van-sprundel Oct 14, 2024
845991d
Fix merge
van-sprundel Oct 14, 2024
673acda
Replace impl `const fn new` with `OnceCell`
van-sprundel Oct 14, 2024
82765a0
Formatting
van-sprundel Oct 14, 2024
d1eee33
Use static TEST_USER_ID with OnceLock
van-sprundel Oct 14, 2024
29ebf01
Merge branch 'main' into interface-newtypes
van-sprundel Oct 15, 2024
7780bd6
Make pid() return `ProcessId`
van-sprundel Oct 15, 2024
ffa3f46
Remove redundant get() call
van-sprundel Oct 15, 2024
10a45ed
Add UserId::ROOT const
van-sprundel Oct 15, 2024
e2ca69e
keep id structs the same size as their field
van-sprundel Oct 15, 2024
1a3fd1b
Use ROOT const on more places
van-sprundel Oct 16, 2024
458efe7
Use transparent struct on GroupId, remove transparent on UserId, Proc…
van-sprundel Oct 16, 2024
9633bab
Merge branch 'main' into interface-newtypes
van-sprundel Oct 16, 2024
513f276
Merge branch 'main' into interface-newtypes
van-sprundel Oct 22, 2024
f62cc4e
Add `is_valid` for ProcessId
van-sprundel Oct 22, 2024
8eff83f
Use `UserId::ROOT`
van-sprundel Oct 22, 2024
fd07c7e
Remove more get calls
van-sprundel Oct 22, 2024
86afd0a
Rename get to inner
van-sprundel Oct 22, 2024
55902f4
Merge branch 'main' into interface-newtypes
van-sprundel Oct 22, 2024
552c440
Fix branch rebase
van-sprundel Oct 22, 2024
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
4 changes: 4 additions & 0 deletions src/system/interface.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
use std::{ffi::CStr, fmt::Display, num::ParseIntError, str::FromStr};

#[repr(transparent)]
van-sprundel marked this conversation as resolved.
Show resolved Hide resolved
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct GroupId(libc::gid_t);

#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct UserId(libc::uid_t);

#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ProcessId(libc::pid_t);

#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct DeviceId(libc::dev_t);

Expand Down
Loading