This repository has no description
1(*---------------------------------------------------------------------------
2 Copyright (c) 2025 Anil Madhavapeddy. All rights reserved.
3 SPDX-License-Identifier: ISC
4 ---------------------------------------------------------------------------*)
5
6type t = {
7 email_id : Proto_id.t;
8 subject : string option;
9 preview : string option;
10}
11
12let email_id t = t.email_id
13let subject t = t.subject
14let preview t = t.preview
15
16let make email_id subject preview = { email_id; subject; preview }
17
18let jsont =
19 let kind = "SearchSnippet" in
20 (* subject and preview can be null per RFC 8621 Section 5 *)
21 Jsont.Object.map ~kind make
22 |> Jsont.Object.mem "emailId" Proto_id.jsont ~enc:email_id
23 |> Jsont.Object.mem "subject" Jsont.(option string)
24 ~dec_absent:None ~enc_omit:Option.is_none ~enc:subject
25 |> Jsont.Object.mem "preview" Jsont.(option string)
26 ~dec_absent:None ~enc_omit:Option.is_none ~enc:preview
27 |> Jsont.Object.finish