Clean up code for optional node inputs/outputs

This removes the unused Split Channels node's primary output
This commit is contained in:
Keavon Chambers 2023-09-03 05:15:02 -07:00
parent bafde43145
commit c4bea2b400
5 changed files with 60 additions and 50 deletions

View file

@ -31,12 +31,20 @@ impl DocumentNodeMetadata {
}
}
#[derive(Clone, Debug, PartialEq, Hash, DynAny, Default)]
/// Utility function for providing a default boolean value to serde.
#[inline(always)]
fn return_true() -> bool {
true
}
#[derive(Clone, Debug, PartialEq, Hash, DynAny)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DocumentNode {
pub name: String,
pub inputs: Vec<NodeInput>,
pub manual_composition: Option<Type>,
#[serde(default = "return_true")]
pub has_primary_output: bool,
pub implementation: DocumentNodeImplementation,
pub metadata: DocumentNodeMetadata,
#[serde(default)]
@ -47,6 +55,22 @@ pub struct DocumentNode {
pub path: Option<Vec<NodeId>>,
}
impl Default for DocumentNode {
fn default() -> Self {
Self {
name: Default::default(),
inputs: Default::default(),
manual_composition: Default::default(),
has_primary_output: true,
implementation: Default::default(),
metadata: Default::default(),
skip_deduplication: Default::default(),
hash: Default::default(),
path: Default::default(),
}
}
}
impl DocumentNode {
pub fn populate_first_network_input(&mut self, node_id: NodeId, output_index: usize, offset: usize, lambda: bool) {
let (index, _) = self