FastLED 3.10.9
Loading...
Searching...
No Matches

◆ methods()

fl::vector< Remote::MethodInfo > fl::Remote::methods ( ) const

Get method information for all registered methods.

Definition at line 373 of file remote.cpp.hpp.

373 {
374 fl::vector<MethodInfo> result;
375
376 // Get flat JSON schema from underlying RPC
377 // Format: [["methodName", "returnType", [["param1", "type1"], ...]], ...]
378 fl::json jsonMethods = mRpc.methods();
379
380 if (!jsonMethods.is_array()) {
381 return result;
382 }
383
384 // Convert each flat method array to MethodInfo struct
385 for (fl::size i = 0; i < jsonMethods.size(); i++) {
386 fl::json method = jsonMethods[i];
387
388 if (!method.is_array() || method.size() < 3) {
389 continue; // Invalid method format
390 }
391
392 MethodInfo info;
393
394 // method[0] = method name
395 info.name = method[0].as_string().value_or("");
396
397 // method[1] = return type
398 info.returnType = method[1].as_string().value_or("void");
399
400 // method[2] = params array: [["param1", "type1"], ["param2", "type2"], ...]
401 if (method[2].is_array()) {
402 fl::json params = method[2];
403 for (fl::size j = 0; j < params.size(); j++) {
404 fl::json param = params[j];
405 if (param.is_array() && param.size() >= 2) {
406 ParamInfo paramInfo;
407 paramInfo.name = param[0].as_string().value_or("");
408 paramInfo.type = param[1].as_string().value_or("unknown");
409 info.params.push_back(fl::move(paramInfo));
410 }
411 }
412 }
413
414 // Flat schema doesn't include description/tags
415 info.description = "";
416 info.tags.clear();
417
418 result.push_back(fl::move(info));
419 }
420
421 return result;
422}
fl::ParamInfo ParamInfo
Definition remote.h:52
fl::MethodInfo MethodInfo
Definition remote.h:51
fl::Rpc mRpc
Definition remote.h:225
size_t size() const FL_NO_EXCEPT
Definition json.h:798
fl::optional< fl::string > as_string() const FL_NO_EXCEPT
Definition json.h:443
bool is_array() const FL_NO_EXCEPT
Definition json.h:389
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
Definition s16x16x4.h:30
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

References fl::json::as_string(), fl::vector< T >::clear(), fl::MethodInfo::description, fl::FL_NO_EXCEPT, fl::json::is_array(), fl::fl::adl_barrier::move(), mRpc, fl::MethodInfo::name, fl::ParamInfo::name, fl::MethodInfo::params, fl::MethodInfo::returnType, fl::json::size(), fl::MethodInfo::tags, and fl::ParamInfo::type.

+ Here is the call graph for this function: