WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Extend API of UnconnectedUdpSocket #91

@maikerlab

Description

@maikerlab

To improve compatibility of RIOT Sockets with more libraries and applications, I want to propose implementing the following functions for riot_wrappers::socket_embedded_nal_async_udp::UnconnectedUdpSocket, similar to the API of async-io

  • pub async fn send_to(&mut self, data: &[u8], addr: SocketAddr) -> Result<(), Error> (like this one)
  • pub async fn recv_from(&mut self, buffer: &mut [u8]) -> Result<(usize, SocketAddr), Error> (like this one from async-io)
  • something like pub async fn peek_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)> (like this one to receive a packet without removing it from the queue

Background:
While integrating the (experimental) Rust Matter Library into RIOT OS (see PR) I had to deal with incompatibilities between the Traits NetworkSend and NetworkReceive and the provided functions by UnconnectedUdpSocket. As a workaround I developed a "Wrapper" where I just called the corresponding functions send/receive_into and did some coordination between them. After my implementation, there were some changes in rs-matter, where the traits got renamed and additionally required the wait_available function to enable sharing one buffer between two UDP sockets.

I don't know if there are any other popular libraries in "Rust Embedded" where the same problem arises, but for using the rs-matter Library in RIOT OS it is required. I think it would also be a great benefit in general, if an async_io socket could easily be swapped out by a RIOT Socket.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions