1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
use crateResult;
use cratePipeline;
/// Safe extension trait: implement this to allow `pipeline.create::<T>()` for pure-Rust composite nodes.
///
/// This is the recommended way to create "new nodes" in Rust: your type can internally
/// create and link native DepthAI nodes.
/// Safe extension trait for parameterized creation.
/// Trait that all device nodes must implement to be created via `Pipeline::create<T>()`
///
/// # Overview
///
/// This trait is analogous to the C++ `DeviceNodeCRTP` pattern used in depthai-core,
/// allowing generic node creation in the pipeline using a type-safe, Rust-idiomatic approach.
///
/// In the C++ library, nodes are created using `pipeline.create<dai::node::Camera>()` where
/// the node type is a template parameter. This trait provides the same ergonomic API in Rust.
///
/// # Design Pattern
///
/// The trait uses the "type-driven instantiation" pattern where:
/// - The pipeline holds the context for node creation
/// - Node types implement this trait to define their creation logic
/// - The generic `Pipeline::create::<T>()` method dispatches to the trait implementation
///
/// # Example
///
/// ```ignore
/// use depthai::pipeline::Pipeline;
/// use depthai::camera::CameraNode;
/// use depthai::pipeline::DeviceNode;
///
/// let pipeline = Pipeline::new().build()?;
///
/// // For nodes that don't need parameters, use DeviceNode trait
/// // (future nodes like StereoDepth, RGBD would implement this)
/// // let stereo = pipeline.create::<StereoDepthNode>()?;
/// ```
///
/// # Implementation Notes
///
/// - For nodes that don't require parameters, implement this trait
/// - For nodes that require parameters (like `CameraNode`), use `DeviceNodeWithParams` instead
/// - The `Sized` bound ensures the node can be returned by value
/// Low-level (FFI) extension trait.
///
/// Prefer implementing `CreateInPipeline` / `CreateInPipelineWith` instead.
///
/// # Safety
/// Implementors must uphold the FFI contract:
/// - Any handles returned must belong to the provided `Pipeline`
/// - Returned Rust values must keep the underlying pipeline alive as long as needed
/// - Do not mix handles from different pipelines
pub unsafe
/// Trait for device nodes that require additional parameters for creation
///
/// # Overview
///
/// Some device nodes need additional configuration at creation time. For example,
/// `CameraNode` requires a `CameraBoardSocket` to specify which physical camera to use.
///
/// This trait extends the basic `DeviceNode` pattern to support parameterized creation,
/// maintaining the ergonomic generic API while allowing flexibility.
///
/// # Example
///
/// ```ignore
/// use depthai::pipeline::Pipeline;
/// use depthai::camera::CameraNode;
/// use depthai::common::CameraBoardSocket;
/// use depthai::pipeline::DeviceNodeWithParams;
///
/// let pipeline = Pipeline::new().build()?;
///
/// // Camera nodes need a socket parameter
/// let camera = pipeline.create_with::<CameraNode, _>(CameraBoardSocket::CamA)?;
/// ```
///
/// # Type Parameters
///
/// * `P` - The parameter type required for node creation
///
/// # Implementation Notes
///
/// - Use this trait when your node requires configuration at creation time
/// - The parameter type `P` can be any type that makes sense for your node
/// - For nodes without parameters, implement `DeviceNode` instead
/// Low-level (FFI) parameterized extension trait.
///
/// Prefer implementing `CreateInPipelineWith<P>` instead.
///
/// # Safety
/// Same safety requirements as `DeviceNode`, plus the implementor must correctly interpret `params`.
pub unsafe