FastLED 3.10.8
Loading...
Searching...
No Matches

◆ methods()

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

Get method information for all registered methods.

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

370 {
371 fl::vector<MethodInfo> result;
372
373 // Get flat JSON schema from underlying RPC
374 // Format: [["methodName", "returnType", [["param1", "type1"], ...]], ...]
375 fl::json jsonMethods = mRpc.methods();
376
377 if (!jsonMethods.is_array()) {
378 return result;
379 }
380
381 // Convert each flat method array to MethodInfo struct
382 for (fl::size i = 0; i < jsonMethods.size(); i++) {
383 fl::json method = jsonMethods[i];
384
385 if (!method.is_array() || method.size() < 3) {
386 continue; // Invalid method format
387 }
388
389 MethodInfo info;
390
391 // method[0] = method name
392 info.name = method[0].as_string().value_or("");
393
394 // method[1] = return type
395 info.returnType = method[1].as_string().value_or("void");
396
397 // method[2] = params array: [["param1", "type1"], ["param2", "type2"], ...]
398 if (method[2].is_array()) {
399 fl::json params = method[2];
400 for (fl::size j = 0; j < params.size(); j++) {
401 fl::json param = params[j];
402 if (param.is_array() && param.size() >= 2) {
403 ParamInfo paramInfo;
404 paramInfo.name = param[0].as_string().value_or("");
405 paramInfo.type = param[1].as_string().value_or("unknown");
406 info.params.push_back(fl::move(paramInfo));
407 }
408 }
409 }
410
411 // Flat schema doesn't include description/tags
412 info.description = "";
413 info.tags.clear();
414
415 result.push_back(fl::move(info));
416 }
417
418 return result;
419}
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 move.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::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: