Skip to content

Commit

Permalink
Add comments/docs
Browse files Browse the repository at this point in the history
  • Loading branch information
glbrntt committed Oct 2, 2023
1 parent d482206 commit 891bf7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sources/GRPCCore/RPCError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
///
/// See also ``Status``.
public struct RPCError: @unchecked Sendable, Hashable, Error {
// @unchecked because it relies on heap allocated storage and 'isKnownUniquelyReferenced'

private var storage: Storage
private mutating func ensureStorageIsUnique() {
if !isKnownUniquelyReferenced(&self.storage) {
Expand All @@ -44,6 +46,11 @@ public struct RPCError: @unchecked Sendable, Hashable, Error {
}

/// Metadata associated with the error.
///
/// Any metadata included in the error thrown from a service will be sent back to the client and
/// conversely any ``RPCError`` received by the client may include metadata sent by a service.
///
/// Note that clients and servers may synthesise errors which may not include metadata.
public var metadata: Metadata {
get { self.storage.metadata }
set {
Expand Down
2 changes: 2 additions & 0 deletions Sources/GRPCCore/Status.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
/// is similar to ``Status`` but only represents error cases, in other words represents all status
/// codes apart from ``Code-swift.struct/ok``.
public struct Status: @unchecked Sendable, Hashable {
// @unchecked because it relies on heap allocated storage and 'isKnownUniquelyReferenced'

private var storage: Storage
private mutating func ensureStorageIsUnique() {
if !isKnownUniquelyReferenced(&self.storage) {
Expand Down

0 comments on commit 891bf7f

Please sign in to comment.