Message

The protocol which all generated protobuf messages implement. Message is the protocol type you should use whenever you need an argument or variable which holds “some message”.

Message.swift:35
@preconcurrency protocol Message : CustomDebugStringConvertible, Sendable
Browse conforming types

Generated messages also implement Hashable, and thus Equatable. However, the protocol conformance is declared on a different protocol. This allows you to use Message as a type directly:

func consume(message: Message) { ... }

Instead of needing to use it as a type constraint on a generic declaration:

func consume<M: Message>(message: M) { ... }

If you need to convince the compiler that your message is Hashable so you can insert it into a Set or use it as a Dictionary key, use a generic declaration with a type constraint:

func insertIntoSet<M: Message & Hashable>(message: M) {
    mySet.insert(message)
}

The actual functionality is implemented either in the generated code or in default implementations of the below methods and properties.