Skip to content

Commit 36558ad

Browse files
committed
docs: update docs
1 parent 67646c6 commit 36558ad

File tree

4 files changed

+45
-92
lines changed

4 files changed

+45
-92
lines changed

crates/libs/kill_tree/src/blocking.rs

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,6 @@ use crate::macos as imp;
77
#[cfg(windows)]
88
use crate::windows as imp;
99

10-
/// Returns the max available process ID.
11-
/// # Platform-specifics
12-
/// ## Windows
13-
/// In hexadecimal, 0xFFFFFFFF.
14-
/// In decimal, 4294967295.
15-
/// But actually process IDs are generated as multiples of 4.
16-
///
17-
/// ## Linux
18-
/// In hexadecimal, 0x400000.
19-
/// In decimal, 4194304.
20-
///
21-
/// ## Macos
22-
/// In decimal, 99998.
23-
///
24-
/// # Examples
25-
///
26-
/// ```
27-
/// use kill_tree::blocking::get_available_max_process_id;
28-
///
29-
/// #[cfg(windows)]
30-
/// assert!(get_available_max_process_id() == 0xFFFF_FFFF);
31-
///
32-
/// #[cfg(target_os = "linux")]
33-
/// assert!(get_available_max_process_id() == 0x0040_0000);
34-
///
35-
/// #[cfg(target_os = "macos")]
36-
/// assert!(get_available_max_process_id() == 99998);
37-
/// ```
38-
#[must_use]
39-
pub fn get_available_max_process_id() -> u32 {
40-
crate::common::get_available_max_process_id()
41-
}
42-
4310
/// Kills the target process and all of its children recursively.
4411
/// # Platform-specifics
4512
///
@@ -53,10 +20,7 @@ pub fn get_available_max_process_id() -> u32 {
5320
///
5421
/// # Examples
5522
/// ```
56-
/// use kill_tree::{
57-
/// blocking::{get_available_max_process_id, kill_tree},
58-
/// Result,
59-
/// };
23+
/// use kill_tree::{blocking::kill_tree, get_available_max_process_id, Result};
6024
///
6125
/// fn main() -> Result<()> {
6226
/// let _ = kill_tree(get_available_max_process_id())?;
@@ -102,8 +66,7 @@ pub fn kill_tree(process_id: ProcessId) -> Result<Outputs> {
10266
/// Kill processes using the `SIGKILL` signal.
10367
/// ```
10468
/// use kill_tree::{
105-
/// blocking::{get_available_max_process_id, kill_tree_with_config},
106-
/// Config, Result,
69+
/// blocking::kill_tree_with_config, get_available_max_process_id, Config, Result,
10770
/// };
10871
///
10972
/// fn main() -> Result<()> {
@@ -119,8 +82,7 @@ pub fn kill_tree(process_id: ProcessId) -> Result<Outputs> {
11982
/// Kills all children __except the target process__.
12083
/// ```
12184
/// use kill_tree::{
122-
/// blocking::{get_available_max_process_id, kill_tree_with_config},
123-
/// Config, Result,
85+
/// blocking::kill_tree_with_config, get_available_max_process_id, Config, Result,
12486
/// };
12587
///
12688
/// fn main() -> Result<()> {

crates/libs/kill_tree/src/common.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,36 @@ use crate::macos as imp;
1111
#[cfg(windows)]
1212
use crate::windows as imp;
1313

14-
pub(crate) fn get_available_max_process_id() -> u32 {
14+
/// Returns the max available process ID.
15+
/// # Platform-specifics
16+
/// ## Windows
17+
/// In hexadecimal, 0xFFFFFFFF.
18+
/// In decimal, 4294967295.
19+
/// But actually process IDs are generated as multiples of 4.
20+
///
21+
/// ## Linux
22+
/// In hexadecimal, 0x400000.
23+
/// In decimal, 4194304.
24+
///
25+
/// ## Macos
26+
/// In decimal, 99998.
27+
///
28+
/// # Examples
29+
///
30+
/// ```
31+
/// use kill_tree::get_available_max_process_id;
32+
///
33+
/// #[cfg(windows)]
34+
/// assert!(get_available_max_process_id() == 0xFFFF_FFFF);
35+
///
36+
/// #[cfg(target_os = "linux")]
37+
/// assert!(get_available_max_process_id() == 0x0040_0000);
38+
///
39+
/// #[cfg(target_os = "macos")]
40+
/// assert!(get_available_max_process_id() == 99998);
41+
/// ```
42+
#[must_use]
43+
pub fn get_available_max_process_id() -> u32 {
1544
imp::AVAILABLE_MAX_PROCESS_ID
1645
}
1746

crates/libs/kill_tree/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ pub mod blocking;
1515
#[cfg(feature = "tokio")]
1616
pub mod tokio;
1717

18+
pub use crate::common::get_available_max_process_id;
1819
pub use crate::core::{Config, Error, Output, Outputs, ParentProcessId, ProcessId, Result};

crates/libs/kill_tree/src/tokio.rs

Lines changed: 11 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,6 @@ use crate::macos as imp;
77
#[cfg(windows)]
88
use crate::windows as imp;
99

10-
/// Returns the max available process ID.
11-
/// # Platform-specifics
12-
/// ## Windows
13-
/// In hexadecimal, 0xFFFFFFFF.
14-
/// In decimal, 4294967295.
15-
/// But actually process IDs are generated as multiples of 4.
16-
///
17-
/// ## Linux
18-
/// In hexadecimal, 0x400000.
19-
/// In decimal, 4194304.
20-
///
21-
/// ## Macos
22-
/// In decimal, 99998.
23-
///
24-
/// # Examples
25-
///
26-
/// ```
27-
/// use kill_tree::blocking::get_available_max_process_id;
28-
///
29-
/// #[cfg(windows)]
30-
/// assert!(get_available_max_process_id() == 0xFFFF_FFFF);
31-
///
32-
/// #[cfg(target_os = "linux")]
33-
/// assert!(get_available_max_process_id() == 0x0040_0000);
34-
///
35-
/// #[cfg(target_os = "macos")]
36-
/// assert!(get_available_max_process_id() == 99998);
37-
/// ```
38-
#[must_use]
39-
pub fn get_available_max_process_id() -> u32 {
40-
crate::common::get_available_max_process_id()
41-
}
42-
4310
/// Kills the target process and all of its children recursively.
4411
/// # Platform-specifics
4512
///
@@ -53,12 +20,10 @@ pub fn get_available_max_process_id() -> u32 {
5320
///
5421
/// # Examples
5522
/// ```
56-
/// use kill_tree::{
57-
/// tokio::{get_available_max_process_id, kill_tree},
58-
/// Result,
59-
/// };
23+
/// use kill_tree::{get_available_max_process_id, tokio::kill_tree, Result};
6024
///
61-
/// fn main() -> Result<()> {
25+
/// #[tokio::main]
26+
/// async fn main() -> Result<()> {
6227
/// let _ = kill_tree(get_available_max_process_id()).await?;
6328
/// Ok(())
6429
/// }
@@ -101,34 +66,30 @@ pub async fn kill_tree(process_id: ProcessId) -> Result<Outputs> {
10166
///
10267
/// Kill processes using the `SIGKILL` signal.
10368
/// ```
104-
/// use kill_tree::{
105-
/// blocking::{get_available_max_process_id, kill_tree_with_config},
106-
/// Config, Result,
107-
/// };
69+
/// use kill_tree::{get_available_max_process_id, tokio::kill_tree_with_config, Config, Result};
10870
///
109-
/// fn main() -> Result<()> {
71+
/// #[tokio::main]
72+
/// async fn main() -> Result<()> {
11073
/// let config = Config {
11174
/// signal: String::from("SIGKILL"),
11275
/// ..Default::default()
11376
/// };
114-
/// let _ = kill_tree_with_config(get_available_max_process_id(), &config)?;
77+
/// let _ = kill_tree_with_config(get_available_max_process_id(), &config).await?;
11578
/// Ok(())
11679
/// }
11780
/// ```
11881
///
11982
/// Kills all children __except the target process__.
12083
/// ```
121-
/// use kill_tree::{
122-
/// blocking::{get_available_max_process_id, kill_tree_with_config},
123-
/// Config, Result,
124-
/// };
84+
/// use kill_tree::{get_available_max_process_id, tokio::kill_tree_with_config, Config, Result};
12585
///
126-
/// fn main() -> Result<()> {
86+
/// #[tokio::main]
87+
/// async fn main() -> Result<()> {
12788
/// let config = Config {
12889
/// include_target: false,
12990
/// ..Default::default()
13091
/// };
131-
/// let _ = kill_tree_with_config(get_available_max_process_id(), &config)?;
92+
/// let _ = kill_tree_with_config(get_available_max_process_id(), &config).await?;
13293
/// Ok(())
13394
/// }
13495
/// ```

0 commit comments

Comments
 (0)