Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #231 from nikomatsakis/dynamic-databases-rfc
[RFC] Dynamic databases
- Loading branch information
Showing
63 changed files
with
2,382 additions
and
2,050 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
# Plumbing | ||
|
||
**Last updated:** 2020-06-24 | ||
|
||
This chapter documents the code that salsa generates and its "inner workings". | ||
We refer to this as the "plumbing". | ||
|
||
This page walks through the ["Hello, World!"] example and explains the code that | ||
it generates. Please take it with a grain of salt: while we make an effort to | ||
keep this documentation up to date, this sort of thing can fall out of date | ||
easily. | ||
easily. See the page history below for major updates. | ||
|
||
["Hello, World!"]: https://github.com/salsa-rs/salsa/blob/master/examples/hello_world/main.rs | ||
|
||
If you'd like to see for yourself, you can set the environment variable | ||
`SALSA_DUMP` to 1 while the procedural macro runs, and it will dump the full | ||
output to stdout. I recommend piping the output through rustfmt. | ||
|
||
## History | ||
|
||
* 2020-07-05: Updated to take [RFC 6](rfcs/RFC0006-Dynamic-Databases.md) into account. | ||
* 2020-06-24: Initial version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Diagram | ||
|
||
Based on the hello world example: | ||
|
||
```rust,ignore | ||
{{#include ../../../examples/hello_world/main.rs:trait}} | ||
``` | ||
|
||
```rust,ignore | ||
{{#include ../../../examples/hello_world/main.rs:database}} | ||
``` | ||
|
||
```mermaid | ||
graph LR | ||
classDef diagramNode text-align:left; | ||
subgraph query group | ||
HelloWorldTrait["trait HelloWorld: Database + HasQueryGroup(HelloWorldStroage)"] | ||
HelloWorldImpl["impl(DB) HelloWorld for DB<br>where DB: HasQueryGroup(HelloWorldStorage)"] | ||
click HelloWorldImpl "http:query_groups.html#impl-of-the-hello-world-trait" "more info" | ||
HelloWorldStorage["struct HelloWorldStorage"] | ||
click HelloWorldStorage "http:query_groups.html#the-group-struct-and-querygroup-trait" "more info" | ||
QueryGroupImpl["impl QueryGroup for HelloWorldStorage<br> type DynDb = dyn HelloWorld<br> type Storage = HelloWorldGroupStorage__;"] | ||
click QueryGroupImpl "http:query_groups.html#the-group-struct-and-querygroup-trait" "more info" | ||
HelloWorldGroupStorage["struct HelloWorldGroupStorage__"] | ||
click HelloWorldGroupStorage "http:query_groups.html#group-storage" "more info" | ||
subgraph for each query... | ||
LengthQuery[struct LengthQuery] | ||
LengthQueryImpl["impl Query for LengthQuery<br> type Key = ()<br> type Value = usize<br> type Storage = salsa::DerivedStorage(Self)<br> type QueryGroup = HelloWorldStorage"] | ||
LengthQueryFunctionImpl["impl QueryFunction for LengthQuery<br> fn execute(db: &dyn HelloWorld, key: ()) -> usize"] | ||
click LengthQuery "http:query_groups.html#for-each-query-a-query-struct" "more info" | ||
click LengthQueryImpl "http:query_groups.html#for-each-query-a-query-struct" "more info" | ||
click LengthQueryFunctionImpl "http:query_groups.html#for-each-query-a-query-struct" "more info" | ||
end | ||
class HelloWorldTrait,HelloWorldImpl,HelloWorldStorage,QueryGroupImpl,HelloWorldGroupStorage diagramNode; | ||
class LengthQuery,LengthQueryImpl,LengthQueryFunctionImpl diagramNode; | ||
end | ||
subgraph database | ||
DatabaseStruct["struct Database { .. storage: Storage(Self) .. }"] | ||
subgraph for each group... | ||
HasQueryGroup["impl plumbing::HasQueryGroup(HelloWorldStorage) for DatabaseStruct"] | ||
click HasQueryGroup "http:database.html#the-hasquerygroup-impl" "more info" | ||
end | ||
DatabaseStorageTypes["impl plumbing::DatabaseStorageTypes for DatabaseStruct<br> type DatabaseStorage = __SalsaDatabaseStorage"] | ||
click DatabaseStorageTypes "http:database.html#the-databasestoragetypes-impl" "more info" | ||
DatabaseStorage["struct __SalsaDatabaseStorage"] | ||
click DatabaseStorage "http:database.html#the-database-storage-struct" "more info" | ||
DatabaseOps["impl plumbing::DatabaseOps for DatabaseStruct"] | ||
click DatabaseOps "http:database.html#the-databaseops-impl" "more info" | ||
class DatabaseStruct,DatabaseStorage,DatabaseStorageTypes,DatabaseOps,HasQueryGroup diagramNode; | ||
end | ||
subgraph salsa crate | ||
DerivedStorage["DerivedStorage"] | ||
class DerivedStorage diagramNode; | ||
end | ||
LengthQueryImpl --> DerivedStorage; | ||
DatabaseStruct --> HelloWorldImpl | ||
HasQueryGroup --> HelloWorldImpl | ||
``` |
Oops, something went wrong.