135template<
typename Sig>
138template<
typename R,
typename... Args>
151 explicit operator bool()
const {
return inner.has_value(); }
182 template<
typename Callable>
233 template<typename Callable>
237 registerMethod<Sig>(config.name.c_str(), wrapped, config.params, config.description, config.tags, config.mode);
241 template<
typename Callable>
278 it->second.mTypedCallable.get());
286 bool has(
const char* name)
const {
363#if FL_PLATFORM_HAS_LARGE_MEMORY
374#if FL_PLATFORM_HAS_LARGE_MEMORY
375 if (!paramNames.
empty()) {
fl::UIDescription description("Demo of the Animatrix effects. @author of fx is StefanPetrick")
Helper class for sending responses in async/streaming RPC methods.
void setResponseSink(fl::function< void(const fl::json &)> sink)
Set response sink for sending ACK responses (used by async functions)
fl::unordered_map< fl::string, detail::RpcEntry > mRegistry
json handle(const json &request)
Process a JSON-RPC request.
Rpc() FL_NOEXCEPT=default
bool unbind(const char *name)
Unbind (unregister) a previously registered method.
bool registerMethod(const char *name, RpcFn< Sig > fn, const fl::vector< fl::string > ¶mNames, const fl::string &description, const fl::vector< fl::string > &tags, fl::RpcMode mode=fl::RpcMode::SYNC)
fl::vector< fl::string > tags() const
Returns list of unique tags used across all methods.
fl::function< void(const fl::json &)> mResponseSink
void bind(const char *name, Callable fn, fl::RpcMode mode=fl::RpcMode::SYNC)
Convenience overload: bind method by name, function, and optional mode.
BindResult< Sig > get(const char *name) const
Get a registered method by name.
void bind(const Config< Callable > &config)
Bind a method with configuration (name, function, optional metadata).
json schema() const
Returns flat schema document.
fl::optional< json > handle_maybe(const json &request)
For notifications (no id), returns nullopt.
json methods() const
Returns flat method array: [["name", "returnType", [["param1", "type1"], ...]], .....
void clear()
Clear all registered methods.
void bindAsync(const char *name, fl::function< void(ResponseSend &, const json &)> fn, fl::RpcMode mode=fl::RpcMode::ASYNC)
Bind async method with ResponseSend& parameter (for ASYNC/ASYNC_STREAM modes) Signature: void(Respons...
fl::size count() const
Returns number of registered methods.
bool has(const char *name) const
Check if a method is registered (regardless of signature).
expected type for operations that can fail (C++23-style)
bool empty() const FL_NOEXCEPT
Generic expected<T, E> type for error handling without exceptions.
FastLED's Elegant JSON Library: fl::json
fl::shared_ptr< ErasedInvoker > mInvoker
fl::shared_ptr< ErasedSchemaGenerator > mSchemaGenerator
fl::shared_ptr< CallableHolderBase > mTypedCallable
fl::vector< fl::string > mTags
constexpr T && forward(typename remove_reference< T >::type &t) FL_NOEXCEPT
constexpr remove_reference< T >::type && move(T &&t) FL_NOEXCEPT
constexpr remove_reference< T >::type && move(T &&t) FL_NOEXCEPT
fl::function< Sig > RpcFn
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
enable_if< is_fixed_point< T >::value, T >::type exp(T x) FL_NOEXCEPT
Base definition for an LED controller.
fl::vector< ParamInfo > params
fl::vector< fl::string > tags
Method parameter information.
Wraps the result of binding to a method by name.
bool has_value() const
Check if binding succeeded.
const fl::expected< RpcFn< R(Args...)>, BindError > & get() const
Access the underlying expected.
R operator()(Args... args) const
Call the bound function directly (undefined behavior if binding failed) Always check ok() or has_valu...
BindError error() const
Get the error (undefined if has_value())
fl::expected< RpcFn< R(Args...)>, BindError > inner
RpcFn< R(Args...)> & value()
BindResult(fl::expected< RpcFn< R(Args...)>, BindError > exp)
Construct from expected.
RpcFn< R(Args...)> value() const
Get the callable (throws if error)
BindResult(RpcFn< R(Args...)> fn)
Construct from RpcFn (success case)
fl::vector< fl::string > params
Parameter names (optional)
Config(fl::string n, Callable f, fl::vector< fl::string > p, fl::string desc, fl::vector< fl::string > t={}, fl::RpcMode m=fl::RpcMode::SYNC)
Constructor with all fields.
fl::string name
Method name (REQUIRED)
Config(fl::string n, Callable f, fl::vector< fl::string > p, fl::RpcMode m=fl::RpcMode::SYNC)
Constructor with params.
fl::vector< fl::string > tags
Tags for grouping (optional)
Callable fn
Function to register (REQUIRED)
Config(fl::string n, Callable f, fl::RpcMode m=fl::RpcMode::SYNC)
Constructor requiring name and function (metadata is optional)
fl::RpcMode mode
Execution mode (SYNC or ASYNC, default SYNC)
fl::string description
Method description (optional)
Configuration for method registration with optional metadata.