Skip to content

Commit

Permalink
Merge pull request #105 from badeend/network-error-code
Browse files Browse the repository at this point in the history
Add `network-error-code`
  • Loading branch information
badeend committed Sep 18, 2024
2 parents 74ea247 + 99ad55e commit 2e9982e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions wit/network.wit
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@since(version = 0.2.0)
interface network {
@unstable(feature = network-error-code)
use wasi:io/error@0.2.1.{error};

/// An opaque resource that represents access to (a subset of) the network.
/// This enables context-based security for networking.
/// There is no need for this to map 1:1 to a physical network interface.
Expand Down Expand Up @@ -105,6 +108,19 @@ interface network {
permanent-resolver-failure,
}

/// Attempts to extract a network-related `error-code` from the stream
/// `error` provided.
///
/// Stream operations which return `stream-error::last-operation-failed`
/// have a payload with more information about the operation that failed.
/// This payload can be passed through to this function to see if there's
/// network-related information about the error to return.
///
/// Note that this function is fallible because not all stream-related
/// errors are network-related errors.
@unstable(feature = network-error-code)
network-error-code: func(err: borrow<error>) -> option<error-code>;

@since(version = 0.2.0)
enum ip-address-family {
/// Similar to `AF_INET` in POSIX.
Expand Down

0 comments on commit 2e9982e

Please sign in to comment.