Expand description
§LibYML (a fork of unsafe-libyaml)
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§
pub use crate::api::yaml_alias_event_initialize;pub use crate::api::yaml_emitter_delete;pub use crate::api::yaml_emitter_initialize;pub use crate::api::yaml_emitter_set_break;pub use crate::api::yaml_emitter_set_canonical;pub use crate::api::yaml_emitter_set_encoding;pub use crate::api::yaml_emitter_set_indent;pub use crate::api::yaml_emitter_set_output;pub use crate::api::yaml_emitter_set_output_string;pub use crate::api::yaml_emitter_set_unicode;pub use crate::api::yaml_emitter_set_width;pub use crate::api::yaml_event_delete;pub use crate::api::yaml_mapping_end_event_initialize;pub use crate::api::yaml_mapping_start_event_initialize;pub use crate::api::yaml_parser_set_encoding;pub use crate::api::yaml_parser_set_input;pub use crate::api::yaml_parser_set_input_string;pub use crate::api::yaml_scalar_event_initialize;pub use crate::api::yaml_sequence_end_event_initialize;pub use crate::api::yaml_sequence_start_event_initialize;pub use crate::api::yaml_stream_end_event_initialize;pub use crate::api::yaml_stream_start_event_initialize;pub use crate::api::yaml_token_delete;pub use crate::decode::yaml_parser_delete;pub use crate::decode::yaml_parser_initialize;pub use crate::document::yaml_document_delete;pub use crate::document::yaml_document_get_node;pub use crate::document::yaml_document_get_root_node;pub use crate::document::yaml_document_initialize;pub use crate::dumper::yaml_emitter_close;pub use crate::dumper::yaml_emitter_dump;pub use crate::dumper::yaml_emitter_open;pub use crate::loader::yaml_parser_load;pub use crate::yaml::YamlAliasDataT;pub use crate::yaml::YamlBreakT;pub use crate::yaml::YamlDocumentT;pub use crate::yaml::YamlEmitterStateT;pub use crate::yaml::YamlEmitterT;pub use crate::yaml::YamlEncodingT;pub use crate::yaml::YamlErrorTypeT;pub use crate::yaml::YamlEventT;pub use crate::yaml::YamlEventTypeT;pub use crate::yaml::YamlMappingStyleT;pub use crate::yaml::YamlMarkT;pub use crate::yaml::YamlNodeItemT;pub use crate::yaml::YamlNodePairT;pub use crate::yaml::YamlNodeT;pub use crate::yaml::YamlNodeTypeT;pub use crate::yaml::YamlParserStateT;pub use crate::yaml::YamlParserT;pub use crate::yaml::YamlReadHandlerT;pub use crate::yaml::YamlScalarStyleT;pub use crate::yaml::YamlSequenceStyleT;pub use crate::yaml::YamlSimpleKeyT;pub use crate::yaml::YamlStackT;pub use crate::yaml::YamlTagDirectiveT;pub use crate::yaml::YamlTokenT;pub use crate::yaml::YamlTokenTypeT;pub use crate::yaml::YamlVersionDirectiveT;pub use crate::yaml::YamlWriteHandlerT;
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
pointerin 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_btostring_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
YamlStringTstruct. - 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!oryaml_realloc!. - Allocates memory using the system’s
mallocfunction. - Reallocates memory using the system’s
reallocfunction. - Duplicates a string using the system’s
mallocfunction and manual copy.
Functions§
- Emit an event.
- Flushes the buffer of the emitter and writes the content to the output stream.
- Parse the input stream and produce the next parsing event.
- Scan the input stream and produce the next token.