Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
439548f
former : standalone constructors
Wandalen Apr 24, 2025
a1518c8
former : cleaning
Wandalen Apr 24, 2025
bfff73d
former : cleaning
Wandalen Apr 24, 2025
e377e2a
former : cleaning
Wandalen Apr 24, 2025
9244a97
former : cleaning
Wandalen Apr 24, 2025
34d206e
former : cleaning
Wandalen Apr 24, 2025
f3c3c7d
former : cleaning
Wandalen Apr 24, 2025
5b333c9
former : cleaning
Wandalen Apr 24, 2025
5fb728c
former : evolve enum
Wandalen Apr 24, 2025
e28d63b
former : evolve enum
Wandalen Apr 24, 2025
f8ab1b8
former : evolve enum
Wandalen Apr 24, 2025
203666f
former : evolve enum
Wandalen Apr 24, 2025
750531b
former : evolve enum
Wandalen Apr 24, 2025
75b2c20
former : evolve enum
Wandalen Apr 24, 2025
845d7eb
former : evolve enum
Wandalen Apr 24, 2025
a0ce1a4
former : plan
Wandalen Apr 24, 2025
cc122eb
former : plan
Wandalen Apr 24, 2025
9807086
former : plan
Wandalen Apr 24, 2025
9b8fa06
former : evolve enum
Wandalen Apr 24, 2025
2f1b94c
former : evolve enum
Wandalen Apr 24, 2025
10d8b77
former : plan
Wandalen Apr 25, 2025
286fcbc
former : plan
Wandalen Apr 26, 2025
7881fbd
former : plan
Wandalen Apr 27, 2025
ffae5f2
former : plan
Wandalen Apr 27, 2025
457e66c
wip
Wandalen Apr 29, 2025
3607b74
wip
Wandalen Apr 29, 2025
a5cf785
wip
Wandalen Apr 29, 2025
538108b
wip
Wandalen Apr 29, 2025
56d7ef2
wip
Wandalen Apr 29, 2025
607cf4c
wip
Wandalen Apr 29, 2025
cd0aff6
wip
Wandalen Apr 29, 2025
02af4aa
wip
Wandalen Apr 29, 2025
b49035f
wip
Wandalen Apr 29, 2025
88df62e
wip
Wandalen Apr 29, 2025
715d0d4
wip
Wandalen Apr 29, 2025
bee88b4
wip
Wandalen Apr 29, 2025
a73a9df
wip
Wandalen Apr 29, 2025
bc14a0d
wip
Wandalen Apr 29, 2025
e63e8f7
wip
Wandalen Apr 29, 2025
b7d780c
wip
Wandalen Apr 29, 2025
89a59c5
wip
Wandalen Apr 29, 2025
d7007c3
wip
Wandalen Apr 30, 2025
cc58cd9
wip
Wandalen Apr 30, 2025
4a9dce3
wip
Wandalen Apr 30, 2025
089fa6c
wip
Wandalen Apr 30, 2025
3a92894
wip
Wandalen Apr 30, 2025
b5f73a7
wip
Wandalen Apr 30, 2025
50642e6
wip
Wandalen Apr 30, 2025
360bdf2
wip
Wandalen Apr 30, 2025
c219836
wip
Wandalen Apr 30, 2025
c109ea8
wip
Wandalen Apr 30, 2025
51aa8e0
wip
Wandalen Apr 30, 2025
a855a2b
wip
Wandalen Apr 30, 2025
ea57ef2
moving out component model
Wandalen Apr 30, 2025
abe6233
plan
Wandalen Apr 30, 2025
f3329a2
plan
Wandalen Apr 30, 2025
d1b66e4
plan
Wandalen Apr 30, 2025
d6202bb
wip
Wandalen May 1, 2025
de2e3fe
wip
Wandalen May 1, 2025
56d5a54
wip
Wandalen May 1, 2025
efd11ac
wip
Wandalen May 1, 2025
03b04f3
wip
Wandalen May 1, 2025
acfd920
wip
Wandalen May 1, 2025
076f9d4
wip
Wandalen May 1, 2025
0a44d49
wip
Wandalen May 2, 2025
6899284
wip
Wandalen May 2, 2025
d6fdb13
wip
Wandalen May 2, 2025
4f56d63
fixing
Wandalen May 2, 2025
a58d98e
fixing
Wandalen May 2, 2025
8580860
fixing
Wandalen May 2, 2025
830f7d9
fixing
Wandalen May 2, 2025
c2b75db
fixing
Wandalen May 3, 2025
e2fa7f8
fixing
Wandalen May 3, 2025
a96a391
wip
Wandalen May 3, 2025
53ca2c4
wip
Wandalen May 3, 2025
8a92a53
wip
Wandalen May 3, 2025
5d14eb2
plan
Wandalen May 3, 2025
e4583dd
plan
Wandalen May 3, 2025
09384fc
.
Wandalen May 3, 2025
081294e
plan
Wandalen May 3, 2025
5e99371
plan
Wandalen May 3, 2025
6242ec4
wip
Wandalen May 3, 2025
87d13e3
wip
Wandalen May 3, 2025
0eb5a3d
wip
Wandalen May 3, 2025
48c5a20
Merge branch 'wip5' into component_model_1
Wandalen May 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/.vscode
/_*

