Rollup merge of #156414 - tunnell:pr-xous-net-recv-byte-offset, r=nia-e

std/sys/net/xous: read NetError code from byte 4 in recv/accept paths

The Xous std backend's TCP **send** path reads the `NetError`
code from `send_request.raw[4]` (correct — that's where the
xous-core kernel's `respond_with_error` writes it). But the TCP
recv, UDP recv, and TcpListener accept paths all read from
`raw[1]` instead. The kernel's historical layout is
`[1, 1, 1, 1, code, 0, 0, 0]`, so byte 1 is always `1` and
`ErrorKind::TimedOut` / `ErrorKind::WouldBlock` are unreachable
from the recv side — every error falls through to the catch-all
`ErrorKind::Other("recv_slice failure")`.

This patch moves the recv-path checks to `raw[4]`, matching the
send path and the kernel's existing encoding. Three files,
identical one-byte change in each (+15 / -10 total). No new
behavior; an existing inconsistency between the send and recv
sides of the same backend is removed.

**Why this matters in practice:** any application using
`set_read_timeout()` to interleave reads and writes on a Xous
`TcpStream` (e.g. a tungstenite-based WebSocket pump) currently
can't distinguish "no data this poll" from real transport
failure. Concretely, a Signal client using a 5s read timeout saw
every WebSocket torn down within 5s of opening, because the
timeout was indistinguishable from a fatal error.

**Coordination with the kernel side:** a complementary kernel-
side change has been filed on the xous-core repo —
[betrusted-io/xous-core#877](https://github.com/betrusted-io/xous-core/pull/877)
— which mirrors the code at byte 1 in addition to byte 4 so
applications work immediately on stock Rust toolchains while
this PR cycles. After both land, the two sides agree at byte 4
and byte 1 stays mirrored only for backwards-compat with older
Rust. Either change alone fixes the user-visible symptom; both
together remove the wire-format ambiguity.

**Tests:** Tier-3 target std backends generally don't have CI
coverage in this repo, so I haven't added any. Happy to add an
in-process test that constructs a fake net-server response and
asserts the `ErrorKind` mapping if maintainers prefer.

Full disclosure: I used an AI agent to debug this problem and eventually track it here.
tree: 4e3b8283559bc1e4027608ffeb6031a80e5c81c8
  1. .github/
  2. compiler/
  3. library/
  4. LICENSES/
  5. src/
  6. tests/
  7. .clang-format
  8. .editorconfig
  9. .git-blame-ignore-revs
  10. .gitattributes
  11. .gitignore
  12. .gitmodules
  13. .ignore
  14. .mailmap
  15. bootstrap.example.toml
  16. Cargo.lock
  17. Cargo.toml
  18. CODE_OF_CONDUCT.md
  19. configure
  20. CONTRIBUTING.md
  21. COPYRIGHT
  22. INSTALL.md
  23. LICENSE-APACHE
  24. license-metadata.json
  25. LICENSE-MIT
  26. package.json
  27. README.md
  28. RELEASES.md
  29. REUSE.toml
  30. rust-bors.toml
  31. rustfmt.toml
  32. triagebot.toml
  33. typos.toml
  34. x
  35. x.ps1
  36. x.py
  37. yarn.lock
README.md

Website | Getting started | Learn | Documentation | Contributing

This is the main source code repository for Rust. It contains the compiler, standard library, and documentation.

Why Rust?

  • Performance: Fast and memory-efficient, suitable for critical services, embedded devices, and easily integrated with other languages.

  • Reliability: Our rich type system and ownership model ensure memory and thread safety, reducing bugs at compile-time.

  • Productivity: Comprehensive documentation, a compiler committed to providing great diagnostics, and advanced tooling including package manager and build tool (Cargo), auto-formatter (rustfmt), linter (Clippy) and editor support (rust-analyzer).

Quick Start

Read “Installation” from The Book.

Installing from Source

If you really want to install from source (though this is not recommended), see INSTALL.md.

Getting Help

See https://www.rust-lang.org/community for a list of chat platforms and forums.

Contributing

See CONTRIBUTING.md.

For a detailed explanation of the compiler's architecture and how to begin contributing, see the rustc-dev-guide.

License

Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.

Trademark

The Rust Foundation owns and protects the Rust and Cargo trademarks and logos (the “Rust Trademarks”).

If you want to use these names or brands, please read the Rust language trademark policy.

Third-party logos may be subject to third-party copyrights and trademarks. See Licenses for details.