{"id":13726172,"url":"https://github.com/inhabitedtype/faraday","last_synced_at":"2025-04-26T07:31:01.237Z","repository":{"id":10360948,"uuid":"65491732","full_name":"inhabitedtype/faraday","owner":"inhabitedtype","description":"Serialization library built for speed and memory efficiency","archived":false,"fork":false,"pushed_at":"2022-10-13T19:53:39.000Z","size":279,"stargazers_count":137,"open_issues_count":8,"forks_count":20,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-04T09:36:06.091Z","etag":null,"topics":["ocaml","serialization"],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inhabitedtype.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-11T18:19:00.000Z","updated_at":"2025-02-16T05:08:13.000Z","dependencies_parsed_at":"2023-01-11T17:50:31.878Z","dependency_job_id":null,"html_url":"https://github.com/inhabitedtype/faraday","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inhabitedtype%2Ffaraday","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inhabitedtype%2Ffaraday/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inhabitedtype%2Ffaraday/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inhabitedtype%2Ffaraday/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inhabitedtype","download_url":"https://codeload.github.com/inhabitedtype/faraday/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250953280,"owners_count":21513291,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ocaml","serialization"],"created_at":"2024-08-03T01:02:54.740Z","updated_at":"2025-04-26T07:31:00.968Z","avatar_url":"https://github.com/inhabitedtype.png","language":"OCaml","funding_links":[],"categories":["OCaml"],"sub_categories":[],"readme":"# Faraday\n\nFaraday is a library for writing fast and memory-efficient serializers. Its\ncore type and related operation gives the user fine-grained control over\ncopying and allocation behavior while serializing user-defined types, and\npresents the output in a form that makes it possible to use vectorized write\noperations, such as the [writev][] system call, or any other platform or\napplication-specific output APIs.\n\n\n[![Build Status](https://github.com/inhabitedtype/faraday/workflows/build/badge.svg)](https://github.com/inhabitedtype/faraday/actions?query=workflow%3A%22build%22)\n\n[writev]: http://man7.org/linux/man-pages/man2/writev.2.html\n\n## Installation\n\nInstall the library and its depenencies via [OPAM][opam]:\n\n[opam]: http://opam.ocaml.org/\n\n```bash\nopam install faraday\n```\n\n## Usage\n\nLike its sister project [Angstrom][], Faraday is written with network protocols\nand serialization formats in mind. As such, its source distribution inclues\nimplementations of various RFCs that are illustrative of real-world\napplications of the library. This includes a [JSON serializer][json].\n\n[angstrom]: https://github.com/inhabitedtype/angstrom\n[json]: https://github.com/inhabitedtype/faraday/blob/master/examples/rFC7159.ml\n\nIn addition, it's appropriate here to include a serializer for the simple\narithmetic expression language described in Angstrom's README.\n\n```ocaml\nopen Faraday\n\ntype 'a binop = [\n  | `Sub of 'a * 'a\n  | `Add of 'a * 'a\n  | `Div of 'a * 'a\n  | `Mul of 'a * 'a\n]\n;;\n\ntype t = [ `Num of int | t binop ]\n\nlet rec serialize ?(prec=0) t expr =\n  match expr with\n  | `Num n          -\u003e write_string t (Printf.sprintf \"%d\" n)\n  | #binop as binop -\u003e\n    let prec', op, l, r =\n      match binop with\n      | `Sub(l, r) -\u003e 2, '-', l, r\n      | `Add(l, r) -\u003e 3, '+', l, r\n      | `Div(l, r) -\u003e 4, '/', l, r\n      | `Mul(l, r) -\u003e 5, '*', l, r\n    in\n    if prec' \u003c prec then write_char t '(';\n    serialize t ~prec:prec' l;\n    write_char t op;\n    serialize t ~prec:prec' r;\n    if prec' \u003c prec then write_char t ')'\n\nlet to_string expr =\n  let t = create 0x1000 in\n  serialize t expr;\n  serialize_to_string t\n```\n\n## Development\n\nTo install development dependencies, pin the package from the root of the\nrepository:\n\n```bash\nopam pin add -n faraday .\nopam install --deps-only faraday\n```\n\nAfter this, you may install a development version of the library using the\ninstall command as usual.\n\nFor building and running the tests during development, you will need to install\nthe `alcotest` package:\n\n```bash\nopam install alcotest\nmake test\n```\n\n## License\n\nBSD3, see LICENSE file for its text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finhabitedtype%2Ffaraday","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finhabitedtype%2Ffaraday","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finhabitedtype%2Ffaraday/lists"}