{"id":18754830,"url":"https://github.com/visa/ttlv","last_synced_at":"2025-09-01T12:31:42.806Z","repository":{"id":163849780,"uuid":"224345967","full_name":"visa/ttlv","owner":"visa","description":null,"archived":false,"fork":false,"pushed_at":"2020-07-23T17:45:07.000Z","size":9,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-11-07T17:43:39.819Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/visa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-27T04:43:24.000Z","updated_at":"2024-07-18T14:40:37.000Z","dependencies_parsed_at":"2023-07-06T19:00:29.141Z","dependency_job_id":null,"html_url":"https://github.com/visa/ttlv","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/visa%2Fttlv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/visa%2Fttlv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/visa%2Fttlv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/visa%2Fttlv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/visa","download_url":"https://codeload.github.com/visa/ttlv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231693341,"owners_count":18411890,"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":[],"created_at":"2024-11-07T17:30:11.487Z","updated_at":"2024-12-29T01:30:21.880Z","avatar_url":"https://github.com/visa.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ttlv\n\nTTLV (tag-type-length-value) encoding scheme, which is used in KMIP (Key Management Interoperability Protocol), is a variant of the more popular TLV (tag-length-value) encoding scheme. This `#![no_std]` crate provides fast and safe TTLV encoding/decoding.\n\nFrom OASIS KMIP spec v2.0:\n\u003e The scheme is designed to minimize the CPU cycle and memory requirements of clients that need to encode or decode protocol messages, and to provide optimal alignment for both 32-bit and 64-bit processors. Minimizing bandwidth over the transport mechanism is considered to be of lesser importance.\n\nTTLV spec: \u003chttps://docs.oasis-open.org/kmip/kmip-spec/v2.0/cs01/kmip-spec-v2.0-cs01.html#_Toc6497650\u003e\n\n## Usage\n\n```rust\nuse ttlv::{Ttlv, Value::*};\nuse num_derive::{FromPrimitive, ToPrimitive};\n\n#[derive(Copy, Clone, PartialEq, Debug, FromPrimitive, ToPrimitive)]\npub enum Tag {\n    Request,\n    RequestHeader,\n    ProtocolVersion,\n    RequestBody,\n}\n\n// Construct TTLV message\nlet message: Ttlv = Ttlv::new(Tag::Request, Structure(vec![\n    Ttlv::new(Tag::RequestHeader, Structure(vec![\n        Ttlv::new(Tag::ProtocolVersion, Integer(6)),\n    ])),\n    Ttlv::new(Tag::RequestBody, TextString(\"message body\")),\n]));\n\n// Encode TTLV message\nlet encoded = \u0026mut [0u8; 1000];\nlet encoded_len = message.encode(encoded)?;\n\n// Decode TTLV message\nlet (decoded, decoded_len) = Ttlv::decode(encoded)?;\n\n// Collect data from decoded message using path\nlet version: i32 = decoded.path(\u0026[Tag::RequestHeader, Tag::ProtocolVersion])?.value()?;\nlet message_body: \u0026str = decoded.path(\u0026[Tag::RequestBody])?.value()?;\n```\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0\n   ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license\n   ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvisa%2Fttlv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvisa%2Fttlv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvisa%2Fttlv/lists"}