Required Instance Methodswift-protobuf 1.29.0SwiftProtobuf

traverse(visitor:)

Traverses the fields of the message, calling the appropriate methods of the passed Visitor object.

Message.swift:98
func traverse<V>(visitor: inout V) throws where V : Visitor

This is used internally by:

  • Protobuf binary serialization

  • JSON serialization (with some twists to account for specialty JSON)

  • Protobuf Text serialization

  • Hashable computation

Conceptually, serializers create visitor objects that are then passed recursively to every message and field via generated traverse methods. The details get a little involved due to the need to allow particular messages to override particular behaviors for specific encodings, but the general idea is quite simple.