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 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
|
||||
|
@ -236,4 +236,7 @@ module Binary : sig
|
||||
val to_bytes : 'a encoding -> 'a -> MBytes.t
|
||||
val of_bytes : 'a encoding -> MBytes.t -> 'a option
|
||||
|
||||
val fixed_length : 'a encoding -> int option
|
||||
val fixed_length_exn : 'a encoding -> int
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user