RustIface.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. #include "interface/RustIface.h"
  16. #include "interface/Iface.h"
  17. #include "memory/Allocator.h"
  18. #include "util/Identity.h"
  19. // struct RustIface {
  20. // struct Iface pub;
  21. // void* rustIf;
  22. // Identity
  23. // };
  24. // struct Error_s iface_send_from_c(struct Message* msg, void* iface);
  25. // void iface_wrap_rust_iface(void* rust_if, struct Iface* c_if);
  26. // static Iface_DEFUN send(struct Message* message, struct Iface* thisInterface)
  27. // {
  28. // struct RustIface* iface = Identity_check((struct RustIface*) thisInterface);
  29. // return iface_send_from_c(message, iface->rustIf);
  30. // }
  31. // static Iface_DEFUN recv(struct Message* message, struct Iface* thisInterface)
  32. // {
  33. // return Error(NONE);
  34. // }
  35. Iface_DEFUN RustIface_incomingFromRust(struct Message* message, struct Iface* thisInterface)
  36. {
  37. if (!thisInterface->connectedIf) {
  38. return Error(INTERNAL);
  39. }
  40. return Iface_send(thisInterface, message);
  41. }
  42. // struct Iface* RustIface_wrap(void* rustIf, struct Allocator* alloc)
  43. // {
  44. // struct RustIface* out = Allocator_calloc(alloc, sizeof(struct Iface), 1);
  45. // Identity_set(out);
  46. // out->rustIf = rustIf;
  47. // return NULL;
  48. // }