https://github.com/magnet/synattra
A Syn Attribute Parser Toolkit
https://github.com/magnet/synattra
Last synced: 6 months ago
JSON representation
A Syn Attribute Parser Toolkit
- Host: GitHub
- URL: https://github.com/magnet/synattra
- Owner: magnet
- License: apache-2.0
- Created: 2019-02-06T16:27:46.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-15T16:17:57.000Z (8 months ago)
- Last Synced: 2024-12-22T07:49:19.194Z (6 months ago)
- Language: Rust
- Homepage:
- Size: 12.7 KB
- Stars: 14
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# Synattra
[](https://travis-ci.org/magnet/synattra)
[](
https://github.com/magnet/synattra)
[](
https://crates.io/crates/synattra)
[](
https://docs.rs/synattra)
[](
https://www.rust-lang.org)## A Syn Attribute Parser Toolkit
Synattra extends Syn and provides structures to easily parse custom attributes.
Notably, Synattra provides a `KVOption` type that allows parsing attributes in the form `key = value` where `key` can be any token or custom keyword (including Rust keywords!) and value any type that can be parsed from a `TokenStream`. Synattra was extracted from the [Metered project](https://github.com/magnet/metered-rs) which needed expressing type paths as option values (e.g `path::to::GenericType`), which was not supported by existing attribute parsing systems (neither Syn's own `Meta` parsing facility or alternate crates such as [prom-attire-rs](https://github.com/Nemo157/prom-attire-rs/)).
Synattra also supports single or multiple values, that can take the shape of `Foo` or `[Foo, Bar]`.
Finally Synattra provides some extra types, such as `InvokePath` which represents any invocation handle, macro or not (e.g `foo` or `println!`).
By reusing Syn's design, Synattra parsers are very robust and when they compile, they usually work :-).
## Changelog
* 0.3.0:
* Updated dependencies to use `syn` 2.0 and `auto_enums` 0.8
* 0.2.0:
* Updated dependencies to use `syn`, `proc-macro2` and `quote` 1.0## Required Rust version
Synattra runs on `Rust` stable.
### Design
Synattra is using Syn's design for attribute parsing. You can see it in use in the [Metered project](https://github.com/magnet/metered-rs).
## License
Licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in the work by you, as defined in the Apache-2.0
license, shall be dual licensed as above, without any additional terms or
conditions.