MCPcopy Create free account
hub / github.com/AimRT/AimRT / ExportRpcContext

Function ExportRpcContext

src/runtime/python_runtime/export_rpc.h:59–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59inline void ExportRpcContext(const pybind11::object& m) {
60 using aimrt::rpc::Context;
61 using aimrt::rpc::ContextRef;
62
63 pybind11::enum_<aimrt_rpc_context_type_t>(m, "RpcContextType")
64 .value("AIMRT_RPC_CLIENT_CONTEXT", AIMRT_RPC_CLIENT_CONTEXT)
65 .value("AIMRT_RPC_SERVER_CONTEXT", AIMRT_RPC_SERVER_CONTEXT);
66
67 pybind11::class_<Context, std::shared_ptr<Context>>(m, "RpcContext")
68 .def(pybind11::init<>())
69 .def("CheckUsed", &Context::CheckUsed)
70 .def("SetUsed", &Context::SetUsed)
71 .def("Reset", &Context::Reset)
72 .def("GetType", &Context::GetType)
73 .def("Timeout", &Context::Timeout)
74 .def("SetTimeout", &Context::SetTimeout)
75 .def("GetMetaValue", &Context::GetMetaValue)
76 .def("SetMetaValue", &Context::SetMetaValue)
77 .def("GetMetaKeys", &Context::GetMetaKeys)
78 .def("GetToAddr", &Context::GetToAddr)
79 .def("SetToAddr", &Context::SetToAddr)
80 .def("GetSerializationType", &Context::GetSerializationType)
81 .def("SetSerializationType", &Context::SetSerializationType)
82 .def("GetFunctionName", &Context::GetFunctionName)
83 .def("SetFunctionName", &Context::SetFunctionName)
84 .def("ToString", &Context::ToString);
85
86 pybind11::class_<ContextRef>(m, "RpcContextRef")
87 .def(pybind11::init<>())
88 .def(pybind11::init<const Context&>(), pybind11::keep_alive<1, 2>())
89 .def(pybind11::init<Context*>(), pybind11::keep_alive<1, 2>())
90 .def(pybind11::init<const std::shared_ptr<Context>&>(), pybind11::keep_alive<1, 2>())
91 .def("__bool__", &ContextRef::operator bool)
92 .def("CheckUsed", &ContextRef::CheckUsed)
93 .def("SetUsed", &ContextRef::SetUsed)
94 .def("GetType", &ContextRef::GetType)
95 .def("Timeout", &ContextRef::Timeout)
96 .def("SetTimeout", &ContextRef::SetTimeout)
97 .def("GetMetaValue", &ContextRef::GetMetaValue)
98 .def("SetMetaValue", &ContextRef::SetMetaValue)
99 .def("GetMetaKeys", &ContextRef::GetMetaKeys)
100 .def("GetToAddr", &ContextRef::GetToAddr)
101 .def("SetToAddr", &ContextRef::SetToAddr)
102 .def("GetSerializationType", &ContextRef::GetSerializationType)
103 .def("SetSerializationType", &ContextRef::SetSerializationType)
104 .def("GetFunctionName", &ContextRef::GetFunctionName)
105 .def("SetFunctionName", &ContextRef::SetFunctionName)
106 .def("ToString", &ContextRef::ToString);
107}
108
109using ServiceFuncReturnType = std::tuple<aimrt::rpc::Status, std::string>;
110using ServiceFuncType = std::function<ServiceFuncReturnType(aimrt::rpc::ContextRef, const pybind11::bytes&)>;

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected