Shell: add Data_encoding.Binary.fixed_length
This commit is contained in:
parent
22ae4dbf45
commit
5eb8d0077a
@ -1178,4 +1178,14 @@ let rec length : type x. x t -> x -> int = fun e ->
|
|||||||
let to_bytes = to_bytes
|
let to_bytes = to_bytes
|
||||||
|
|
||||||
let length = length
|
let length = length
|
||||||
|
|
||||||
|
let fixed_length e =
|
||||||
|
match classify e with
|
||||||
|
| `Fixed n -> Some n
|
||||||
|
| `Dynamic | `Variable -> None
|
||||||
|
let fixed_length_exn e =
|
||||||
|
match fixed_length e with
|
||||||
|
| Some n -> n
|
||||||
|
| None -> invalid_arg "Data_encoding.Binary.fixed_length_exn"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -236,4 +236,7 @@ module Binary : sig
|
|||||||
val to_bytes : 'a encoding -> 'a -> MBytes.t
|
val to_bytes : 'a encoding -> 'a -> MBytes.t
|
||||||
val of_bytes : 'a encoding -> MBytes.t -> 'a option
|
val of_bytes : 'a encoding -> MBytes.t -> 'a option
|
||||||
|
|
||||||
|
val fixed_length : 'a encoding -> int option
|
||||||
|
val fixed_length_exn : 'a encoding -> int
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user