Skip to content

Commit beeb414

Browse files
gjcairothomasvl
authored andcommitted
Make README clearer about serializedBytes()
1 parent edb6ed4 commit beeb414

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,19 @@ let info2 = BookInfo.with {
262262
}
263263

264264
// Serialize to binary protobuf format: you can choose to serialize into
265-
// any type conforming to SwiftProtobufContiguousBytes. For example:
265+
// any type conforming to `SwiftProtobufContiguousBytes`. For example:
266+
// Resolve the `SwiftProtobufContiguousBytes` return value to `Data`
266267
let binaryData: Data = try info.serializedBytes()
268+
// Resolve the `SwiftProtobufContiguousBytes` return value to `[UInt8]`
267269
let binaryDataAsBytes: [UInt8] = try info.serializedBytes()
268270

271+
// Note that while the `serializedBytes()` spelling is generally preferred,
272+
// you may also use `serializedData()` to get the bytes as an instance of
273+
// `Data` where required.
274+
// This means that the following two statements are equivalent:
275+
// let binaryData: Data = try info.serializedBytes()
276+
// let binaryData: Data = try info.serializedData()
277+
269278
// Deserialize a received Data object from `binaryData`
270279
let decodedInfo = try BookInfo(serializedData: binaryData)
271280

0 commit comments

Comments
 (0)