From 37658875968ebe4aa5bfa49f1e45d8fdb3365f46 Mon Sep 17 00:00:00 2001 From: Ohad Ravid Date: Thu, 25 Jan 2024 16:58:10 +0200 Subject: [PATCH] Remove docs abour low level api to limits --- src/job.rs | 4 +--- src/lib.rs | 31 ++----------------------------- src/limits.rs | 1 + 3 files changed, 4 insertions(+), 32 deletions(-) diff --git a/src/job.rs b/src/job.rs index 2c74a72..a07327f 100644 --- a/src/job.rs +++ b/src/job.rs @@ -32,9 +32,7 @@ impl Job { } /// Create an anonymous job object and sets it's limit according to `info`. - /// Note: This method shouldn't change the provided `info`, but the internal Windows API - /// require a mutable pointer, which means this function requires &mut as well. - pub fn create_with_limit_info(info: &mut ExtendedLimitInfo) -> Result { + pub fn create_with_limit_info(info: &ExtendedLimitInfo) -> Result { let job = Self::create()?; job.set_extended_limit_info(info)?; diff --git a/src/lib.rs b/src/lib.rs index 8525522..280050a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ //! or by creating an empty one using `new()`, use helper methods to configure //! the required limits, and finally set the info to the job. //! -//! ```edition2018 +//! ```edition2021 //! use win32job::*; //! # fn main() -> Result<(), JobError> { //! @@ -28,7 +28,7 @@ //! ``` //! //! Which is equivalnent to: -//! ```edition2018 +//! ```edition2021 //! use win32job::*; //! # fn main() -> Result<(), JobError> { //! @@ -45,33 +45,6 @@ //! # Ok(()) //! # } //! ``` -//! -//! # Using the low level API -//! -//! The most basic API is getting an `ExtendedLimitInfo` object and -//! manipulating the raw `JOBOBJECT_BASIC_LIMIT_INFORMATION`, and then set it back to the job. -//! -//! It's important to remeber to set the needed `LimitFlags` for each limit used. -//! -//! ```edition2018 -//! use win32job::*; -//! # fn main() -> Result<(), JobError> { -//! use windows::Win32::System::JobObjects::JOB_OBJECT_LIMIT_WORKINGSET; -//! -//! let job = Job::create()?; -//! let mut info = job.query_extended_limit_info()?; -//! -//! info.0.BasicLimitInformation.MinimumWorkingSetSize = 1 * 1024 * 1024; -//! info.0.BasicLimitInformation.MaximumWorkingSetSize = 4 * 1024 * 1024; -//! info.0.BasicLimitInformation.LimitFlags |= JOB_OBJECT_LIMIT_WORKINGSET; -//! -//! job.set_extended_limit_info(&mut info)?; -//! job.assign_current_process()?; -//! # info.clear_limits(); -//! # job.set_extended_limit_info(&mut info)?; -//! # Ok(()) -//! # } -//! ``` mod error; mod job; mod limits; diff --git a/src/limits.rs b/src/limits.rs index b0d93aa..d36f70f 100644 --- a/src/limits.rs +++ b/src/limits.rs @@ -13,6 +13,7 @@ use windows::Win32::System::{ #[derive(Debug)] pub struct ExtendedLimitInfo(pub(crate) JOBOBJECT_EXTENDED_LIMIT_INFORMATION); +#[derive(Debug, Clone, Copy)] #[repr(u32)] pub enum PriorityClass { Normal = NORMAL_PRIORITY_CLASS.0,