My agentic slop goes here. Not intended for anyone else!
1# JMAP Unix Implementation 2 3This library provides Unix-specific implementation for the core JMAP protocol. 4 5## Overview 6 7Jmap_unix provides the implementation needed to make actual connections to JMAP servers 8using OCaml's Unix module. It handles: 9 10- HTTP connections to JMAP endpoints 11- Authentication 12- Session discovery 13- Request/response handling 14- Blob upload/download 15- High-level email operations (Jmap_unix.Email) 16 17## Usage 18 19```ocaml 20open Jmap 21open Jmap_unix 22 23(* Create a connection to a JMAP server *) 24let connect_example env = 25 let ctx = Jmap_unix.create_client () in 26 match Jmap_unix.quick_connect env ~host:"jmap.example.com" ~username:"user" ~password:"pass" () with 27 | Ok (ctx, session) -> 28 (* Use the connection for JMAP requests *) 29 let builder = Jmap_unix.build ctx in 30 let builder = Jmap_unix.using builder [`Core] in 31 (* ... add method calls ... *) 32 let response = Jmap_unix.execute env builder in 33 ignore (Jmap_unix.close ctx) 34 | Error err -> 35 Printf.eprintf "Connection failed: %s\n" (Jmap.Error.to_string err) 36``` 37 38## Email Operations 39 40The Email module provides high-level operations for working with emails: 41 42```ocaml 43open Jmap 44open Jmap_unix 45 46(* Get an email *) 47let get_email_example env ctx account_id email_id = 48 match Email.get_email env ctx ~account_id ~email_id () with 49 | Ok email -> Printf.printf "Got email: %s\n" (Jmap_email.Email.subject email) 50 | Error err -> Printf.eprintf "Error: %s\n" (Jmap.Error.to_string err) 51 52(* Search for unread emails *) 53let search_unread env ctx account_id = 54 let filter = Jmap.Methods.Filter.(["hasKeyword", `String "$unseen"]) in 55 match Email.search_emails env ctx ~account_id ~filter () with 56 | Ok (ids, Some emails) -> Printf.printf "Found %d unread emails\n" (List.length emails) 57 | Ok (ids, None) -> Printf.printf "Found %d unread email IDs\n" (List.length ids) 58 | Error err -> Printf.eprintf "Search error: %s\n" (Jmap.Error.to_string err) 59 60(* Mark emails as read *) 61let mark_read env ctx account_id email_ids = 62 match Email.mark_as_seen env ctx ~account_id ~email_ids () with 63 | Ok () -> Printf.printf "Marked %d emails as read\n" (List.length email_ids) 64 | Error err -> Printf.eprintf "Mark error: %s\n" (Jmap.Error.to_string err) 65``` 66 67## Dependencies 68 69- jmap (core library) 70- jmap-email (email types and helpers) 71- eio (structured concurrency) 72- tls-eio (TLS support) 73- cohttp-eio (HTTP client) 74- yojson (JSON handling) 75- uri (URL parsing)