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
- API module for LibYML.
- decode
- Decode module for LibYML.
- document
- Document module for LibYML.
- dumper
- Dumper module for LibYML.
- externs
- Extern functions and macros for interacting with the underlying libyaml C library.
- internal
- Internal utilities for LibYML.
- libc
- Declarations for C library functions used within the LibYML library.
- loader
- Loader module for LibYML.
- macros
- Macros module for LibYML.
- memory
- Memory management for LibYML.
- string
- String utilities for LibYML.
- success
- Success and Failure types for LibYML.
- utils
- Utility functions for LibYML.
- yaml
- YAML API module for LibYML.
Macros§
- AS_
DIGIT - Converts the byte at the current pointer in the string to its corresponding integer value.
- AS_
HEX_ AT - Converts a hexadecimal character at a given offset in a string to its corresponding integer value.
- BUFFER_
DEL - Deletes the buffer and frees the allocated memory.
- BUFFER_
INIT - Initializes a buffer with a given size.
- CHECK
- A macro that checks if the current byte in the given string matches a specific octet.
- CHECK_
AT - This macro checks if the octet at the specified offset in the given string matches the provided octet.
- CLEAR
- 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.
- DEQUEUE
- Removes and returns the first element from the queue.
- ENQUEUE
- Enqueues a value onto the queue.
- IS_
ALPHA - Checks if the current character in the string is an alphabetic character.
- IS_
ASCII - Checks if the current character in the string is an ASCII character.
- IS_
BLANK - Checks if the character at the current pointer in the given string is a space or tab character.
- IS_
BLANKZ - 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.
- IS_
BLANKZ_ AT - 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.
- IS_
BLANK_ AT - Checks if the character at the specified offset in the given string is a space or tab character.
- IS_BOM
- Checks if the first three bytes of the given string form the UTF-8 byte order mark (BOM) for UTF-8 encoding.
- IS_
BREAK - Checks if the character at the current pointer in the given string is a line break character.
- IS_
BREAKZ - Checks if the character at the current pointer in the given string is a line break character or a null character.
- IS_
BREAKZ_ AT - Checks if the character at the specified offset in the given string is a line break character or a null character.
- IS_
BREAK_ AT - Checks if the character at the specified offset in the given string is a line break character.
- IS_CRLF
- Checks if the character at the current pointer in the given string is a carriage return followed by a line feed.
- IS_
DIGIT - Checks if the byte pointed to by the
pointerin the given string is a digit (0-9). - IS_
HEX_ AT - Checks if the character at the given offset in the string is a hexadecimal digit.
- IS_
PRINTABLE - Checks if the character at the current pointer in the given string is printable.
- IS_
SPACE - Checks if the character at the current pointer in the given string is a space character (ASCII 0x20).
- IS_
SPACE_ AT - Checks if the character at the specified offset in the given string is a space character (ASCII 0x20).
- IS_TAB
- Checks if the character at the current pointer in the given string is a tab character (ASCII 0x09).
- IS_
TAB_ AT - Checks if the character at the specified offset in the given string is a tab character (ASCII 0x09).
- IS_Z
- Checks if the character at the current pointer in the given string is a null character (ASCII 0).
- IS_Z_AT
- Checks if the character at the specified offset in the given string is a null character (ASCII 0).
- JOIN
- Joins two strings together by appending the contents of
string_btostring_a. - MOVE
- Moves the pointer of the given string to the next Unicode character.
- POP
- Removes and returns the last element from the stack.
- PUSH
- Pushes a value onto the stack.
- QUEUE_
DEL - Deallocates the memory used by the queue and sets all pointers to null.
- QUEUE_
EMPTY - Checks if the queue is empty.
- QUEUE_
INIT - Initializes a queue with a specified type and allocates memory for it.
- QUEUE_
INSERT - Inserts a value into the queue at the specified index.
- STACK_
DEL - Deallocates the memory used by the stack and sets all pointers to null.
- STACK_
EMPTY - Checks if the stack has no elements.
- STACK_
INIT - Initializes a stack with a specified type and allocates memory for it.
- STACK_
LIMIT - Checks if the stack has enough memory to push a new element.
- STRING_
ASSIGN - Assigns a new value to a
YamlStringTstruct. - STRING_
DEL - Deletes a string and frees the allocated memory.
- STRING_
EXTEND - Extends the capacity of a string by reallocating memory if the current capacity is insufficient.
- STRING_
INIT - Initializes a string for use with the yaml library.
- WIDTH
- Returns the width of the Unicode character at the current position in a string.
- WIDTH_
AT - Returns the width of a Unicode character at the given offset in a string.
- copy
- Copies the content of a string to another string.
- yaml_
free - Frees memory allocated by
yaml_malloc!oryaml_realloc!. - yaml_
malloc - Allocates memory using the system’s
mallocfunction. - yaml_
realloc - Reallocates memory using the system’s
reallocfunction. - yaml_
strdup - Duplicates a string using the system’s
mallocfunction and manual copy.
Functions§
- yaml_
emitter_ ⚠emit - Emit an event.
- yaml_
emitter_ ⚠flush - Flushes the buffer of the emitter and writes the content to the output stream.
- yaml_
parser_ ⚠parse - Parse the input stream and produce the next parsing event.
- yaml_
parser_ ⚠scan - Scan the input stream and produce the next token.