@@ -64,24 +64,6 @@ defmodule Protobuf do
6464
6565 @ behaviour Protobuf
6666
67- @ deprecated "Build the struct by hand with %MyMessage{...} or use struct/1"
68- @ impl unquote ( __MODULE__ )
69- def new ( ) do
70- Protobuf.Builder . new ( __MODULE__ )
71- end
72-
73- @ deprecated "Build the struct by hand with %MyMessage{...} or use struct/2"
74- @ impl unquote ( __MODULE__ )
75- def new ( attrs ) do
76- Protobuf.Builder . new ( __MODULE__ , attrs )
77- end
78-
79- @ deprecated "Build the struct by hand with %MyMessage{...} or use struct!/2"
80- @ impl unquote ( __MODULE__ )
81- def new! ( attrs ) do
82- Protobuf.Builder . new! ( __MODULE__ , attrs )
83- end
84-
8567 @ impl unquote ( __MODULE__ )
8668 def transform_module ( ) do
8769 nil
@@ -98,59 +80,6 @@ defmodule Protobuf do
9880 end
9981 end
10082
101- @ doc """
102- Builds a blank struct with default values.
103-
104- > #### Deprecated {: .warning}
105- >
106- > This is deprecated in favor of building the struct with `%MyMessage{...}` or using
107- > `struct/1`.
108-
109- """
110- @ callback new ( ) :: struct ( )
111-
112- @ doc """
113- Builds and updates the struct with passed fields.
114-
115- This function will:
116-
117- * Recursively call `c:new/1` for embedded fields
118- * Create structs using `struct/2` for keyword lists and maps
119- * Create the correct struct if passed the wrong struct
120- * Call `c:new/1` for each element in the list for repeated fields
121-
122- > #### Deprecated {: .warning}
123- > This is deprecated in favor of building the struct with `%MyMessage{...}` or using
124- > `struct/2`.
125-
126- ## Examples
127-
128- MyMessage.new(field1: "foo")
129- #=> %MyMessage{field1: "foo", ...}
130-
131- MyMessage.new(field1: [field2: "foo"])
132- #=> %MyMessage{field1: %MySubMessage{field2: "foo"}}
133-
134- MyMessage.new(field1: %WrongStruct{field2: "foo"})
135- #=> %MyMessage{field1: %MySubMessage{field2: "foo"}}
136-
137- MyMessage.new(repeated: [%{field1: "foo"}, %{field1: "bar"}])
138- #=> %MyMessage{repeated: [%MyRepeated{field1: "foo"}, %MyRepeated{field1: "bar"}]}
139-
140- """
141- @ callback new ( attributes :: Enum . t ( ) ) :: struct
142-
143- @ doc """
144- Similar to `c:new/1`, but use `struct!/2` to build the struct, so
145- errors will be raised if unknown keys are passed.
146-
147- > #### Deprecated {: .warning}
148- > This is deprecated in favor of building the struct with `%MyMessage{...}` or using
149- > `struct!/2` directly.
150-
151- """
152- @ callback new! ( attributes :: Enum . t ( ) ) :: struct ( )
153-
15483 @ doc """
15584 Encodes the given struct into to a Protobuf binary.
15685
@@ -253,7 +182,7 @@ defmodule Protobuf do
253182
254183 You encode this:
255184
256- payload = Protobuf.encode(User.new!( email: "user@example.com") )
185+ payload = Protobuf.encode(% User{ email: "user@example.com"} )
257186 #=> <<...>>
258187
259188 Now, you try to decode this payload using this schema instead:
0 commit comments