1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! # wun32job-rs
//!
//! A safe API for Windows' job objects, which can be used to set various limits to
//! processes associated with them.
//! See also [Microsoft Docs](https://docs.microsoft.com/en-us/windows/win32/api/jobapi2/nf-jobapi2-createjobobjectw).
//!
//! # Using the higher level API
//!
//! After getting an `ExtendedLimitInfo` object, either by querying the info of a job
//! or by creating an empty one using `new()`, use helper methods to configure
//! the required limits, and finally set the info to the job.
//!
//! ```edition2021
//! use win32job::*;
//! # fn main() -> Result<(), JobError> {
//!
//! let mut info = ExtendedLimitInfo::new();
//!
//! info.limit_working_memory(1 * 1024 * 1024,  4 * 1024 * 1024)
//!     .limit_priority_class(PriorityClass::BelowNormal);
//!
//! let job = Job::create_with_limit_info(&mut info)?;
//! job.assign_current_process()?;
//! #   info.clear_limits();
//! #   job.set_extended_limit_info(&mut info)?;
//! #   Ok(())
//! # }
//! ```
//!
//! Which is equivalnent to:
//! ```edition2021
//! use win32job::*;
//! # fn main() -> Result<(), JobError> {
//!
//! let job = Job::create()?;
//! let mut info = job.query_extended_limit_info()?;
//!
//! info.limit_working_memory(1 * 1024 * 1024,  4 * 1024 * 1024)
//!     .limit_priority_class(PriorityClass::BelowNormal);
//!
//! 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;
mod query;
pub mod utils;

pub use crate::error::JobError;
pub use crate::job::Job;
pub use crate::limits::{ExtendedLimitInfo, PriorityClass};

// Cannot use `cfg(test)` here since `rustdoc` won't look at it.
#[cfg(debug_assertions)]
mod test_readme {
    #[doc = include_str!("../README.md")]
    enum _DoctestReadme {}
}