Thanks to visit codestin.com
Credit goes to github.com

Skip to content

lume-lang/architect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lume Architect

CI crates.io docs.rs

A simplistic query system, allowing for on-demand, memoized computation.

architect is a way of defining queries. A query is some function which takes a set of arguments and computes some result. By default, results from queries are memoized to prevent recomputation. This does assume that the result of the query is idempotent, given the input arguments.

Getting started

To make a function into a query, add the crate:

cargo add lume_architect --features derive

On the type which the query operates on, implement the DatabaseContext trait:

use lume_architect::{Database, DatabaseContext};

struct Provider {
    // ... other fields

    db: Database,
}

impl DatabaseContext for Provider {
    fn db(&self) -> &Database {
        &self.db
    }
}

To declare a method as a query, add the cached_query attribute:

impl Provider {
    /// Computes some result, which takes a reeeeally long time.
    #[cached_query]
    pub fn compute(&self) -> f32 {
        // ...
    }
}

Inspiration

This implementation is heavily based on Rust's query system, based on salsa. Massive credit to the countless of amazing developers who helped create them.

About

Library for creating memoized queries, in a simple way

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages