File tree 1 file changed +33
-0
lines changed
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -448,6 +448,39 @@ pub const HttpDevice = struct {
448
448
}
449
449
self .runner_loop .store_tx_data (TXPkg .convert_type (.HTTP , Package { .SMALL = req }), runner_inst ) catch unreachable ;
450
450
}
451
+
452
+ pub fn link_device (self : * HttpDevice , runner : anytype ) void {
453
+ const info = @typeInfo (@TypeOf (runner ));
454
+ switch (info ) {
455
+ .pointer = > | ptr | {
456
+ const child_type = ptr .child ;
457
+ if (@hasField (child_type , "HTTP_device" )) {
458
+ const HTTP_device = & runner .HTTP_device ;
459
+ if (@TypeOf (HTTP_device .* ) == ? * Device ) {
460
+ self .device .device_instance = @ptrCast (self );
461
+ HTTP_device .* = & self .device ;
462
+ } else {
463
+ @compileError ("HTTP_device need to be a Device pointer" );
464
+ }
465
+ } else {
466
+ @compileError (std .fmt .comptimePrint ("type {s} does not have field \" HTTP_device\" " , .{@typeName (runner )}));
467
+ }
468
+
469
+ if (@hasField (child_type , "runner_dev" )) {
470
+ if (@TypeOf (runner .runner_dev ) == Runner ) {
471
+ self .runner_loop = &(runner .* .runner_dev );
472
+ } else {
473
+ @compileError ("runner_dev need to be a Runner type" );
474
+ }
475
+ } else {
476
+ @compileError (std .fmt .comptimePrint ("type {s} does not have field \" runner_dev\" " , .{@typeName (runner )}));
477
+ }
478
+ },
479
+ else = > {
480
+ @compileError ("\" runner\" need to be a Pointer" );
481
+ },
482
+ }
483
+ }
451
484
};
452
485
453
486
fn check_request (req : * const Request ) HTTPError ! void {
You can’t perform that action at this time.
0 commit comments