#newtype #properties #pattern #dynamic #system #type-safe #emphasizes

dynp

Dynamic property system that emphasizes the use of the Newtype pattern

3 releases

0.1.12 Oct 8, 2023
0.1.11 Sep 28, 2023
0.1.10 Sep 24, 2023

#6 in #property

32 downloads per month

MIT license

18KB
271 lines

dynp

codecov

A dynamic, type-safe property system that emphasizes the use of the Newtype pattern.

💡 Inspiration

This library was ispired by the iZotope/glassproperties C++ library; big credits to the amazing authors of that library.

📦 Features

  • Property collection
  • Property assignment
  • Property retrieval
  • Property subscriptions (with callbacks / closures)

👨‍💻 Usage

The following snipped should give you a basic idea what this library is about.

use dynp::PropertyCollection;

// define a custom property using the Newtype pattern
#[derive(Copy, Clone, Debug)]
struct CustomProperty(i32);

fn main() {
    // create a new property collection
    let mut collection = PropertyCollection::new();

    // assign a new property
    collection.assign(CustomProperty(42));

    // get the property
    match collection.get::<CustomProperty>() {
       Some(prop) => {
          println!("Property: {:?}", prop);
        },
        None => {
            println!("Property does not exist");
        }
    };
}

🚧 Roadmap

  • Property deserialization
  • Performance tests and improvements
  • Improved documentation

No runtime deps

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy