You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

operator.cc 821 B

1234567891011121314151617181920212223
  1. #include "operator.h"
  2. #include <iostream>
  3. #include <vector>
  4. #include "dora-operator-api.h"
  5. Operator::Operator() {}
  6. std::unique_ptr<Operator> new_operator()
  7. {
  8. return std::make_unique<Operator>();
  9. }
  10. DoraOnInputResult on_input(Operator &op, rust::Str id, rust::Slice<const uint8_t> data, OutputSender &output_sender)
  11. {
  12. op.counter += 1;
  13. std::cout << "Rust API operator received input `" << id.data() << "` with data `" << (unsigned int)data[0] << "` (internal counter: " << (unsigned int)op.counter << ")" << std::endl;
  14. std::vector<unsigned char> out_vec{op.counter};
  15. rust::Slice<const uint8_t> out_slice{out_vec.data(), out_vec.size()};
  16. auto send_result = send_output(output_sender, rust::Str("status"), out_slice);
  17. DoraOnInputResult result = {send_result.error, false};
  18. return result;
  19. }