pub struct MarkupParseContext { /* private fields */ }Expand description
A parse context is used to parse a stream of bytes that you expect to contain marked-up text.
See g_markup_parse_context_new(), #GMarkupParser, and so on for more details. A parse context is used to parse a stream of bytes that you expect to contain marked-up text.
See g_markup_parse_context_new(), #GMarkupParser, and so on for more details.
GLib type: Shared boxed type with reference counted clone semantics.
Implementations§
Source§impl MarkupParseContext
impl MarkupParseContext
Sourcepub fn end_parse(&self) -> Result<(), Error>
pub fn end_parse(&self) -> Result<(), Error>
Signals to the #GMarkupParseContext that all data has been fed into the parse context with g_markup_parse_context_parse().
This function reports an error if the document isn’t complete, for example if elements are still open.
§Returns
true on success, false if an error was set
Signals to the #GMarkupParseContext that all data has been
fed into the parse context with g_markup_parse_context_parse().
This function reports an error if the document isn’t complete, for example if elements are still open.
§Returns
Sourcepub fn element(&self) -> GString
pub fn element(&self) -> GString
Retrieves the name of the currently open element.
If called from the start_element or end_element handlers this will give the element_name as passed to those functions. For the parent elements, see g_markup_parse_context_get_element_stack().
§Returns
the name of the currently open element, or None
Retrieves the name of the currently open element.
If called from the start_element or end_element handlers this will give the element_name as passed to those functions. For the parent elements, see g_markup_parse_context_get_element_stack().
§Returns
the name of the currently open element, or None
Sourcepub fn element_stack(&self) -> Vec<GString>
pub fn element_stack(&self) -> Vec<GString>
Retrieves the element stack from the internal state of the parser.
The returned #GSList is a list of strings where the first item is the currently open tag (as would be returned by g_markup_parse_context_get_element()) and the next item is its immediate parent.
This function is intended to be used in the start_element and end_element handlers where g_markup_parse_context_get_element() would merely return the name of the element that is being processed.
§Returns
the element stack, which must not be modified Retrieves the element stack from the internal state of the parser.
The returned #GSList is a list of strings where the first item is the currently open tag (as would be returned by g_markup_parse_context_get_element()) and the next item is its immediate parent.
This function is intended to be used in the start_element and end_element handlers where g_markup_parse_context_get_element() would merely return the name of the element that is being processed.
§Returns
the element stack, which must not be modified
Sourcepub fn offset(&self) -> usize
Available on crate feature v2_88 only.
pub fn offset(&self) -> usize
v2_88 only.Retrieves the current offset from the beginning of the document, in bytes.
The information is meant to accompany the values returned by
position(), and comes with the
same accuracy guarantees.
§Returns
the offset Retrieves the current offset from the beginning of the document, in bytes.
The information is meant to accompany the values returned by
position(), and comes with the
same accuracy guarantees.
§Returns
the offset
Sourcepub fn position(&self) -> (i32, i32)
pub fn position(&self) -> (i32, i32)
Retrieves the current line number and the number of the character on that line. Intended for use in error messages; there are no strict semantics for what constitutes the “current” line number other than “the best number we could come up with for error messages.”
§Returns
§line_number
return location for a line number, or None
§char_number
return location for a char-on-line number, or None
Retrieves the current line number and the number of the character on
that line. Intended for use in error messages; there are no strict
semantics for what constitutes the “current” line number other than
“the best number we could come up with for error messages.”
§Returns
§line_number
return location for a line number, or None
§char_number
return location for a char-on-line number, or None
Sourcepub fn parse(&self, text: &str) -> Result<(), Error>
pub fn parse(&self, text: &str) -> Result<(), Error>
Feed some data to the #GMarkupParseContext.
The data need not be valid UTF-8; an error will be signaled if it’s invalid. The data need not be an entire document; you can feed a document into the parser incrementally, via multiple calls to this function. Typically, as you receive data from a network connection or file, you feed each received chunk of data into this function, aborting the process if an error occurs. Once an error is reported, no further data may be fed to the #GMarkupParseContext; all errors are fatal.
§text
chunk of text to parse
§text_len
length of @text in bytes
§Returns
false if an error occurred, true on success
Feed some data to the #GMarkupParseContext.
The data need not be valid UTF-8; an error will be signaled if it’s invalid. The data need not be an entire document; you can feed a document into the parser incrementally, via multiple calls to this function. Typically, as you receive data from a network connection or file, you feed each received chunk of data into this function, aborting the process if an error occurs. Once an error is reported, no further data may be fed to the #GMarkupParseContext; all errors are fatal.
§text
chunk of text to parse
§text_len
length of @text in bytes
§Returns
Trait Implementations§
Source§impl Clone for MarkupParseContext
impl Clone for MarkupParseContext
Source§impl Debug for MarkupParseContext
impl Debug for MarkupParseContext
Source§impl From<MarkupParseContext> for Value
impl From<MarkupParseContext> for Value
Source§fn from(s: MarkupParseContext) -> Self
fn from(s: MarkupParseContext) -> Self
Source§impl HasParamSpec for MarkupParseContext
impl HasParamSpec for MarkupParseContext
type ParamSpec = ParamSpecBoxed
Source§type SetValue = MarkupParseContext
type SetValue = MarkupParseContext
type BuilderFn = fn(&str) -> ParamSpecBoxedBuilder<'_, MarkupParseContext>
fn param_spec_builder() -> Self::BuilderFn
Source§impl Hash for MarkupParseContext
impl Hash for MarkupParseContext
Source§impl Ord for MarkupParseContext
impl Ord for MarkupParseContext
Source§impl PartialEq for MarkupParseContext
impl PartialEq for MarkupParseContext
Source§impl PartialOrd for MarkupParseContext
impl PartialOrd for MarkupParseContext
Source§impl StaticType for MarkupParseContext
impl StaticType for MarkupParseContext
Source§fn static_type() -> Type
fn static_type() -> Type
Self.impl Eq for MarkupParseContext
impl StructuralPartialEq for MarkupParseContext
Auto Trait Implementations§
impl Freeze for MarkupParseContext
impl RefUnwindSafe for MarkupParseContext
impl !Send for MarkupParseContext
impl !Sync for MarkupParseContext
impl Unpin for MarkupParseContext
impl UnwindSafe for MarkupParseContext
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)