impl Uid { /// A `Uid` corresponding to the root user (uid 0). pubconst ROOT: Self = Self(0);
/// Converts a `RawUid` into a `Uid`. /// /// `raw` must be the value of a valid Unix user ID, and not `-1`. #[inline] pubfn from_raw(raw: RawUid) -> Self {
debug_assert_ne!(raw, !0); Self(raw)
}
/// Converts a `RawUid` into a `Uid`. /// /// `raw` must be the value of a valid Unix user ID, and not `-1`. #[inline] pubconstfn from_raw_unchecked(raw: RawUid) -> Self { Self(raw)
}
/// Converts a `Uid` into a `RawUid`. #[inline] pubconstfn as_raw(self) -> RawUid { self.0
}
/// Test whether this uid represents the root user ([`Uid::ROOT`]). #[inline] pubconstfn is_root(self) -> bool { self.0 == Self::ROOT.0
}
}
impl Gid { /// A `Gid` corresponding to the root group (gid 0). pubconst ROOT: Self = Self(0);
/// Converts a `RawGid` into a `Gid`. /// /// `raw` must be the value of a valid Unix group ID, and not `-1`. #[inline] pubfn from_raw(raw: RawGid) -> Self {
debug_assert_ne!(raw, !0); Self(raw)
}
/// Converts a `RawGid` into a `Gid`. /// /// `raw` must be the value of a valid Unix group ID, and not `-1`. #[inline] pubconstfn from_raw_unchecked(raw: RawGid) -> Self { Self(raw)
}
/// Converts a `Gid` into a `RawGid`. #[inline] pubconstfn as_raw(self) -> RawGid { self.0
}
/// Test whether this gid represents the root group ([`Gid::ROOT`]). #[inline] pubconstfn is_root(self) -> bool { self.0 == Self::ROOT.0
}
}
// Return the raw value of the IDs. In case of `None` it returns `!0` since it // has the same bit pattern as `-1` indicating no change to the owner/group ID. pub(crate) fn translate_fchown_args(
owner: Option<Uid>,
group: Option<Gid>,
) -> (c::uid_t, c::gid_t) { let ow = match owner {
Some(o) => o.as_raw(),
None => !0,
};
let gr = match group {
Some(g) => g.as_raw(),
None => !0,
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.