mirror of
https://github.com/simonask/libyaml-safer
synced 2025-02-16 20:38:30 +00:00
Fix intra-doc links
This commit is contained in:
parent
d64879c3f1
commit
784b874007
8 changed files with 48 additions and 39 deletions
|
@ -10,7 +10,8 @@ use crate::{
|
|||
|
||||
/// Start a YAML stream.
|
||||
///
|
||||
/// This function should be used before [`yaml_emitter_dump()`] is called.
|
||||
/// This function should be used before
|
||||
/// [`yaml_emitter_dump()`](crate::yaml_emitter_dump) is called.
|
||||
pub fn yaml_emitter_open(emitter: &mut Emitter) -> Result<(), EmitterError> {
|
||||
assert!(!emitter.opened);
|
||||
let event = Event {
|
||||
|
@ -24,7 +25,8 @@ pub fn yaml_emitter_open(emitter: &mut Emitter) -> Result<(), EmitterError> {
|
|||
|
||||
/// Finish a YAML stream.
|
||||
///
|
||||
/// This function should be used after [`yaml_emitter_dump()`] is called.
|
||||
/// This function should be used after
|
||||
/// [`yaml_emitter_dump()`](crate::yaml_emitter_dump) is called.
|
||||
pub fn yaml_emitter_close(emitter: &mut Emitter) -> Result<(), EmitterError> {
|
||||
assert!(emitter.opened);
|
||||
if emitter.closed {
|
||||
|
@ -41,8 +43,9 @@ pub fn yaml_emitter_close(emitter: &mut Emitter) -> Result<(), EmitterError> {
|
|||
|
||||
/// Emit a YAML document.
|
||||
///
|
||||
/// The document object may be generated using the [`yaml_parser_load()`] function
|
||||
/// or the [`yaml_document_new()`] function.
|
||||
/// The document object may be generated using the
|
||||
/// [`yaml_parser_load()`](crate::yaml_parser_load) function or the
|
||||
/// [`yaml_document_new()`](crate::yaml_document_new) function.
|
||||
pub fn yaml_emitter_dump(
|
||||
emitter: &mut Emitter,
|
||||
mut document: Document,
|
||||
|
|
|
@ -111,10 +111,10 @@ fn yaml_emitter_set_emitter_error<T>(
|
|||
|
||||
/// Emit an event.
|
||||
///
|
||||
/// The event object may be generated using the [`yaml_parser_parse()`] function.
|
||||
/// The emitter takes the responsibility for the event object and destroys its
|
||||
/// content after it is emitted. The event object is destroyed even if the
|
||||
/// function fails.
|
||||
/// The event object may be generated using the
|
||||
/// [`yaml_parser_parse()`](crate::yaml_parser_parse) function. The emitter
|
||||
/// takes the responsibility for the event object and destroys its content after
|
||||
/// it is emitted. The event object is destroyed even if the function fails.
|
||||
pub fn yaml_emitter_emit(emitter: &mut Emitter, event: Event) -> Result<(), EmitterError> {
|
||||
emitter.events.push_back(event);
|
||||
while let Some(event) = yaml_emitter_needs_mode_events(emitter) {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
clippy::unnecessary_wraps,
|
||||
clippy::match_wildcard_for_single_variants
|
||||
)]
|
||||
#![deny(unsafe_code)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
|
|
|
@ -15,9 +15,11 @@ use crate::{
|
|||
/// If the produced document has no root node, it means that the document end
|
||||
/// has been reached.
|
||||
///
|
||||
/// An application must not alternate the calls of [`yaml_parser_load()`] with
|
||||
/// the calls of [`yaml_parser_scan()`] or [`yaml_parser_parse()`]. Doing this
|
||||
/// will break the parser.
|
||||
/// An application must not alternate the calls of
|
||||
/// [`yaml_parser_load()`](crate::yaml_parser_load) with the calls of
|
||||
/// [`yaml_parser_scan()`](crate::yaml_parser_scan) or
|
||||
/// [`yaml_parser_parse()`](crate::yaml_parser_parse). Doing this will break the
|
||||
/// parser.
|
||||
pub fn yaml_parser_load(parser: &mut Parser) -> Result<Document, ComposerError> {
|
||||
let mut document = yaml_document_new(None, &[], false, false);
|
||||
document.nodes.reserve(16);
|
||||
|
|
|
@ -59,12 +59,14 @@ fn SKIP_TOKEN(parser: &mut Parser) {
|
|||
///
|
||||
/// Call the function subsequently to produce a sequence of events corresponding
|
||||
/// to the input stream. The initial event has the type
|
||||
/// [`EventData::StreamStart`] while the ending event has the type
|
||||
/// [`EventData::StreamEnd`].
|
||||
/// [`EventData::StreamStart`](crate::EventData::StreamStart) while the ending
|
||||
/// event has the type [`EventData::StreamEnd`](crate::EventData::StreamEnd).
|
||||
///
|
||||
/// An application must not alternate the calls of [`yaml_parser_parse()`] with
|
||||
/// the calls of [`yaml_parser_scan()`] or [`yaml_parser_load()`]. Doing this
|
||||
/// will break the parser.
|
||||
/// An application must not alternate the calls of
|
||||
/// [`yaml_parser_parse()`](crate::yaml_parser_parse) with the calls of
|
||||
/// [`yaml_parser_scan()`](crate::yaml_parser_scan) or
|
||||
/// [`yaml_parser_load()`](crate::yaml_parser_load). Doing this will break the
|
||||
/// parser.
|
||||
pub fn yaml_parser_parse(parser: &mut Parser) -> Result<Event, ParserError> {
|
||||
if parser.stream_end_produced || parser.state == ParserState::End {
|
||||
return Ok(Event {
|
||||
|
|
|
@ -53,6 +53,7 @@ fn yaml_parser_determine_encoding(
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn read_utf8_buffered(
|
||||
reader: &mut dyn BufRead,
|
||||
out: &mut VecDeque<char>,
|
||||
|
@ -93,11 +94,9 @@ fn read_utf8_buffered(
|
|||
}
|
||||
|
||||
match err.error_len() {
|
||||
Some(_invalid_len) => {
|
||||
Err(ReaderError::InvalidUtf8 {
|
||||
value: available[valid_bytes],
|
||||
})
|
||||
}
|
||||
Some(_invalid_len) => Err(ReaderError::InvalidUtf8 {
|
||||
value: available[valid_bytes],
|
||||
}),
|
||||
None => {
|
||||
if valid_bytes != 0 {
|
||||
// Some valid UTF-8 characters were present, and the
|
||||
|
|
|
@ -84,12 +84,14 @@ fn READ_LINE_STRING(parser: &mut Parser, string: &mut String) {
|
|||
///
|
||||
/// Call the function subsequently to produce a sequence of tokens corresponding
|
||||
/// to the input stream. The initial token has the type
|
||||
/// [`TokenData::StreamStart`] while the ending token has the type
|
||||
/// [`TokenData::StreamEnd`].
|
||||
/// [`TokenData::StreamStart`](crate::TokenData::StreamStart) while the ending
|
||||
/// token has the type [`TokenData::StreamEnd`](crate::TokenData::StreamEnd).
|
||||
///
|
||||
/// An application must not alternate the calls of [`yaml_parser_scan()`] with
|
||||
/// the calls of [`yaml_parser_parse()`] or [`yaml_parser_load()`]. Doing this
|
||||
/// will break the parser.
|
||||
/// An application must not alternate the calls of
|
||||
/// [`yaml_parser_scan()`](crate::yaml_parser_scan) with the calls of
|
||||
/// [`yaml_parser_parse()`](crate::yaml_parser_parse) or
|
||||
/// [`yaml_parser_load()`](crate::yaml_parser_load). Doing this will break the
|
||||
/// parser.
|
||||
pub fn yaml_parser_scan(parser: &mut Parser) -> Result<Token, ScannerError> {
|
||||
if parser.stream_end_produced {
|
||||
return Ok(Token {
|
||||
|
|
26
src/yaml.rs
26
src/yaml.rs
|
@ -217,7 +217,7 @@ pub enum TokenData {
|
|||
impl TokenData {
|
||||
/// Returns `true` if the yaml token data is [`VersionDirective`].
|
||||
///
|
||||
/// [`VersionDirective`]: YamlTokenData::VersionDirective
|
||||
/// [`VersionDirective`]: TokenData::VersionDirective
|
||||
#[must_use]
|
||||
pub fn is_version_directive(&self) -> bool {
|
||||
matches!(self, Self::VersionDirective { .. })
|
||||
|
@ -225,7 +225,7 @@ impl TokenData {
|
|||
|
||||
/// Returns `true` if the yaml token data is [`TagDirective`].
|
||||
///
|
||||
/// [`TagDirective`]: YamlTokenData::TagDirective
|
||||
/// [`TagDirective`]: TokenData::TagDirective
|
||||
#[must_use]
|
||||
pub fn is_tag_directive(&self) -> bool {
|
||||
matches!(self, Self::TagDirective { .. })
|
||||
|
@ -233,7 +233,7 @@ impl TokenData {
|
|||
|
||||
/// Returns `true` if the yaml token data is [`DocumentStart`].
|
||||
///
|
||||
/// [`DocumentStart`]: YamlTokenData::DocumentStart
|
||||
/// [`DocumentStart`]: TokenData::DocumentStart
|
||||
#[must_use]
|
||||
pub fn is_document_start(&self) -> bool {
|
||||
matches!(self, Self::DocumentStart)
|
||||
|
@ -241,7 +241,7 @@ impl TokenData {
|
|||
|
||||
/// Returns `true` if the yaml token data is [`StreamEnd`].
|
||||
///
|
||||
/// [`StreamEnd`]: YamlTokenData::StreamEnd
|
||||
/// [`StreamEnd`]: TokenData::StreamEnd
|
||||
#[must_use]
|
||||
pub fn is_stream_end(&self) -> bool {
|
||||
matches!(self, Self::StreamEnd)
|
||||
|
@ -249,7 +249,7 @@ impl TokenData {
|
|||
|
||||
/// Returns `true` if the yaml token data is [`BlockEntry`].
|
||||
///
|
||||
/// [`BlockEntry`]: YamlTokenData::BlockEntry
|
||||
/// [`BlockEntry`]: TokenData::BlockEntry
|
||||
#[must_use]
|
||||
pub fn is_block_entry(&self) -> bool {
|
||||
matches!(self, Self::BlockEntry)
|
||||
|
@ -257,7 +257,7 @@ impl TokenData {
|
|||
|
||||
/// Returns `true` if the yaml token data is [`BlockSequenceStart`].
|
||||
///
|
||||
/// [`BlockSequenceStart`]: YamlTokenData::BlockSequenceStart
|
||||
/// [`BlockSequenceStart`]: TokenData::BlockSequenceStart
|
||||
#[must_use]
|
||||
pub fn is_block_sequence_start(&self) -> bool {
|
||||
matches!(self, Self::BlockSequenceStart)
|
||||
|
@ -265,7 +265,7 @@ impl TokenData {
|
|||
|
||||
/// Returns `true` if the yaml token data is [`BlockMappingStart`].
|
||||
///
|
||||
/// [`BlockMappingStart`]: YamlTokenData::BlockMappingStart
|
||||
/// [`BlockMappingStart`]: TokenData::BlockMappingStart
|
||||
#[must_use]
|
||||
pub fn is_block_mapping_start(&self) -> bool {
|
||||
matches!(self, Self::BlockMappingStart)
|
||||
|
@ -273,7 +273,7 @@ impl TokenData {
|
|||
|
||||
/// Returns `true` if the yaml token data is [`BlockEnd`].
|
||||
///
|
||||
/// [`BlockEnd`]: YamlTokenData::BlockEnd
|
||||
/// [`BlockEnd`]: TokenData::BlockEnd
|
||||
#[must_use]
|
||||
pub fn is_block_end(&self) -> bool {
|
||||
matches!(self, Self::BlockEnd)
|
||||
|
@ -281,7 +281,7 @@ impl TokenData {
|
|||
|
||||
/// Returns `true` if the yaml token data is [`Key`].
|
||||
///
|
||||
/// [`Key`]: YamlTokenData::Key
|
||||
/// [`Key`]: TokenData::Key
|
||||
#[must_use]
|
||||
pub fn is_key(&self) -> bool {
|
||||
matches!(self, Self::Key)
|
||||
|
@ -289,7 +289,7 @@ impl TokenData {
|
|||
|
||||
/// Returns `true` if the yaml token data is [`Value`].
|
||||
///
|
||||
/// [`Value`]: YamlTokenData::Value
|
||||
/// [`Value`]: TokenData::Value
|
||||
#[must_use]
|
||||
pub fn is_value(&self) -> bool {
|
||||
matches!(self, Self::Value)
|
||||
|
@ -297,7 +297,7 @@ impl TokenData {
|
|||
|
||||
/// Returns `true` if the yaml token data is [`FlowSequenceEnd`].
|
||||
///
|
||||
/// [`FlowSequenceEnd`]: YamlTokenData::FlowSequenceEnd
|
||||
/// [`FlowSequenceEnd`]: TokenData::FlowSequenceEnd
|
||||
#[must_use]
|
||||
pub fn is_flow_sequence_end(&self) -> bool {
|
||||
matches!(self, Self::FlowSequenceEnd)
|
||||
|
@ -305,7 +305,7 @@ impl TokenData {
|
|||
|
||||
/// Returns `true` if the yaml token data is [`FlowEntry`].
|
||||
///
|
||||
/// [`FlowEntry`]: YamlTokenData::FlowEntry
|
||||
/// [`FlowEntry`]: TokenData::FlowEntry
|
||||
#[must_use]
|
||||
pub fn is_flow_entry(&self) -> bool {
|
||||
matches!(self, Self::FlowEntry)
|
||||
|
@ -313,7 +313,7 @@ impl TokenData {
|
|||
|
||||
/// Returns `true` if the yaml token data is [`FlowMappingEnd`].
|
||||
///
|
||||
/// [`FlowMappingEnd`]: YamlTokenData::FlowMappingEnd
|
||||
/// [`FlowMappingEnd`]: TokenData::FlowMappingEnd
|
||||
#[must_use]
|
||||
pub fn is_flow_mapping_end(&self) -> bool {
|
||||
matches!(self, Self::FlowMappingEnd)
|
||||
|
|
Loading…
Add table
Reference in a new issue