Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add partial support to the binary decoding initializer. #290

Merged
merged 2 commits into from
Feb 22, 2017

Conversation

thomasvl
Copy link
Collaborator

Also add tests to confirm partial and full decoding work as
expected.

@thomasvl
Copy link
Collaborator Author

Added second commit with docs.

@thomasvl thomasvl force-pushed the partial_decode branch 2 times, most recently from 4939b2d to af68441 Compare February 21, 2017 22:39
@@ -268,7 +268,20 @@ public extension Message {
return visitor.serializedSize
}

init(serializedData data: Data, extensions: ExtensionSet? = nil) throws {
/// Initializes the message by decoding the Protocol Buffer binary serialization
/// format into for this message.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove "into"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

/// format into for this message.
///
/// - Parameters:
/// - serializedData: The binary serialation data to decode.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/serialation/serialization/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

///
/// - Parameters:
/// - serializedData: The binary serialation data to decode.
/// - extensions: An `ExtensionSet` to log up and decode any extensions in this
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/log/look/?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, done.

/// - Parameters:
/// - serializedData: The binary serialation data to decode.
/// - extensions: An `ExtensionSet` to log up and decode any extensions in this
/// message or message nested within this message's fields.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"message or messages nested" (add "s")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

/// - serializedData: The binary serialation data to decode.
/// - extensions: An `ExtensionSet` to log up and decode any extensions in this
/// message or message nested within this message's fields.
/// - partial: The binary serialization format requires all `required` fields
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"By default, the binary serialization format..."

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

/// message or message nested within this message's fields.
/// - partial: The binary serialization format requires all `required` fields
/// be present; when `partial` is `false`,
/// `BinaryDecodingError.missingRequiredFields` is throw if any were missing.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/throw/thrown/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

/// be present; when `partial` is `false`,
/// `BinaryDecodingError.missingRequiredFields` is throw if any were missing.
/// When `partial` is `true`, then partial messages are allowed, and
/// `Message.isRequired` is not checked.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/isRequired/isInitialized/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh.

/// `BinaryDecodingError.missingRequiredFields` is throw if any were missing.
/// When `partial` is `true`, then partial messages are allowed, and
/// `Message.isRequired` is not checked.
/// - Throws: An instance of `BinaryDecodingError` on failure .
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove space before period

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -23,4 +23,8 @@ public enum BinaryDecodingError: Error {
case malformedProtobuf
/// The data being parsed does not match the type specified in the proto file
case schemaMismatch
/// The message or sub messages definitions have required fields, and the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/sub/nested/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@thomasvl thomasvl merged commit 758cafd into apple:master Feb 22, 2017
@thomasvl thomasvl deleted the partial_decode branch February 22, 2017 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants