Comments (3)
Protobuf serializable Record definition
module SampleNamespace =
open System
open Froto.Serialization
open Froto.Serialization.Serializer
open Froto.Serialization.Encoding
type ETest =
| Nada = 0
| One = 1
| Two = 2
let ETestDefault = ETest.One // NOTE: Non-zero default is only supported in Proto2
type InnerSample = {
id : int32
name : string
option : bool
test : ETest
packedFixed32 : uint32 list
repeatedInt32 : int32 list
_unknownFields : RawField list
_foundFields : Set<FieldNum>
}
with
static member Default = {
id=0
name=""
option=false
test=ETest.Nada
packedFixed32=[]
repeatedInt32=[]
_unknownFields=List.empty
_foundFields=Set.empty
}
static member Serializer (m, zcb) =
(m.id |> Encode.fromVarint 1) >>
(m.name |> Encode.fromString 2) >>
(m.option |> Encode.fromBool 3) >>
(m.test |> Encode.fromDefaultedVarint ETestDefault 4) >>
(m.packedFixed32 |> Encode.fromPackedFixed32 5) >>
(m.repeatedInt32 |> Encode.fromRepeated Encode.fromVarint 6) >>
(m._unknownFields |> Encode.fromRawFields )
<| zcb
static member DecoderRing =
[
0, fun m rawField -> { m with _unknownFields = rawField :: m._unknownFields }
1, fun m rawField -> { m with id = rawField |> Decode.toInt32 } : InnerSample
2, fun m rawField -> { m with name = rawField |> Decode.toString } : InnerSample
3, fun m rawField -> { m with option = rawField |> Decode.toBool } : InnerSample
4, fun m rawField -> { m with test = rawField |> Decode.toEnum } : InnerSample
5, fun m rawField -> { m with packedFixed32 = rawField |> Decode.toPackedFixed32 } : InnerSample
6, fun m rawField -> { m with repeatedInt32 = (rawField |> Decode.toInt32) :: m.repeatedInt32 } : InnerSample
]
|> Map.ofList
static member RememberFound (m,found) =
{ m with _foundFields = m._foundFields |> Set.add found }
static member DecodeFixup m =
{ m with
packedFixed32 = List.rev m.packedFixed32
repeatedInt32 = List.rev m.repeatedInt32
_unknownFields = List.rev m._unknownFields }
static member RequiredFields =
[ 1; 2 ] |> Set.ofList
static member FoundFields m =
m._foundFields
static member UnknownFields m =
m._unknownFields
from froto.
This makes me really happy to see this!
from froto.
Fixed in #39
from froto.
Related Issues (20)
- PulsarApi.proto HOT 3
- need stable CI builds on master HOT 5
- new maintainer please HOT 4
- Parse error when optional/required/repeated is missing HOT 3
- Support for proto3? HOT 1
- Span<T> HOT 4
- Are there any plans for a proto3 canonical json serialization? HOT 1
- Are the methods mentioned in Serialization.fs currently consumed anywhere in code? HOT 1
- UnknownFields in the serializer seems to be unused, can this be removed or is it unimplemented? HOT 14
- Proto2 required fields are not properly serialized HOT 1
- Would it be possible to get a 0.51 nuget release of the parser and serializer? HOT 21
- Proto3 oneOf type does not parse HOT 4
- gRPC on top of ASP.NET Core 3.0 HOT 4
- Add interface implementation of IMessage to Froto.Serialiation to make code gen have less dependencies HOT 6
- Enum in message body error HOT 4
- Allow identifiers to start with underscore HOT 1
- SourceLink seems to fail while building HOT 3
- position in ProtoField are defined differently
- gRPC on Alpine docker requires libc6-compat
- Make TP work with .NET Core tooling HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from froto.