Skip to content

Commit

Permalink
Rename from Structs -> StructUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj committed May 23, 2024
1 parent d4ae41d commit 5d5d771
Show file tree
Hide file tree
Showing 9 changed files with 449 additions and 237 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Structs.jl is licensed under the MIT License:
StructUtils.jl is licensed under the MIT License:

Copyright (c) 2024: Jacob Quinn

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "Structs"
name = "StructUtils"
uuid = "ec057cc2-7a8d-4b58-b3b3-92acb9f63b42"
version = "1.0.0"

Expand Down
34 changes: 16 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
# Structs
# StructUtils

[![CI](https://github.com/quinnj/Structs.jl/workflows/CI/badge.svg)](https://github.com/quinnj/Structs.jl/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/quinnj/Structs.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/quinnj/Structs.jl)
[![deps](https://juliahub.com/docs/Structs/deps.svg)](https://juliahub.com/ui/Packages/Structs/HHBkp?t=2)
[![version](https://juliahub.com/docs/Structs/version.svg)](https://juliahub.com/ui/Packages/Structs/HHBkp)
[![pkgeval](https://juliahub.com/docs/Structs/pkgeval.svg)](https://juliahub.com/ui/Packages/Structs/HHBkp)

\*\*
[![CI](https://github.com/quinnj/StructUtils.jl/workflows/CI/badge.svg)](https://github.com/quinnj/StructUtils.jl/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/quinnj/StructUtils.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/quinnj/StructUtils.jl)
[![deps](https://juliahub.com/docs/StructUtils/deps.svg)](https://juliahub.com/ui/Packages/StructUtils/HHBkp?t=2)
[![version](https://juliahub.com/docs/StructUtils/version.svg)](https://juliahub.com/ui/Packages/StructUtils/HHBkp)
[![pkgeval](https://juliahub.com/docs/StructUtils/pkgeval.svg)](https://juliahub.com/ui/Packages/StructUtils/HHBkp)

## Installation

The package is registered in the [`General`](https://github.com/JuliaRegistries/General) registry and so can be installed at the REPL with `] add Structs`.
The package is registered in the [`General`](https://github.com/JuliaRegistries/General) registry and so can be installed at the REPL with `] add StructUtils`.

## Documentation

The primary interface provided by Structs.jl is in the form of the exported `@noarg`, `@defaults`, and `@tags` macros, along with the unexported (to avoid clashing with the Base definition) of `Structs.@kwdef`. These macros can be used on struct definitions to provide a more ergonomic and flexible way to define structs with default values, keyword constructors, and more.
The primary interface provided by StructUtils.jl is in the form of the exported `@noarg`, `@defaults`, and `@tags` macros, along with the unexported (to avoid clashing with the Base definition) of `StructUtils.@kwdef`. These macros can be used on struct definitions to provide a more ergonomic and flexible way to define structs with default values, keyword constructors, and more.

The `@noarg` macro can be used to define a "no argument" constructor, and must be used with mutable structs. This allows
for programmatic construction and discovery of the supported behavior. Default values and field tags can also be defined in `@noarg` structs.
Expand All @@ -25,18 +23,18 @@ The `@tags` macro can be used to define tags for fields in any kind of struct.

The `@kwdef` macro mirros the functionality of the Base defintion, while also allowing for the inclusion of field tags.

The other major interface Structs.jl provides is the `Structs.make(T, source)` function. It allows programmatic construction of a type `T` from a variety of source objects.
For example, I could have a custom struct `Foo` and be able to construct an instance from an array of values, a dictionary, a database cursor, a JSON object, etc. This is done by allowing source objects to implement interfaces for how fields should be provided programmatically (the primary means being the `Structs.applyeach` function), while `Structs.make` uses the programmatic knowledge from the above-mentioned macros, along with potential field tags, to construct the object.
The other major interface StructUtils.jl provides is the `StructUtils.make(T, source)` function. It allows programmatic construction of a type `T` from a variety of source objects.
For example, I could have a custom struct `Foo` and be able to construct an instance from an array of values, a dictionary, a database cursor, a JSON object, etc. This is done by allowing source objects to implement interfaces for how fields should be provided programmatically (the primary means being the `StructUtils.applyeach` function), while `StructUtils.make` uses the programmatic knowledge from the above-mentioned macros, along with potential field tags, to construct the object.

Additional documentation is forth-coming around how package developers can use the "under the hood" machinery of Structs.jl to provide a more flexible and ergonomic interface to their users, like custom serialization/deserialization, database interaction, etc.
Additional documentation is forth-coming around how package developers can use the "under the hood" machinery of StructUtils.jl to provide a more flexible and ergonomic interface to their users, like custom serialization/deserialization, database interaction, etc.

## Contributing and Questions

Contributions are very welcome, as are feature requests and suggestions. Please open an
[issue][issues-url] if you encounter any problems or would just like to ask a question.

[ci-img]: https://github.com/quinnj/Structs.jl/workflows/CI/badge.svg
[ci-url]: https://github.com/quinnj/Structs.jl/actions?query=workflow%3ACI+branch%3Amaster
[codecov-img]: https://codecov.io/gh/quinnj/Structs.jl/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/quinnj/Structs.jl
[issues-url]: https://github.com/quinnj/Structs.jl/issues
[ci-img]: https://github.com/quinnj/StructUtils.jl/workflows/CI/badge.svg
[ci-url]: https://github.com/quinnj/StructUtils.jl/actions?query=workflow%3ACI+branch%3Amaster
[codecov-img]: https://codecov.io/gh/quinnj/StructUtils.jl/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/quinnj/StructUtils.jl
[issues-url]: https://github.com/quinnj/StructUtils.jl/issues
Loading

0 comments on commit 5d5d771

Please sign in to comment.