FastLED 3.9.15
Loading...
Searching...
No Matches
rpc_method_builder.h
Go to the documentation of this file.
1#pragma once
2#include "fl/stl/string.h"
3#include "fl/stl/vector.h"
5
6namespace fl {
7
8// Forward declaration - Rpc is defined in fl/rpc.h
9class Rpc;
10
11namespace detail {
12
13// =============================================================================
14// MethodBuilder - Fluent API for setting method metadata
15// =============================================================================
16// This is an internal detail class used by Rpc::method_with().
17// Users get this via the fluent API but shouldn't need to reference it directly.
18
19template<typename Sig>
21public:
24
25 // Set parameter names (in order)
26 MethodBuilder& params(fl::initializer_list<const char*> names) {
27 for (const char* n : names) {
28 mParamNames.push_back(fl::string(n));
29 }
30 return *this;
31 }
32
33 // Set method description
34 MethodBuilder& description(const char* desc) {
35 mDescription = desc;
36 return *this;
37 }
38
39 // Set tags for grouping (OpenRPC tags)
40 MethodBuilder& tags(fl::initializer_list<const char*> tagList) {
41 for (const char* t : tagList) {
42 mTags.push_back(fl::string(t));
43 }
44 return *this;
45 }
46
47 // Finalize and register the method
48 // Implementation is in rpc.h after Rpc is fully defined
49 void done();
50
51 // Accessors for done() implementation
52 Rpc* factory() const { return mFactory; }
53 const fl::string& name() const { return mName; }
54 const RpcFn<Sig>& fn() const { return mFn; }
56 const fl::string& descriptionStr() const { return mDescription; }
57 const fl::vector<fl::string>& tagsVec() const { return mTags; }
58
59private:
66};
67
68} // namespace detail
69} // namespace fl
Definition rpc.h:178
const fl::vector< fl::string > & tagsVec() const
const fl::string & descriptionStr() const
MethodBuilder & description(const char *desc)
fl::vector< fl::string > mParamNames
MethodBuilder & params(fl::initializer_list< const char * > names)
MethodBuilder & tags(fl::initializer_list< const char * > tagList)
const fl::vector< fl::string > & paramNames() const
MethodBuilder(Rpc *factory, const char *name, RpcFn< Sig > fn)
const RpcFn< Sig > & fn() const
fl::vector< fl::string > mTags
const fl::string & name() const
Compile-time linker keep-alive hook for a single fl::Bus.
Definition bus_traits.h:48
fl::function< Sig > RpcFn
Definition rpc_handle.h:14
Base definition for an LED controller.
Definition crgb.hpp:179