Crate libyml

source ·
Expand description

§LibYML (a fork of unsafe-libyaml)

Made With Love Crates.io lib.rs Docs.rs Codecov Build Status GitHub

LibYML is a Rust library for working with YAML data, forked from unsafe-libyaml. It offers a safe and efficient interface for parsing, emitting, and manipulating YAML data.

§Features

  • Serialization and Deserialization: Easy-to-use APIs for serializing Rust structs and enums to YAML and vice versa.
  • Custom Struct and Enum Support: Seamless serialization and deserialization of custom data types.
  • Comprehensive Error Handling: Detailed error messages and recovery mechanisms.
  • Streaming Support: Efficient processing of large YAML documents.
  • Alias and Anchor Support: Handling of complex YAML structures with references.
  • Tag Handling: Support for custom tags and type-specific serialization.
  • Configurable Emitter: Customizable YAML output generation.
  • Extensive Documentation: Detailed docs and examples for easy onboarding.
  • Safety and Efficiency: Minimized unsafe code with an interface designed to prevent common pitfalls.

§Installation

Add this to your Cargo.toml:

[dependencies]
libyml = "0.0.5"

§Documentation

For full API documentation, please visit https://doc.libyml.com/libyml/ or https://docs.rs/libyml.

§Rust Version Compatibility

Compiler support: requires rustc 1.56.0+

§Contributing

Contributions are welcome! If you’d like to contribute, please feel free to submit a Pull Request on GitHub.

§Credits and Acknowledgements

LibYML is a fork of the work done by David Tolnay and the maintainers of unsafe-libyaml. While it has evolved into a separate library, we express our sincere gratitude to them as well as the libyaml maintainers for their contributions to the Rust and C programming communities.

§License

MIT license, same as libyaml.

Re-exports§

Modules§

  • API module for LibYML.
  • Decode module for LibYML.
  • Document module for LibYML.
  • Dumper module for LibYML.
  • Extern functions and macros for interacting with the underlying libyaml C library.
  • Internal utilities for LibYML.
  • Declarations for C library functions used within the LibYML library.
  • Loader module for LibYML.
  • Macros module for LibYML.
  • Memory management for LibYML.
  • String utilities for LibYML.
  • Success and Failure types for LibYML.
  • Utility functions for LibYML.
  • YAML API module for LibYML.

Macros§

  • Converts the byte at the current pointer in the string to its corresponding integer value.
  • Converts a hexadecimal character at a given offset in a string to its corresponding integer value.
  • Deletes the buffer and frees the allocated memory.
  • Initializes a buffer with a given size.
  • A macro that checks if the current byte in the given string matches a specific octet.
  • This macro checks if the octet at the specified offset in the given string matches the provided octet.
  • Clears the content of the string by setting the pointer to the start and filling the memory from the start to the end with zeros.
  • Removes and returns the first element from the queue.
  • Enqueues a value onto the queue.
  • Checks if the current character in the string is an alphabetic character.
  • Checks if the current character in the string is an ASCII character.
  • Checks if the character at the current pointer in the given string is a space or tab character.
  • Checks if the character at the current pointer in the given string is a space, tab, line break character, or if it is a null character.
  • Checks if the character at the specified offset in the given string is a space, tab, or line break character, or if it is a null character.
  • Checks if the character at the specified offset in the given string is a space or tab character.
  • Checks if the first three bytes of the given string form the UTF-8 byte order mark (BOM) for UTF-8 encoding.
  • Checks if the character at the current pointer in the given string is a line break character.
  • Checks if the character at the current pointer in the given string is a line break character or a null character.
  • Checks if the character at the specified offset in the given string is a line break character or a null character.
  • Checks if the character at the specified offset in the given string is a line break character.
  • Checks if the character at the current pointer in the given string is a carriage return followed by a line feed.
  • Checks if the byte pointed to by the pointer in the given string is a digit (0-9).
  • Checks if the character at the given offset in the string is a hexadecimal digit.
  • Checks if the character at the current pointer in the given string is printable.
  • Checks if the character at the current pointer in the given string is a space character (ASCII 0x20).
  • Checks if the character at the specified offset in the given string is a space character (ASCII 0x20).
  • Checks if the character at the current pointer in the given string is a tab character (ASCII 0x09).
  • Checks if the character at the specified offset in the given string is a tab character (ASCII 0x09).
  • Checks if the character at the current pointer in the given string is a null character (ASCII 0).
  • Checks if the character at the specified offset in the given string is a null character (ASCII 0).
  • Joins two strings together by appending the contents of string_b to string_a.
  • Moves the pointer of the given string to the next Unicode character.
  • Removes and returns the last element from the stack.
  • Pushes a value onto the stack.
  • Deallocates the memory used by the queue and sets all pointers to null.
  • Checks if the queue is empty.
  • Initializes a queue with a specified type and allocates memory for it.
  • Inserts a value into the queue at the specified index.
  • Deallocates the memory used by the stack and sets all pointers to null.
  • Checks if the stack has no elements.
  • Initializes a stack with a specified type and allocates memory for it.
  • Checks if the stack has enough memory to push a new element.
  • Assigns a new value to a YamlStringT struct.
  • Deletes a string and frees the allocated memory.
  • Extends the capacity of a string by reallocating memory if the current capacity is insufficient.
  • Initializes a string for use with the yaml library.
  • Returns the width of the Unicode character at the current position in a string.
  • Returns the width of a Unicode character at the given offset in a string.
  • Copies the content of a string to another string.
  • Frees memory allocated by yaml_malloc! or yaml_realloc!.
  • Allocates memory using the system’s malloc function.
  • Reallocates memory using the system’s realloc function.
  • Duplicates a string using the system’s malloc function and manual copy.

Functions§