Skip to content

Instantly share code, notes, and snippets.

@vshapenko
Created December 18, 2019 12:13
Show Gist options
  • Save vshapenko/66563362bfcc575a1f4d71a50be00db3 to your computer and use it in GitHub Desktop.
Save vshapenko/66563362bfcc575a1f4d71a50be00db3 to your computer and use it in GitHub Desktop.
[<Struct>]
type TlVector< ^T when ^T:(static member decodeFrom: BytesReader -> ^T) > =
{ Data: ^T array }
static member inline decodeBodyFrom (reader: BytesReader): TlVector< ^T> =
let data =
[| 1..reader.ReadVectorSize() |]
|> Array.map (fun _ -> readFrom reader)
{ Data = data }
static member inline decodeFrom (reader: BytesReader): TlVector< ^T> =
TlVector< ^T>.decodeBodyFrom reader
static member inline decode (bytes: ArraySegment<byte>): TlVector< ^T> =
bytes |> BytesReader |> TlVector< ^T>.decodeFrom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment