MessagePack.FSharpExtensions 4.0.0
MessagePack.FSharpExtensions
MessagePack.FSharpExtensions is a MessagePack-CSharp extension library for F#.
Usage
open System
open System.Buffers
open MessagePack
open MessagePack.Resolvers
open MessagePack.FSharp
[<MessagePackObject>]
type UnionSample =
| Foo of XYZ : int
| Bar of OPQ : string list
let convertAsMemory<'T> options (value: 'T) =
let memory = ReadOnlyMemory(MessagePackSerializer.Serialize(value, options))
MessagePackSerializer.Deserialize<'T>(memory, options)
let convertAsSequence<'T> options (value: 'T) =
let sequence = ReadOnlySequence(MessagePackSerializer.Serialize(value, options))
MessagePackSerializer.Deserialize<'T>(& sequence, options)
let dump = function
| Foo x ->
printfn "%d" x
| Bar xs ->
printfn "%A" xs
let resolver =
Resolvers.CompositeResolver.Create(
FSharpResolver.Instance,
StandardResolver.Instance
)
let options = MessagePackSerializerOptions.Standard.WithResolver(resolver)
Foo 999
|> convertAsMemory options
|> dump
Bar ["example"]
|> convertAsSequence options
|> dump
Supported types
- option
- voption
- list
- map
- set
- Discriminated Union
- Struct Discriminated Union
Records, Struct Records and Anonymous Records are serialized and deserialized using DynamicObjectResolver
in MessagePack-CSharp
.
Showing the top 20 packages that depend on MessagePack.FSharpExtensions.
Packages | Downloads |
---|---|
NBomber.Contracts
Public contracts for NBomber
|
3 |
NBomber.Contracts
Contracts for NBomber
|
3 |
NBomber.Contracts
Public contracts for NBomber
|
2 |
.NET Core 3.1
- FSharp.Core (>= 7.0.200)
- MessagePack (>= 2.4.59)
.NET 6.0
- FSharp.Core (>= 7.0.200)
- MessagePack (>= 2.4.59)
.NET Standard 2.0
- FSharp.Core (>= 7.0.200)
- MessagePack (>= 2.4.59)