Comments (2)
Let me quickly concretize what those 3 different approaches could look like:
Examples
Following are 3 scale-info
encoded JSON example showing a composite type:
pub struct Foo(Compact<i32>);
Using a built-in scale-info
compact
type:
{
"strings": [
"Foo", # ID 1
],
"types": [
{ # ID 1
"compact": 2
},
{ # ID 2
"primitive": "i32"
},
{ # ID 3
"composite": {
"path": [ 1 ],
"fields": [
{ "type": 1 }
]
}
}
]
}
Using a built-in flag for compact types:
{
"strings": [
"Foo", # ID 1
],
"types": [
{ # ID 1
"primitive": "i32"
},
{ # ID 2
"composite": {
"path": [ 1 ],
"fields": [
{ "type": 1, "compact": true }
]
}
}
]
}
Using a special custom type for compact types: (Taking the one from scale
library)
{
"strings": [
"scale", # ID 1
"Compact", # ID 2
"T", # ID 3
"Foo", # ID 4
],
"types": [
{ # ID 1
"primitive": "i32"
},
{ # ID 2
"composite": {
"path": [ 1, 2 ],
"params": [ 3 ],
"fields": [
{
"type": {
"parameter": 3
}
}
]
}
},
{ # ID 3
"composite": {
"path": [ 4 ],
"fields": [
{
"type": {
"generic": {
"type": 2,
"params": [ 1 ],
}
}
}
]
}
}
]
}
from scale-info.
I am leaning towards the last example even though it seems to be the most convoluted solution because it plays nice with our other proposal for generics support (#6) and does not introduce yet another concept for the protocol but uses what is already there. Also due to the design of the generics proposal there will be at most one Compact
type definition per metadata so it won't be as convoluted at scale.
from scale-info.
Related Issues (20)
- Add UI tests for crate renaming
- Support `r#` in the module path HOT 2
- Regression from latest release with crate resolution HOT 5
- trait bound `H256: TypeInfo` is not satisfied; `TypeInfo` is not implemented for `H256, H160, H64, ethereum_types::U256` HOT 3
- Could we have a rename function? HOT 4
- Strip pretty-printed invisible delimiters for type names
- I found a little flaws in `scale-info` doc V2.1.2
- bitvec 1.0 HOT 1
- Should PortableType be pub use?
- Can scale-info support `skip` or `ignore` for some struct field? HOT 1
- Don't enable bitvec when "std" feature is enabled
- Generated metadata includes `struct NonZeroU64(NonZeroU64)`, which is impossible to construct HOT 3
- Implement stable type id HOT 6
- Implement `TypeInfo` for `Duration`
- Update CI
- scale info is no longer no_std compatible HOT 1
- Optionally allow encoding `PhantomData<T>` types HOT 3
- What are `I256` and `U256` for? HOT 1
- Not an issue, but can you type info to have reflections in rust ? HOT 2
- New release? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scale-info.