protos/
categories.rs

1use parity_scale_codec::{Decode, Encode};
2use scale_info::prelude::vec::Vec;
3
4#[cfg(not(feature = "std"))]
5type String = Vec<u8>;
6
7#[cfg(feature = "std")]
8use serde::{Deserialize, Serialize};
9
10/// A XX64 hash of the trait interface.
11pub type ShardsTrait = [u8; 8];
12
13#[derive(Encode, Decode, Copy, Clone, PartialEq, Debug, Eq, scale_info::TypeInfo)]
14#[cfg_attr(
15  feature = "std",
16  derive(Serialize, Deserialize),
17  serde(rename_all = "camelCase")
18)]
19pub enum ShardsFormat {
20  /// Canonical textual format interpreted by the Shards runtime
21  Edn,
22  /// Serialized binary format
23  Binary,
24}
25
26#[derive(Encode, Decode, Clone, PartialEq, Debug, Eq, scale_info::TypeInfo)]
27#[cfg_attr(
28  feature = "std",
29  derive(Serialize, Deserialize),
30  serde(rename_all = "camelCase")
31)]
32pub struct ShardsScriptInfo {
33  pub format: ShardsFormat,
34  #[codec(compact)]
35  pub shards_version: u32,
36  pub requiring: Vec<ShardsTrait>,
37  pub implementing: Vec<ShardsTrait>,
38}
39
40// serde(rename_all = "camelCase") is needed or polkadot.js will not be able to deserialize
41
42#[derive(Encode, Decode, Copy, Clone, PartialEq, Debug, Eq, scale_info::TypeInfo)]
43#[cfg_attr(
44  feature = "std",
45  derive(Serialize, Deserialize),
46  serde(rename_all = "camelCase")
47)]
48pub enum AudioCategories {
49  /// A compressed audio file in the ogg container format
50  OggFile,
51  /// A compressed audio file in the mp3 format
52  Mp3File,
53}
54
55#[derive(Encode, Decode, Copy, Clone, PartialEq, Debug, Eq, scale_info::TypeInfo)]
56#[cfg_attr(
57  feature = "std",
58  derive(Serialize, Deserialize),
59  serde(rename_all = "camelCase")
60)]
61pub enum ModelCategories {
62  /// A GLTF binary model
63  GltfFile,
64  /// 🤫😄
65  Sdf,
66  /// A physics collision model
67  PhysicsCollider,
68}
69
70#[derive(Encode, Decode, Copy, Clone, PartialEq, Debug, Eq, scale_info::TypeInfo)]
71#[cfg_attr(
72  feature = "std",
73  derive(Serialize, Deserialize),
74  serde(rename_all = "camelCase")
75)]
76pub enum TextureCategories {
77  PngFile,
78  JpgFile,
79}
80
81#[derive(Encode, Decode, Copy, Clone, PartialEq, Debug, Eq, scale_info::TypeInfo)]
82#[cfg_attr(
83  feature = "std",
84  derive(Serialize, Deserialize),
85  serde(rename_all = "camelCase")
86)]
87pub enum VectorCategories {
88  /// A Scalable Vector Graphics file
89  SvgFile,
90  /// A TrueType font file
91  TtfFile,
92  /// A font file in the OpenType format
93  OtfFile,
94}
95
96#[derive(Encode, Decode, Copy, Clone, PartialEq, Debug, Eq, scale_info::TypeInfo)]
97#[cfg_attr(
98  feature = "std",
99  derive(Serialize, Deserialize),
100  serde(rename_all = "camelCase")
101)]
102pub enum VideoCategories {
103  /// A compressed video file in the mkv container format
104  MkvFile,
105  /// A compressed video file in the mp4 container format
106  Mp4File,
107}
108
109#[derive(Encode, Decode, Copy, Clone, PartialEq, Debug, Eq, scale_info::TypeInfo)]
110#[cfg_attr(
111  feature = "std",
112  derive(Serialize, Deserialize),
113  serde(rename_all = "camelCase")
114)]
115pub enum TextCategories {
116  /// Plain Text
117  Plain,
118  /// Json String
119  Json,
120  /// WebGPU shader code
121  Wgsl,
122  /// A markdown file
123  Markdown,
124}
125
126#[derive(Encode, Decode, Copy, Clone, PartialEq, Debug, Eq, scale_info::TypeInfo)]
127#[cfg_attr(
128  feature = "std",
129  derive(Serialize, Deserialize),
130  serde(rename_all = "camelCase")
131)]
132pub enum BinaryCategories {
133  /// A generic wasm program, compiled to run on a WASI runtime
134  WasmProgram,
135  /// A generic wasm reactor, compiled to run on a WASI runtime
136  WasmReactor,
137  /// A blender file. Royalties distribution of blender files derived protos will always allocate a % to the Blender Foundation
138  BlendFile,
139  /// An ONNX ML model in its binary format
140  OnnxModel,
141  /// A safetensors ML model as from https://github.com/huggingface/safetensors
142  SafeTensors,
143  /// A RareForm Engine Domain
144  RareDomain,
145}
146
147/// Types of categories that can be attached to a Proto-Fragment to describe it (e.g Code, Audio, Video etc.)
148#[derive(Encode, Decode, Clone, PartialEq, Debug, Eq, scale_info::TypeInfo)]
149#[cfg_attr(
150  feature = "std",
151  derive(Serialize, Deserialize),
152  serde(rename_all = "camelCase")
153)]
154pub enum Categories {
155  /// Text of the supported sub-categories
156  Text(TextCategories),
157  /// A Scripting Trait declaration, traits are unique, and are used to describe how Shards work (Scripts)
158  /// None is meant to be used in Fragnova protos when uploading and RPCs mainly.
159  Trait(Option<ShardsTrait>),
160  /// Shards scripts of various sub-categories
161  /// Shards use interoperability traits to describe how they can be used in other shards
162  Shards(ShardsScriptInfo),
163  /// Audio files and effects
164  Audio(AudioCategories),
165  /// Textures of the supported sub-categories
166  Texture(TextureCategories),
167  /// Vectors of the supported sub-categories (e.g. SVG, Font)
168  Vector(VectorCategories),
169  /// Video file of the supported formats
170  Video(VideoCategories),
171  /// 2d/3d models of the supported formats
172  Model(ModelCategories),
173  /// Binary of the supported sub-categories
174  Binary(BinaryCategories),
175  /// A bundle of many protos
176  Bundle,
177}