diff options
| -rw-r--r-- | CHANGELOG.md | 7 | ||||
| -rw-r--r-- | arg_picker/src/builtin.rs | 3 | ||||
| -rw-r--r-- | arg_picker/src/builtin/pick_ip_attr.rs | 39 | ||||
| -rw-r--r-- | arg_picker/src/builtin/pick_pathbuf.rs | 18 | ||||
| -rw-r--r-- | arg_picker/src/builtin/pick_socket_attr.rs | 39 |
5 files changed, 102 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index da1c26a..9890439 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -171,14 +171,13 @@ None _No migration is required — these are purely additive derives that expand the type's capabilities without affecting existing behavior._ -**[`core`]** Added the `build` feature (renamed from `builds`) to `mingling_core` and `mingling`. The old `builds` feature has been deprecated in favor of `build`, with a backward-compatibility alias retained in `mingling/Cargo.toml`: +8. **[`core`]** Added the `build` feature (renamed from `builds`) to `mingling_core` and `mingling`. The old `builds` feature has been deprecated in favor of `build`, with a backward-compatibility alias retained in `mingling/Cargo.toml`: - **`mingling_core/Cargo.toml`**: Renamed the feature from `builds` to `build`. - **`mingling/Cargo.toml`**: Changed the feature dependency from `mingling_core/builds` to `mingling_core/build`. A deprecated `builds` feature alias is kept as `builds = ["mingling_core/build"]` with a note indicating it will be removed in a future breaking change. _No behavioral changes — the `build` feature provides identical functionality to the old `builds` feature. Downstream code using `builds` continues to work via the alias, but should migrate to `build`._ - -8. **[`core`]** Renamed `ResourceMarker` methods from public names (`res_clone`, `res_default`, `modify`) to doc-hidden internal names (`__resource_marker_clone`, `__resource_marker_default`, `__resource_marker_modify`). These methods are internal implementation details of the resource injection system and should not be called directly by user code. By prefixing with `__` and adding `#[doc(hidden)]`, they are still technically accessible but hidden from documentation and tooling, reducing API surface confusion. +9. **[`core`]** Renamed `ResourceMarker` methods from public names (`res_clone`, `res_default`, `modify`) to doc-hidden internal names (`__resource_marker_clone`, `__resource_marker_default`, `__resource_marker_modify`). These methods are internal implementation details of the resource injection system and should not be called directly by user code. By prefixing with `__` and adding `#[doc(hidden)]`, they are still technically accessible but hidden from documentation and tooling, reducing API surface confusion. - **`res_clone()`** → **`__resource_marker_clone()`** — Internal method for cloning a resource value during resource injection. - **`res_default()`** → **`__resource_marker_default()`** — Internal method for creating a default resource value during resource injection. @@ -188,7 +187,7 @@ None A new module `mingling_core::asset::core_invokes` has been added to provide a centralized location for internal invocation helpers. -9. **[`core:exec`]** Refactored the program execution pipeline (`exec` and `exec_with_args`) to use the `might_be_async` crate instead of manual `#[cfg(feature = "async")]` duplication. The previously separate sync and async implementations have been consolidated into a single `#[might_be_async::func]`-annotated function, with `might_be_async::invoke!()` wrapping the `C::do_chain(current)` call inside `exec_with_args` and the delegation from `exec` to `exec_with_args`. +10. **[`core:exec`]** Refactored the program execution pipeline (`exec` and `exec_with_args`) to use the `might_be_async` crate instead of manual `#[cfg(feature = "async")]` duplication. The previously separate sync and async implementations have been consolidated into a single `#[might_be_async::func]`-annotated function, with `might_be_async::invoke!()` wrapping the `C::do_chain(current)` call inside `exec_with_args` and the delegation from `exec` to `exec_with_args`. The `exec` function no longer contains the full execution loop inline. Instead, it delegates to `exec_with_args` (which now also carries the `#[might_be_async::func]` annotation), reducing code duplication and centralizing the execution logic. diff --git a/arg_picker/src/builtin.rs b/arg_picker/src/builtin.rs index 1c698ba..b51590d 100644 --- a/arg_picker/src/builtin.rs +++ b/arg_picker/src/builtin.rs @@ -1,5 +1,8 @@ mod pick_bool; mod pick_flag; +mod pick_ip_attr; mod pick_numbers; +mod pick_pathbuf; mod pick_picker_args; +mod pick_socket_attr; mod pick_string; diff --git a/arg_picker/src/builtin/pick_ip_attr.rs b/arg_picker/src/builtin/pick_ip_attr.rs new file mode 100644 index 0000000..d68fa15 --- /dev/null +++ b/arg_picker/src/builtin/pick_ip_attr.rs @@ -0,0 +1,39 @@ +use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; + +use crate::SinglePickable; + +impl SinglePickable for IpAddr { + fn pick_single(str: Option<&str>) -> crate::PickerArgResult<Self> { + match str { + Some(s) => match s.parse::<IpAddr>() { + Ok(addr) => crate::PickerArgResult::Parsed(addr), + Err(_) => crate::PickerArgResult::NotFound, + }, + None => crate::PickerArgResult::NotFound, + } + } +} + +impl SinglePickable for Ipv4Addr { + fn pick_single(str: Option<&str>) -> crate::PickerArgResult<Self> { + match str { + Some(s) => match s.parse::<Ipv4Addr>() { + Ok(addr) => crate::PickerArgResult::Parsed(addr), + Err(_) => crate::PickerArgResult::NotFound, + }, + None => crate::PickerArgResult::NotFound, + } + } +} + +impl SinglePickable for Ipv6Addr { + fn pick_single(str: Option<&str>) -> crate::PickerArgResult<Self> { + match str { + Some(s) => match s.parse::<Ipv6Addr>() { + Ok(addr) => crate::PickerArgResult::Parsed(addr), + Err(_) => crate::PickerArgResult::NotFound, + }, + None => crate::PickerArgResult::NotFound, + } + } +} diff --git a/arg_picker/src/builtin/pick_pathbuf.rs b/arg_picker/src/builtin/pick_pathbuf.rs new file mode 100644 index 0000000..3bd4410 --- /dev/null +++ b/arg_picker/src/builtin/pick_pathbuf.rs @@ -0,0 +1,18 @@ +use std::path::PathBuf; + +use crate::{ + PickerArgResult::{NotFound, Parsed}, + SinglePickable, +}; + +impl SinglePickable for PathBuf { + fn pick_single(str: Option<&str>) -> crate::PickerArgResult<Self> { + match str { + Some(str) => match just_fmt::fmt_path_str(str) { + Ok(formated) => Parsed(PathBuf::from(formated)), + Err(_) => NotFound, + }, + None => NotFound, + } + } +} diff --git a/arg_picker/src/builtin/pick_socket_attr.rs b/arg_picker/src/builtin/pick_socket_attr.rs new file mode 100644 index 0000000..0c0dd71 --- /dev/null +++ b/arg_picker/src/builtin/pick_socket_attr.rs @@ -0,0 +1,39 @@ +use std::net::{SocketAddr, SocketAddrV4, SocketAddrV6}; + +use crate::SinglePickable; + +impl SinglePickable for SocketAddr { + fn pick_single(str: Option<&str>) -> crate::PickerArgResult<Self> { + match str { + Some(s) => match s.parse::<SocketAddr>() { + Ok(addr) => crate::PickerArgResult::Parsed(addr), + Err(_) => crate::PickerArgResult::NotFound, + }, + None => crate::PickerArgResult::NotFound, + } + } +} + +impl SinglePickable for SocketAddrV4 { + fn pick_single(str: Option<&str>) -> crate::PickerArgResult<Self> { + match str { + Some(s) => match s.parse::<SocketAddrV4>() { + Ok(addr) => crate::PickerArgResult::Parsed(addr), + Err(_) => crate::PickerArgResult::NotFound, + }, + None => crate::PickerArgResult::NotFound, + } + } +} + +impl SinglePickable for SocketAddrV6 { + fn pick_single(str: Option<&str>) -> crate::PickerArgResult<Self> { + match str { + Some(s) => match s.parse::<SocketAddrV6>() { + Ok(addr) => crate::PickerArgResult::Parsed(addr), + Err(_) => crate::PickerArgResult::NotFound, + }, + None => crate::PickerArgResult::NotFound, + } + } +} |
