Skip to content

Commit e52dd87

Browse files
authored
Update PLUGIN.md
1 parent de3bc2b commit e52dd87

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Documentation/PLUGIN.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,25 @@ exposed via public API, so even if `ImplementationOnlyImports` is set to `true`,
182182
this will only work if the `Visibility` is set to `internal`.
183183

184184

185+
##### Generation Option: `Applying` - Apply unsafe values to proto models
186+
187+
Using this option, all generated proto models will conform to `_ApplyingProtocol`.
188+
This protocol requires `func applying(_ value, fieldNumber)` which enables us modify
189+
a field's value only by it's `fieldNumber`. For instance, if this option is enabled,
190+
it's possible to make a copy of a particular message with modifiying some of its
191+
fields using the code below.
192+
193+
```swift
194+
let new = try message
195+
.applying(value1, for: 1)
196+
.applying(value2, for: 2)
197+
```
198+
199+
This code creates a new model which some of its fields (mapped fields 1 and 2 in
200+
proto model) has been modified. Notice that this is a throwing function and if
201+
there's any problem with the applying, it will throw a `ProtoApplyingError` error.
202+
203+
185204
### Building your project
186205

187206
After copying the `.pb.swift` files into your project, you will need

0 commit comments

Comments
 (0)