FastLED 3.9.15
Loading...
Searching...
No Matches

◆ methods()

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

Get method information for all registered methods.

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

291 {
292 fl::vector<MethodInfo> result;
293
294 // Get flat JSON schema from underlying RPC
295 // Format: [["methodName", "returnType", [["param1", "type1"], ...]], ...]
296 fl::json jsonMethods = mRpc.methods();
297
298 if (!jsonMethods.is_array()) {
299 return result;
300 }
301
302 // Convert each flat method array to MethodInfo struct
303 for (fl::size i = 0; i < jsonMethods.size(); i++) {
304 fl::json method = jsonMethods[i];
305
306 if (!method.is_array() || method.size() < 3) {
307 continue; // Invalid method format
308 }
309
310 MethodInfo info;
311
312 // method[0] = method name
313 info.name = method[0].as_string().value_or("");
314
315 // method[1] = return type
316 info.returnType = method[1].as_string().value_or("void");
317
318 // method[2] = params array: [["param1", "type1"], ["param2", "type2"], ...]
319 if (method[2].is_array()) {
320 fl::json params = method[2];
321 for (fl::size j = 0; j < params.size(); j++) {
322 fl::json param = params[j];
323 if (param.is_array() && param.size() >= 2) {
324 ParamInfo paramInfo;
325 paramInfo.name = param[0].as_string().value_or("");
326 paramInfo.type = param[1].as_string().value_or("unknown");
327 info.params.push_back(fl::move(paramInfo));
328 }
329 }
330 }
331
332 // Flat schema doesn't include description/tags
333 info.description = "";
334 info.tags.clear();
335
336 result.push_back(fl::move(info));
337 }
338
339 return result;
340}
fl::ParamInfo ParamInfo
Definition remote.h:50
fl::MethodInfo MethodInfo
Definition remote.h:49
fl::Rpc mRpc
Definition remote.h:206
bool is_array() const FL_NOEXCEPT
Definition json.h:246
size_t size() const FL_NOEXCEPT
Definition json.h:633
fl::optional< fl::string > as_string() const FL_NOEXCEPT
Definition json.h:282
constexpr remove_reference< T >::type && move(T &&t) FL_NOEXCEPT
Definition s16x16x4.h:28
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::json::is_array(), fl::fl::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: