Download examples/c++-dataflow/operator-rust-api/operator.cc from opencsg/csg-robomaster: direct link, hf CLI and curl.
- Browser
- Download file 830 Bytes
-
https://huggingface.co/datasets/opencsg/csg-robomaster/resolve/main/examples/c%2B%2B-dataflow/operator-rust-api/operator.cc
- Command line
-
hf download hf://datasets/opencsg/csg-robomaster/examples/c++-dataflow/operator-rust-api/operator.cc
-
curl -L -o operator.cc https://huggingface.co/datasets/opencsg/csg-robomaster/resolve/main/examples/c%2B%2B-dataflow/operator-rust-api/operator.cc
830 Bytes
| Operator::Operator() {} | |
| std::unique_ptr<Operator> new_operator() | |
| { | |
| return std::make_unique<Operator>(); | |
| } | |
| DoraOnInputResult on_input(Operator &op, rust::Str id, rust::Slice<const uint8_t> data, OutputSender &output_sender) | |
| { | |
| op.counter += 1; | |
| std::cout << "Rust API operator received input `" << id.data() << "` with data `" << (unsigned int)data[0] << "` (internal counter: " << (unsigned int)op.counter << ")" << std::endl; | |
| std::vector<unsigned char> out_vec{op.counter}; | |
| rust::Slice<const uint8_t> out_slice{out_vec.data(), out_vec.size()}; | |
| auto send_result = send_output(output_sender, rust::Str("status"), out_slice); | |
| DoraOnInputResult result = {send_result.error, false}; | |
| return result; | |
| } | |