.roo
.env
_key
_data
Expand All @@ -31,3 +32,4 @@ Cargo.lock
.warchive*
-*
rustc-ice-*.txt
.roo
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
exclude = [
"-*",
"module/move/_video_experiment",
"module/move/cargo_will",
]
# default-members = [ "module/core/wtools" ]

Expand Down Expand Up @@ -56,6 +57,7 @@ single_call_fn = "allow"
inline_always = "allow"
module_name_repetitions = "allow"
absolute_paths = "allow"
wildcard_imports = "allow"

## top level

Expand Down Expand Up @@ -460,14 +462,12 @@ default-features = false
# path = "module/alias/wautomata"
# default-features = false


## ca

[workspace.dependencies.wca]
version = "~0.24.0"
path = "module/move/wca"


## censor

[workspace.dependencies.wcensor]
Expand Down Expand Up @@ -649,7 +649,6 @@ default-features = false
[workspace.dependencies.const_format]
version = "~0.2.32"
default-features = false

# proc-macro2 = { version = "~1.0.78", default-features = false, features = [] }
# quote = { version = "~1.0.35", default-features = false, features = [] }
# syn = { version = "~2.0.52", default-features = false, features = [ "full", "extra-traits" ] } # qqq : xxx : optimize set of features
Expand Down
19 changes: 10 additions & 9 deletions module/alias/cargo_will/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ enabled = []

[dependencies]
willbe = { workspace = true }
error_tools = { workspace = true }

[dev-dependencies]
test_tools = { workspace = true }
assert_fs = "1.0"
serde_yaml = "0.9"
serde_json = "1.0.114"
serde = "1.0"
assert_cmd = "2.0"
petgraph = "~0.6"
cargo_metadata = "~0.14"
# [dev-dependencies]
# test_tools = { workspace = true }
# assert_fs = "1.0"
# serde_yaml = "0.9"
# serde_json = "1.0.114"
# serde = "1.0"
# assert_cmd = "2.0"
# petgraph = "~0.6"
# cargo_metadata = "~0.14"
23 changes: 23 additions & 0 deletions module/alias/cargo_will/plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Project Plan: Fix cargo_will crate

## Increments

* ❌ Increment 1: Analyze the structure and dependencies of the cargo_will crate.
* Detailed Plan Step 1: Read the `Cargo.toml` file of the `cargo_will` crate to understand its dependencies.
* Detailed Plan Step 2: List the files in the `src` directory of the `cargo_will` crate to understand its structure.
* Detailed Plan Step 3: Read the main source file (e.g., `src/lib.rs` or `src/main.rs`) to understand the crate's entry point and overall logic.
* Verification Strategy: Ensure the commands execute successfully and the output is as expected. Manually review the output to understand the structure and dependencies.
* ⏳ Increment 2: Identify and fix any compilation errors in the cargo_will crate.
* Detailed Plan Step 1: Run `cargo build` in the `module/alias/cargo_will` directory.
* Detailed Plan Step 2: Analyze the output of `cargo build` to identify any compilation errors.
* Detailed Plan Step 3: Fix any identified compilation errors.
* Verification Strategy: Ensure `cargo build` executes successfully with no errors.

## Notes & Insights
* **[5/3/2025] Stuck:** Encountered persistent issues with building the crate due to dependency resolution problems. Initiating Stuck Resolution Process.

## Hypotheses

* Hypothesis 1: The path to the `willbe` dependency is incorrect.
* Hypothesis 2: There is a version conflict between the `error_tools` dependency in `cargo_will` and `willbe`.
* Hypothesis 3: There is an issue with the workspace configuration in the root `Cargo.toml` file.
4 changes: 2 additions & 2 deletions module/core/clone_dyn_meta/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ mod derive;

#[ cfg( feature = "enabled" ) ]
#[ proc_macro_attribute ]
pub fn clone_dyn( _attr : proc_macro::TokenStream, item : proc_macro::TokenStream ) -> proc_macro::TokenStream
pub fn clone_dyn( attr : proc_macro::TokenStream, item : proc_macro::TokenStream ) -> proc_macro::TokenStream
{
let result = derive::clone_dyn( _attr, item );
let result = derive::clone_dyn( attr, item );
match result
{
Ok( stream ) => stream.into(),
Expand Down
43 changes: 38 additions & 5 deletions module/core/component_model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ documentation = "https://docs.rs/component_model"
repository = "https://github.com/Wandalen/wTools/tree/master/module/core/component_model"
homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/component_model"
description = """
Type-based data assignment and extraction between structs.
A flexible implementation of the Builder pattern supporting nested builders and collection-specific subcomponent_models. Simplify the construction of complex objects.
"""
categories = [ "algorithms", "development-tools" ]
keywords = [ "fundamental", "general-purpose" ]
keywords = [ "fundamental", "general-purpose", "builder-pattern" ]

[lints]
workspace = true
Expand All @@ -24,11 +24,44 @@ features = [ "full" ]
all-features = false

[features]
default = [ "enabled" ]
full = [ "enabled" ]
enabled = []

no_std = [ "component_model_types/no_std", "collection_tools/no_std" ]
use_alloc = [ "no_std", "component_model_types/use_alloc", "collection_tools/use_alloc" ]

# no_std = [ "collection_tools/no_std" ]
# use_alloc = [ "no_std", "collection_tools/use_alloc" ]

default = [
"enabled",
"derive_component_model",
"derive_components",
"derive_component_from",
"derive_component_assign",
"derive_components_assign",
"derive_from_components",
"types_component_model",
"types_component_assign",
]
full = [
"default",
]
enabled = [ "component_model_meta/enabled", "component_model_types/enabled" ]

derive_component_model = [ "component_model_meta/derive_component_model", "types_component_model" ]
derive_components = [ "component_model_meta/derive_components", "derive_component_assign", "derive_components_assign", "derive_component_from", "derive_from_components" ]
derive_component_assign = [ "component_model_meta/derive_component_assign", "types_component_assign" ]
derive_components_assign = [ "derive_component_assign", "component_model_meta/derive_components_assign" ]
derive_component_from = [ "component_model_meta/derive_component_from" ]
derive_from_components = [ "component_model_meta/derive_from_components" ]

types_component_model = [ "component_model_types/types_component_model" ]
types_component_assign = [ "component_model_types/types_component_assign" ]

[dependencies]
component_model_meta = { workspace = true }
component_model_types = { workspace = true }
# collection_tools = { workspace = true, features = [ "collection_constructors" ] }

[dev-dependencies]
test_tools = { workspace = true }
collection_tools = { workspace = true, features = [ "collection_constructors" ] }
1 change: 1 addition & 0 deletions module/core/component_model/License
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.


THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Expand Down
68 changes: 66 additions & 2 deletions module/core/component_model/Readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,70 @@
<!-- {{# generate.module_header{} #}} -->

# Module :: component_model
[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/Modulecomponent_modelPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/Modulecomponent_modelPush.yml) [![docs.rs](https://img.shields.io/docsrs/component_model?color=e3e8f0&logo=docs.rs)](https://docs.rs/component_model) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY)

Type-based data assignment and extraction between structs.
[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental)
[![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_component_model_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_component_model_push.yml)
[![docs.rs](https://img.shields.io/docsrs/component_model?color=e3e8f0&logo=docs.rs)](https://docs.rs/component_model)
[![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fcomponent_model%2Fexamples%2Fcomponent_model_trivial.rs,RUN_POSTFIX=--example%20module%2Fcore%2Fcomponent_model%2Fexamples%2Fcomponent_model_trivial.rs/https://github.com/Wandalen/wTools)
[![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY)

A flexible component model for Rust supporting generic assignment and type-based field access.

## Installation

Add `component_model` to your `Cargo.toml`:

```sh
cargo add component_model
```

## Minimal Example: Using Assign

```rust
use component_model::prelude::Assign;

#[derive(Debug, PartialEq, Default)]
struct Person {
age: i32,
name: String,
}

impl<IntoT> Assign<i32, IntoT> for Person
where
IntoT: Into<i32>,
{
fn assign(&mut self, component: IntoT) {
self.age = component.into();
}
}

impl<IntoT> Assign<String, IntoT> for Person
where
IntoT: Into<String>,
{
fn assign(&mut self, component: IntoT) {
self.name = component.into();
}
}

fn main() {
let mut person = Person::default();
person.assign(42);
person.assign("Alice");
assert_eq!(person, Person { age: 42, name: "Alice".to_string() });
}
```

## API Overview

- **Assign**: Generic trait for assigning values to struct fields by type.
- **AssignWithType**: Trait for assigning values with explicit type annotation.
- **ComponentsAssign**: Trait for assigning multiple components at once.

See [component_model_types documentation](https://docs.rs/component_model_types) for details.

## Where to Go Next

- [Examples Directory](https://github.com/Wandalen/wTools/tree/master/module/core/component_model/examples): Explore practical, runnable examples.
- [API Documentation (docs.rs)](https://docs.rs/component_model): Get detailed information on all public types, traits, and functions.
- [Repository (GitHub)](https://github.com/Wandalen/wTools/tree/master/module/core/component_model): View the source code, contribute, or report issues.
42 changes: 42 additions & 0 deletions module/core/component_model/examples/component_model_trivial.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// //! ## Example : Trivial
// //!
// //! The provided code snippet illustrates a basic use-case of the Former, which is used to apply the builder pattern for to construct complex objects step-by-step, ensuring they are always in a valid state and hiding internal structures.
// //!
//
// #[ cfg( any( not( feature = "derive_component_model" ), not( feature = "enabled" ) ) ) ]
// fn main() {}
//
// #[ cfg( all( feature = "derive_component_model", feature = "enabled" ) ) ]
// fn main()
// {
// use component_model::Former;
//
// // Use attribute debug to print expanded code.
// #[ derive( Debug, PartialEq, Former ) ]
// // Uncomment to see what derive expand into
// // #[ debug ]
// pub struct UserProfile
// {
// age : i32,
// username : String,
// bio_optional : Option< String >, // Fields could be optional
// }
//
// let profile = UserProfile::component_model()
// .age( 30 )
// .username( "JohnDoe".to_string() )
// .bio_optional( "Software Developer".to_string() ) // Optionally provide a bio
// .form();
//
// dbg!( &profile );
// // Expected output:
// // &profile = UserProfile {
// // age: 30,
// // username: "JohnDoe",
// // bio_optional: Some("Software Developer"),
// // }
//
// }

fn main() {}
// qqq : xxx : write it
48 changes: 48 additions & 0 deletions module/core/component_model/examples/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Component Model Crate Examples

This directory contains runnable examples demonstrating various features and use cases of the `component_model` crate and its associated derive macros (`#[ derive( ComponentModel ) ]`, `#[ derive( Assign ) ]`, etc.).

Each file focuses on a specific aspect, from basic usage to advanced customization and subforming patterns.

## How to Run Examples

To run any of the examples listed below, navigate to the `component_model` crate's root directory (`module/core/component_model`) in your terminal and use the `cargo run --example` command, replacing `<example_name>` with the name of the file (without the `.rs` extension).

**Command:**

```sh
# Replace <example_name> with the desired example file name
cargo run --example <example_name>
```

**Example:**

```sh
# From the module/core/component_model directory:
cargo run --example component_model_trivial
```

**Note:** Some examples might require specific features to be enabled if you are running them outside the default configuration, although most rely on the default features. Check the top of the example file for any `#[ cfg(...) ]` attributes if you encounter issues.

## Example Index

| Group | Example File | Description |
|----------------------|------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|
| **Basic Usage** | [component_model_trivial.rs](./component_model_trivial.rs) | Basic derive usage with required/optional fields. |
| | [component_model_many_fields.rs](./component_model_many_fields.rs) | Derive usage with various field types (primitives, String, Option, Vec, HashMap) using scalar setters. |
| **Collections** | [component_model_collection_vector.rs](./component_model_collection_vector.rs) | Building a `Vec` using `#[ subform_collection ]` and `.add()`. |
| | [component_model_collection_hashmap.rs](./component_model_collection_hashmap.rs) | Building a `HashMap` using `#[ subform_collection ]` and `.add( ( k, v ) )`. |
| | [component_model_collection_hashset.rs](./component_model_collection_hashset.rs) | Building a `HashSet` using `#[ subform_collection ]` and `.add( value )`. |
| **Customization** | [component_model_custom_defaults.rs](./component_model_custom_defaults.rs) | Specifying custom default values with `#[ component_model( default = ... ) ]`. |
| | [component_model_custom_setter.rs](./component_model_custom_setter.rs) | Defining an alternative custom setter method on the Component Model struct. |
| | [component_model_custom_setter_overriden.rs](./component_model_custom_setter_overriden.rs) | Overriding a default setter using `#[ scalar( setter = false ) ]`. |
| | [component_model_custom_scalar_setter.rs](./component_model_custom_scalar_setter.rs) | Defining a custom *scalar* setter manually (contrasting subform approach). |
| **Subcomponent_models** | [component_model_custom_subform_scalar.rs](./component_model_custom_subform_scalar.rs) | Building a nested struct using `#[ subform_scalar ]`. |
| | [component_model_custom_subform_collection.rs](./component_model_custom_subform_collection.rs) | Implementing a custom *collection* subcomponent_model setter manually. |
| | [component_model_custom_subform_entry.rs](./component_model_custom_subform_entry.rs) | Building collection entries individually using `#[ subform_entry ]` and a custom setter helper. |
| | [component_model_custom_subform_entry2.rs](./component_model_custom_subform_entry2.rs) | Building collection entries individually using `#[ subform_entry ]` with fully manual closure logic. |
| **Advanced** | [component_model_custom_mutator.rs](./component_model_custom_mutator.rs) | Using `#[ storage_fields ]` and `#[ mutator( custom ) ]` with `impl ComponentModelMutator`. |
| | [component_model_custom_definition.rs](./component_model_custom_definition.rs) | Defining a custom `ComponentModelDefinition` and `FormingEnd` to change the formed type. |
| | [component_model_custom_collection.rs](./component_model_custom_collection.rs) | Implementing `Collection` traits for a custom collection type. |
| **Component Model** | [component_model_component_from.rs](./component_model_component_from.rs) | Using `#[ derive( ComponentFrom ) ]` for type-based field extraction. |
| **Debugging** | [component_model_debug.rs](./component_model_debug.rs) | Using the struct-level `#[ debug ]` attribute to view generated code. |
Loading
Loading