[go: up one dir, main page]

nom 0.3.9

A byte oriented, zero copy, parser combinators library
Documentation
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="generator" content="rustdoc">
    <meta name="description" content="API documentation for the Rust `producer` mod in crate `nom`.">
    <meta name="keywords" content="rust, rustlang, rust-lang, producer">

    <title>nom::producer - Rust</title>

    <link rel="stylesheet" type="text/css" href="../../main.css">

    
    
</head>
<body class="rustdoc">
    <!--[if lte IE 8]>
    <div class="warning">
        This old browser is unsupported and will most likely display funky
        things.
    </div>
    <![endif]-->

    

    <section class="sidebar">
        
        <p class='location'><a href='../index.html'>nom</a></p><script>window.sidebarCurrent = {name: 'producer', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script>
    </section>

    <nav class="sub">
        <form class="search-form js-only">
            <div class="search-container">
                <input class="search-input" name="search"
                       autocomplete="off"
                       placeholder="Click or press 'S' to search, '?' for more options..."
                       type="search">
            </div>
        </form>
    </nav>

    <section id='main' class="content mod">
<h1 class='fqn'><span class='in-band'>Module <a href='../index.html'>nom</a>::<wbr><a class='mod' href=''>producer</a></span><span class='out-of-band'><span id='render-detail'>
            <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
                [<span class='inner'>&#x2212;</span>]
            </a>
        </span><a id='src-3493' class='srclink' href='../../src/nom/producer.rs.html#1-352' title='goto source code'>[src]</a></span></h1>
<div class='docblock'><p>Data producers</p>

<p>The goal of data producers is to parse data as soon as it is generated.</p>

<h1 id="example" class='section-header'><a
                           href="#example">Example</a></h1><pre class='rust rust-example-rendered'>
 <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>str</span>;
 <span class='kw'>fn</span> <span class='ident'>local_print</span><span class='op'>&lt;</span><span class='lifetime'>&#39;a</span>, <span class='ident'>T</span>: <span class='ident'>Debug</span><span class='op'>&gt;</span>(<span class='ident'>input</span>: <span class='ident'>T</span>) <span class='op'>-&gt;</span> <span class='ident'>IResult</span><span class='op'>&lt;</span><span class='lifetime'>&#39;a</span>, <span class='ident'>T</span>, ()<span class='op'>&gt;</span> {
   <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{:?}&quot;</span>, <span class='ident'>input</span>);
   <span class='ident'>Done</span>(<span class='ident'>input</span>, ())
 }

 <span class='comment'>// create a data producer from a file</span>
 <span class='ident'>FileProducer</span>::<span class='ident'>new</span>(<span class='string'>&quot;links.txt&quot;</span>, <span class='number'>20</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>producer</span>: <span class='ident'>FileProducer</span><span class='op'>|</span> {
   <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>p</span> <span class='op'>=</span> <span class='ident'>producer</span>;

   <span class='comment'>// adapt the parsing function to the producer</span>
   <span class='macro'>pusher</span><span class='macro'>!</span>(<span class='ident'>push</span>, <span class='ident'>local_print</span>);
   <span class='comment'>// get started</span>
   <span class='ident'>push</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>p</span>);
 });
</pre>
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table>
                    <tr class=' module-item'>
                        <td><a class='struct' href='struct.FileProducer.html'
                               title='nom::producer::FileProducer'>FileProducer</a></td>
                        <td class='docblock short'>
                             <p>Can produce data from a file</p>

                        </td>
                    </tr>
                
                    <tr class=' module-item'>
                        <td><a class='struct' href='struct.MemProducer.html'
                               title='nom::producer::MemProducer'>MemProducer</a></td>
                        <td class='docblock short'>
                             <p>Can parse data from an already in memory byte array</p>

                        </td>
                    </tr>
                </table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2>
<table>
                    <tr class=' module-item'>
                        <td><a class='enum' href='enum.ProducerState.html'
                               title='nom::producer::ProducerState'>ProducerState</a></td>
                        <td class='docblock short'>
                             <p>Holds the data producer&#39;s current state</p>

                        </td>
                    </tr>
                </table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
<table>
                    <tr class=' module-item'>
                        <td><a class='trait' href='trait.Producer.html'
                               title='nom::producer::Producer'>Producer</a></td>
                        <td class='docblock short'>
                             <p>A producer implements the produce method, currently working with u8 arrays</p>

                        </td>
                    </tr>
                </table></section>
    <section id='search' class="content hidden"></section>

    <section class="footer"></section>

    <div id="help" class="hidden">
        <div class="shortcuts">
            <h1>Keyboard shortcuts</h1>
            <dl>
                <dt>?</dt>
                <dd>Show this help dialog</dd>
                <dt>S</dt>
                <dd>Focus the search field</dd>
                <dt>&larrb;</dt>
                <dd>Move up in search results</dd>
                <dt>&rarrb;</dt>
                <dd>Move down in search results</dd>
                <dt>&#9166;</dt>
                <dd>Go to active search result</dd>
            </dl>
        </div>
        <div class="infos">
            <h1>Search tricks</h1>
            <p>
                Prefix searches with a type followed by a colon (e.g.
                <code>fn:</code>) to restrict the search to a given type.
            </p>
            <p>
                Accepted types are: <code>fn</code>, <code>mod</code>,
                <code>struct</code>, <code>enum</code>,
                <code>trait</code>, <code>typedef</code> (or
                <code>tdef</code>).
            </p>
            <p>
                Search functions by type signature (e.g.
                <code>vec -> usize</code>)
            </p>
        </div>
    </div>

    

    <script>
        window.rootPath = "../../";
        window.currentCrate = "nom";
        window.playgroundUrl = "";
    </script>
    <script src="../../jquery.js"></script>
    <script src="../../main.js"></script>
    
    <script async src="../../search-index.js"></script>
</body>
</html>