-
Notifications
You must be signed in to change notification settings - Fork 0
Package Format
The package format uses JSON syntax and contains the following elements:
- name: The package name (type: String).
- version: The package version (type: String, format: semantic versioning).
- crates: The crates defined in this package. Crates reflect the structure of corresponding Rust crates (type: Dictionary of Crate objects (key: crate name, value: Crate object)).
- types: Types defined in this crate (type: Dictionary of Type objects (key: type name, value: Type object)).
- modules: Modules defined in this crate. Modules reflect the structure of corresponding module crates (type: Dictionary of Module objects (key: module name, value: Module object)).
- types: Types defined in this module (type: Dictionary of Type objects (key: type name, value: Type object)).
- modules: Modules defined in this module (type: Dictionary of Module objects (key: module name, value: Module object)).
- inputs: Optional list of input edges. If the type implements the Node trait, this needs to be set (type: List of Strings).
- outputs: Optional list of output edges. If the type implements the Node trait, this needs to be set (type: List of Strings).
- type_parameters: Optional list of type parameters in case the type is generic (type: List of Strings).
- constructors: Constructors that can be used to create an instance of this type (type: Dictionary (key: constructor name, value: Constructor object)).
Reflects the flowrs_build::package::Constructor enumeration. Describes in detail how code for constructor function should be created. The necessary fields depend on the enumeration type. Currently, the following types exist:
A simple constructor function without any parameters.
- function_name: The optional name of the constructor function. Default: "new" (type: String).
A simple constructor function with a single parameter being the globally available ChangeObserver object.
- function_name: The optional name of the constructor function. Default: "new" (type: String).
Example:
"DebugNode":{
...
"constructors":{
"New":{
"NewWithObserver":{
}
}
}
}
A simple constructor function with two parameters: The globally available ChangeObserver and Context objects.
- function_name: The optional name of the constructor function. Default: "new" (type: String).
A constructor with arbitrary arguments.
- function_name: The optional name of the constructor function. Default: "new" (type: String).
- arguments: The arguments of the constructor function (type: List of Argument objects).
- name: The name of the argument (type: String).
- type: The argument type (type: ArgumentType)
- passing: Describes how the argument is passed to the constructor function (type: ArgumentPassing)
- construction: Describes how the argument is constructed (type: ArgumentConstruction)
- Move
- Clone
- MutableReference
- Reference
- ExistingObject: One of the global objects (change_observer, context).
- Constructor: Name of the constructor to use for argument construction (type: String).
-
Type: A specific type (that can have additional type parameters).
- name: Name of the type (type: String).
- type_parameters: Optional list of type parameters (type: List of ArgumentType objects).
-
Generic: A generic type (that can have additional type parameters).
- name: Name of the type (type: String).
- type_parameters: Optional list of type parameters (type: List of ArgumentType objects).
Example:
"ValueNode":{
"inputs":[
],
"outputs":[
"output"
],
"type_parameters":[
"I"
],
"constructors":{
"New":{
"NewWithArbitraryArgs":{
"arguments":[
{
"type":{
"Generic":{
"name":"I"
}
},
"name":"value",
"passing":"Move",
"construction":{
"Constructor":"Json"
}
},
{
"type":{
"Type":{
"name":"()"
}
},
"name":"change_observer",
"passing":"Clone",
"construction":{
"ExistingObject":[
]
}
}
]
}
}
}
}
A constructor that reads its arguments from JSON. The JSON is part of the flow project JSON.
Example:
"TimerNodeConfig":{
"constructors":{
"Json":"FromJson"
}
}
A constructor that reads its arguments from JSON. The JSON is part of the flow project JSON.
Example:
"TimerNodeConfig":{
"constructors":{
"Default":"FromDefault"
}
}
A constructor that is directly written in Rust code.
- code_template: The code that should be emitted for this constructor. The code can contain placeholders (marked with {{placeholder}}) that are replaced during code generation (type: String).
Possible placeholders:
- fully_qualified_name: The fully qualified name of the object that should be created.
- type_name: The name of the type.
- type_parameter_part: The type parameter part of generic types.
- type_parameter_NAME: The chosen type for type parameter NAME.
- mutable: If the object to be created should be mutable, this field contains "mut". If not, it contains "".
Example:
"MyType":{
"type_parameters":[
"U",
"T"
],
"constructors":{
"Code":{
"FromCode":{
"code_template":"let {{fully_qualified_name}}:{{type_parameter_U}} = 5;"
}
}
}
}
{
"name":"flowrs-std",
"version":"1.0.0",
"crates":{
"flowrs_std":{
"types":{
},
"modules":{
"nodes":{
"types":{
},
"modules":{
"debug":{
"modules":{
},
"types":{
"DebugNode":{
"inputs":[
"input"
],
"outputs":[
"output"
],
"type_parameters":[
"I"
],
"constructors":{
"New":{
"NewWithObserver":{
}
}
}
}
}
},
"value":{
"modules":{
},
"types":{
"ValueType":{
"constructors":{
"Json":"FromJson"
}
},
"ValueNode":{
"inputs":[
],
"outputs":[
"output"
],
"type_parameters":[
"I"
],
"constructors":{
"New":{
"NewWithArbitraryArgs":{
"arguments":[
{
"type":{
"Generic":{
"name":"I"
}
},
"name":"value",
"passing":"Move",
"construction":{
"Constructor":"Json"
}
},
{
"type":{
"Type":{
"name":"()"
}
},
"name":"change_observer",
"passing":"Clone",
"construction":{
"ExistingObject":[
]
}
}
]
}
}
}
}
}
},
"timer":{
"modules":{
},
"types":{
"TimerNodeConfig":{
"constructors":{
"Json":"FromJson"
}
},
"PollTimer":{
"type_parameters":[
"U"
],
"constructors":{
"New":{
"New":{
}
}
}
},
"SelectedTimer":{
"type_parameters":[
"U"
],
"constructors":{
"New":{
"New":{
}
}
}
},
"TimerNode":{
"inputs":[
"config_input",
"token_input"
],
"outputs":[
"token_output"
],
"type_parameters":[
"T",
"U"
],
"constructors":{
"NewWithToken":{
"NewWithArbitraryArgs":{
"function_name":"new_with_token",
"arguments":[
{
"type":{
"Generic":{
"name":"T",
"type_parameters":[
{
"Generic":{
"name":"U"
}
}
]
}
},
"name":"timer",
"passing":"Move",
"construction":{
"Constructor":"New"
}
},
{
"type":{
"Generic":{
"name":"U"
}
},
"name":"token_object",
"passing":"Move",
"construction":{
"Constructor":"New"
}
},
{
"type":{
"Type":{
"name":"()"
}
},
"name":"change_observer",
"passing":"Clone",
"construction":{
"ExistingObject":[
]
}
}
]
}
},
"New":{
"NewWithArbitraryArgs":{
"arguments":[
{
"type":{
"Generic":{
"name":"T",
"type_parameters":[
{
"Generic":{
"name":"U"
}
}
]
}
},
"name":"timer",
"passing":"Move",
"construction":{
"Constructor":"New"
}
},
{
"type":{
"Type":{
"name":"()"
}
},
"name":"change_observer",
"passing":"Clone",
"construction":{
"ExistingObject":[
]
}
}
]
}
}
}
}
}
}
}
}
}
}
}
}