package pkcs11

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file p11_user_type.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
type t =
  | CKU_SO
  | CKU_USER
  | CKU_CONTEXT_SPECIFIC
  | CKU_CS_UNKNOWN of P11_ulong.t
[@@deriving eq,ord]

let to_string =
  function
  | CKU_SO  -> "CKU_SO"
  | CKU_USER  -> "CKU_USER"
  | CKU_CONTEXT_SPECIFIC  -> "CKU_CONTEXT_SPECIFIC"
  | CKU_CS_UNKNOWN x -> Unsigned.ULong.to_string x

let of_string =
  function
  | "CKU_SO" -> CKU_SO
  | "CKU_USER" -> CKU_USER
  | "CKU_CONTEXT_SPECIFIC" -> CKU_CONTEXT_SPECIFIC
  | x -> (
      try
        CKU_CS_UNKNOWN (Unsigned.ULong.of_string x)
      with
      | Sys.Break as e ->
        raise e
      | _ ->
        invalid_arg ("Pkcs11_CK_USER_TYPE.of_string: cannot find " ^ x)
    )

let to_yojson user_type =
  `String (to_string user_type)

let of_yojson = P11_helpers.of_json_string ~typename:"user type" of_string