# `RustyXML.Partial`
[🔗](https://github.com/jeffhuen/rustyxml/blob/v0.2.3/lib/rusty_xml/partial.ex#L1)

Incremental XML parsing for scenarios where the complete document
is not available upfront (e.g., socket streams, chunked HTTP).

Drop-in replacement for `Saxy.Partial`.

## Example

    {:ok, partial} = RustyXML.Partial.new(MyHandler, initial_state)

    {:cont, partial} = RustyXML.Partial.parse(partial, "<root>")
    {:cont, partial} = RustyXML.Partial.parse(partial, "<item/>")
    {:cont, partial} = RustyXML.Partial.parse(partial, "</root>")

    {:ok, final_state} = RustyXML.Partial.terminate(partial)

# `t`
[🔗](https://github.com/jeffhuen/rustyxml/blob/v0.2.3/lib/rusty_xml/partial.ex#L25)

```elixir
@type t() :: %RustyXML.Partial{
  handler: module(),
  opts: keyword(),
  parser: RustyXML.Native.parser_ref(),
  started: boolean(),
  state: any()
}
```

# `get_state`
[🔗](https://github.com/jeffhuen/rustyxml/blob/v0.2.3/lib/rusty_xml/partial.ex#L106)

```elixir
@spec get_state(t()) :: any()
```

Get the current handler state without terminating.

# `new`
[🔗](https://github.com/jeffhuen/rustyxml/blob/v0.2.3/lib/rusty_xml/partial.ex#L37)

```elixir
@spec new(module(), any(), keyword()) :: {:ok, t()}
```

Create a new partial parser.

# `parse`
[🔗](https://github.com/jeffhuen/rustyxml/blob/v0.2.3/lib/rusty_xml/partial.ex#L59)

```elixir
@spec parse(t(), binary()) :: {:cont, t()} | {:halt, any()} | {:error, any()}
```

Feed a chunk of XML data to the parser.

Returns:
  * `{:cont, partial}` — more data expected
  * `{:halt, state}` — handler returned `{:stop, state}`
  * `{:error, reason}` — parse error

# `terminate`
[🔗](https://github.com/jeffhuen/rustyxml/blob/v0.2.3/lib/rusty_xml/partial.ex#L85)

```elixir
@spec terminate(t()) :: {:ok, any()} | {:error, any()}
```

Terminate parsing and get the final state.

Sends `:end_document` to the handler.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
