diff options
author | 2015-06-29 20:16:15 +0000 | |
---|---|---|
committer | 2015-06-29 20:16:15 +0000 | |
commit | 64106c4d3d4ddba8c7bc2af75376e6d3d3d75601 (patch) | |
tree | 8c64d6e8be006486d975a651505fbbde61365cd6 /src | |
download | irsc-64106c4d3d4ddba8c7bc2af75376e6d3d3d75601.tar.gz irsc-64106c4d3d4ddba8c7bc2af75376e6d3d3d75601.tar.xz irsc-64106c4d3d4ddba8c7bc2af75376e6d3d3d75601.zip |
Update documentationgh-pages
Diffstat (limited to 'src')
54 files changed, 61766 insertions, 0 deletions
diff --git a/src/aho_corasick/autiter.rs.html b/src/aho_corasick/autiter.rs.html new file mode 100644 index 0000000..af7f372 --- /dev/null +++ b/src/aho_corasick/autiter.rs.html @@ -0,0 +1,747 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/aho-corasick-0.2.1/src/autiter.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>autiter.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +<span id="313">313</span> +<span id="314">314</span> +<span id="315">315</span> +<span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>::{<span class='self'>self</span>, <span class='ident'>BufRead</span>, <span class='ident'>Read</span>}; + +<span class='kw'>use</span> <span class='ident'>super</span>::{<span class='ident'>ROOT_STATE</span>, <span class='ident'>PatIdx</span>, <span class='ident'>StateIdx</span>}; + +<span class='doccomment'>/// An abstraction over automatons and their corresponding iterators.</span> +<span class='kw'>pub</span> <span class='kw'>trait</span> <span class='ident'>Automaton</span>: <span class='ident'>Sized</span> { + <span class='doccomment'>/// Return the next state given the current state and next character.</span> + <span class='kw'>fn</span> <span class='ident'>next_state</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>si</span>: <span class='ident'>StateIdx</span>, <span class='ident'>b</span>: <span class='ident'>u8</span>) <span class='op'>-></span> <span class='ident'>StateIdx</span>; + + <span class='doccomment'>/// Return true if and only if the given state and current pattern index</span> + <span class='doccomment'>/// indicate a match.</span> + <span class='kw'>fn</span> <span class='ident'>has_match</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>si</span>: <span class='ident'>StateIdx</span>, <span class='ident'>outi</span>: <span class='ident'>PatIdx</span>) <span class='op'>-></span> <span class='ident'>bool</span>; + + <span class='doccomment'>/// Build a match given the current state, pattern index and input index.</span> + <span class='kw'>fn</span> <span class='ident'>get_match</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>si</span>: <span class='ident'>StateIdx</span>, <span class='ident'>outi</span>: <span class='ident'>PatIdx</span>, <span class='ident'>texti</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>Match</span>; + + <span class='doccomment'>/// Attempt to skip through the input.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This returns the index into `text` at which the next match attempt</span> + <span class='doccomment'>/// should start. (If no skipping occurred, then the return value should</span> + <span class='doccomment'>/// be equal to `at`.)</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Finally, if no match is possible, then return `text.len()`.</span> + <span class='kw'>fn</span> <span class='ident'>skip_to</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>si</span>: <span class='ident'>StateIdx</span>, <span class='ident'>text</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>], <span class='ident'>at</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>usize</span>; + + <span class='doccomment'>/// Returns true if and only if this automaton can skip through the input.</span> + <span class='kw'>fn</span> <span class='ident'>is_skippable</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span>; + + <span class='doccomment'>/// Returns all of the patterns matched by this automaton.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The order of the patterns is the order in which they were added.</span> + <span class='kw'>fn</span> <span class='ident'>patterns</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span>[<span class='ident'>String</span>]; + + <span class='doccomment'>/// Returns the pattern indexed at `i`.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The index corresponds to the position at which the pattern was added</span> + <span class='doccomment'>/// to the automaton, starting at `0`.</span> + <span class='kw'>fn</span> <span class='ident'>pattern</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>i</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>str</span>; + + <span class='doccomment'>/// Return the number of patterns in the automaton.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>len</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='self'>self</span>.<span class='ident'>patterns</span>().<span class='ident'>len</span>() + } + + <span class='doccomment'>/// Returns true if the automaton has no patterns.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>is_empty</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='self'>self</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>0</span> + } + + <span class='doccomment'>/// Returns an iterator of non-overlapping matches in `s`.</span> + <span class='kw'>fn</span> <span class='ident'>find</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='lifetime'>'s</span><span class='op'>></span>( + <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='self'>self</span>, + <span class='ident'>s</span>: <span class='kw-2'>&</span><span class='lifetime'>'s</span> <span class='ident'>str</span>, + ) <span class='op'>-></span> <span class='ident'>Matches</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='lifetime'>'s</span>, <span class='kw'>Self</span><span class='op'>></span> { + <span class='ident'>Matches</span> { + <span class='ident'>aut</span>: <span class='self'>self</span>, + <span class='ident'>text</span>: <span class='ident'>s</span>.<span class='ident'>as_bytes</span>(), + <span class='ident'>texti</span>: <span class='number'>0</span>, + <span class='ident'>si</span>: <span class='ident'>ROOT_STATE</span>, + } + } + + <span class='doccomment'>/// Returns an iterator of overlapping matches in `s`.</span> + <span class='kw'>fn</span> <span class='ident'>find_overlapping</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='lifetime'>'s</span><span class='op'>></span>( + <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='self'>self</span>, + <span class='ident'>s</span>: <span class='kw-2'>&</span><span class='lifetime'>'s</span> <span class='ident'>str</span>, + ) <span class='op'>-></span> <span class='ident'>MatchesOverlapping</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='lifetime'>'s</span>, <span class='kw'>Self</span><span class='op'>></span> { + <span class='ident'>MatchesOverlapping</span> { + <span class='ident'>aut</span>: <span class='self'>self</span>, + <span class='ident'>text</span>: <span class='ident'>s</span>.<span class='ident'>as_bytes</span>(), + <span class='ident'>texti</span>: <span class='number'>0</span>, + <span class='ident'>si</span>: <span class='ident'>ROOT_STATE</span>, + <span class='ident'>outi</span>: <span class='number'>0</span>, + } + } + + <span class='doccomment'>/// Returns an iterator of non-overlapping matches in the given reader.</span> + <span class='kw'>fn</span> <span class='ident'>stream_find</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>R</span>: <span class='ident'>io</span>::<span class='ident'>Read</span><span class='op'>></span>( + <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='self'>self</span>, + <span class='ident'>rdr</span>: <span class='ident'>R</span>, + ) <span class='op'>-></span> <span class='ident'>StreamMatches</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>R</span>, <span class='kw'>Self</span><span class='op'>></span> { + <span class='ident'>StreamMatches</span> { + <span class='ident'>aut</span>: <span class='self'>self</span>, + <span class='ident'>buf</span>: <span class='ident'>io</span>::<span class='ident'>BufReader</span>::<span class='ident'>new</span>(<span class='ident'>rdr</span>), + <span class='ident'>texti</span>: <span class='number'>0</span>, + <span class='ident'>si</span>: <span class='ident'>ROOT_STATE</span>, + } + } + + <span class='doccomment'>/// Returns an iterator of overlapping matches in the given reader.</span> + <span class='kw'>fn</span> <span class='ident'>stream_find_overlapping</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>R</span>: <span class='ident'>io</span>::<span class='ident'>Read</span><span class='op'>></span>( + <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='self'>self</span>, + <span class='ident'>rdr</span>: <span class='ident'>R</span>, + ) <span class='op'>-></span> <span class='ident'>StreamMatchesOverlapping</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>R</span>, <span class='kw'>Self</span><span class='op'>></span> { + <span class='ident'>StreamMatchesOverlapping</span> { + <span class='ident'>aut</span>: <span class='self'>self</span>, + <span class='ident'>buf</span>: <span class='ident'>io</span>::<span class='ident'>BufReader</span>::<span class='ident'>new</span>(<span class='ident'>rdr</span>), + <span class='ident'>texti</span>: <span class='number'>0</span>, + <span class='ident'>si</span>: <span class='ident'>ROOT_STATE</span>, + <span class='ident'>outi</span>: <span class='number'>0</span>, + } + } +} + +<span class='doccomment'>/// Records a match in the search text.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>, <span class='ident'>Debug</span>, <span class='ident'>Hash</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Match</span> { + <span class='doccomment'>/// The pattern index.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This corresponds to the ordering in which the matched pattern was</span> + <span class='doccomment'>/// added to the automaton, starting at `0`.</span> + <span class='kw'>pub</span> <span class='ident'>pati</span>: <span class='ident'>usize</span>, + <span class='doccomment'>/// The starting byte offset of the match in the search text.</span> + <span class='kw'>pub</span> <span class='ident'>start</span>: <span class='ident'>usize</span>, + <span class='doccomment'>/// The ending byte offset of the match in the search text.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// (This can be re-captiulated with `pati` and adding the pattern's</span> + <span class='doccomment'>/// length to `start`, but it is convenient to have it here.)</span> + <span class='kw'>pub</span> <span class='ident'>end</span>: <span class='ident'>usize</span>, +} + +<span class='doccomment'>/// An iterator of non-overlapping matches for in-memory text.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This iterator yields `Match` values.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// `'a` is the lifetime of the automaton and `'s` is the lifetime of the</span> +<span class='doccomment'>/// search text.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Matches</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='lifetime'>'s</span>, <span class='ident'>A</span>: <span class='lifetime'>'a</span> <span class='op'>+</span> <span class='ident'>Automaton</span><span class='op'>></span> { + <span class='ident'>aut</span>: <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>A</span>, + <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='lifetime'>'s</span> [<span class='ident'>u8</span>], + <span class='ident'>texti</span>: <span class='ident'>usize</span>, + <span class='ident'>si</span>: <span class='ident'>StateIdx</span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='lifetime'>'s</span>, <span class='ident'>A</span>: <span class='ident'>Automaton</span><span class='op'>></span> <span class='ident'>Iterator</span> <span class='kw'>for</span> <span class='ident'>Matches</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='lifetime'>'s</span>, <span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Item</span> <span class='op'>=</span> <span class='ident'>Match</span>; + + <span class='kw'>fn</span> <span class='ident'>next</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Match</span><span class='op'>></span> { + <span class='comment'>// When there's an initial lone start byte, it is usually worth it</span> + <span class='comment'>// to use `memchr` to skip along the input. The problem is that</span> + <span class='comment'>// the skipping function is called in the inner match loop, which</span> + <span class='comment'>// can be quite costly if the skipping condition is never met.</span> + <span class='comment'>// Therefore, we lift the case analysis outside of the main loop at</span> + <span class='comment'>// the cost of repeating code.</span> + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>is_skippable</span>() { + <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>skip_to</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='self'>self</span>.<span class='ident'>text</span>, <span class='self'>self</span>.<span class='ident'>texti</span>); + <span class='kw'>while</span> <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'><</span> <span class='self'>self</span>.<span class='ident'>text</span>.<span class='ident'>len</span>() { + <span class='self'>self</span>.<span class='ident'>si</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>next_state</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='self'>self</span>.<span class='ident'>text</span>[<span class='self'>self</span>.<span class='ident'>texti</span>]); + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>has_match</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='number'>0</span>) { + <span class='kw'>let</span> <span class='ident'>m</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>get_match</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='number'>0</span>, <span class='self'>self</span>.<span class='ident'>texti</span>); + <span class='self'>self</span>.<span class='ident'>si</span> <span class='op'>=</span> <span class='ident'>ROOT_STATE</span>; + <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'>+=</span> <span class='number'>1</span>; + <span class='kw'>return</span> <span class='prelude-val'>Some</span>(<span class='ident'>m</span>); + } + <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>skip_to</span>( + <span class='self'>self</span>.<span class='ident'>si</span>, <span class='self'>self</span>.<span class='ident'>text</span>, <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'>+</span> <span class='number'>1</span>); + } + } <span class='kw'>else</span> { + <span class='kw'>while</span> <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'><</span> <span class='self'>self</span>.<span class='ident'>text</span>.<span class='ident'>len</span>() { + <span class='self'>self</span>.<span class='ident'>si</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>next_state</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='self'>self</span>.<span class='ident'>text</span>[<span class='self'>self</span>.<span class='ident'>texti</span>]); + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>has_match</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='number'>0</span>) { + <span class='kw'>let</span> <span class='ident'>m</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>get_match</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='number'>0</span>, <span class='self'>self</span>.<span class='ident'>texti</span>); + <span class='self'>self</span>.<span class='ident'>si</span> <span class='op'>=</span> <span class='ident'>ROOT_STATE</span>; + <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'>+=</span> <span class='number'>1</span>; + <span class='kw'>return</span> <span class='prelude-val'>Some</span>(<span class='ident'>m</span>); + } + <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'>+=</span> <span class='number'>1</span>; + } + } + <span class='prelude-val'>None</span> + } +} + +<span class='doccomment'>/// An iterator of non-overlapping matches for streaming text.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This iterator yields `io::Result<Match>` values.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// `'a` is the lifetime of the automaton and `R` is the type of the underlying</span> +<span class='doccomment'>/// `io::Read`er.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>StreamMatches</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>R</span>, <span class='ident'>A</span>: <span class='lifetime'>'a</span> <span class='op'>+</span> <span class='ident'>Automaton</span><span class='op'>></span> { + <span class='ident'>aut</span>: <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>A</span>, + <span class='ident'>buf</span>: <span class='ident'>io</span>::<span class='ident'>BufReader</span><span class='op'><</span><span class='ident'>R</span><span class='op'>></span>, + <span class='ident'>texti</span>: <span class='ident'>usize</span>, + <span class='ident'>si</span>: <span class='ident'>StateIdx</span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>R</span>: <span class='ident'>io</span>::<span class='ident'>Read</span>, <span class='ident'>A</span>: <span class='ident'>Automaton</span><span class='op'>></span> <span class='ident'>Iterator</span> <span class='kw'>for</span> <span class='ident'>StreamMatches</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>R</span>, <span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Item</span> <span class='op'>=</span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Match</span><span class='op'>></span>; + + <span class='kw'>fn</span> <span class='ident'>next</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Match</span><span class='op'>>></span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>m</span> <span class='op'>=</span> <span class='prelude-val'>None</span>; + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>consumed</span> <span class='op'>=</span> <span class='number'>0</span>; +<span class='lifetime'>'LOOP</span>: <span class='kw'>loop</span> { + <span class='self'>self</span>.<span class='ident'>buf</span>.<span class='ident'>consume</span>(<span class='ident'>consumed</span>); + <span class='kw'>let</span> <span class='ident'>bs</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>buf</span>.<span class='ident'>fill_buf</span>() { + <span class='prelude-val'>Err</span>(<span class='ident'>err</span>) <span class='op'>=></span> <span class='kw'>return</span> <span class='prelude-val'>Some</span>(<span class='prelude-val'>Err</span>(<span class='ident'>err</span>)), + <span class='prelude-val'>Ok</span>(<span class='ident'>bs</span>) <span class='kw'>if</span> <span class='ident'>bs</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>0</span> <span class='op'>=></span> <span class='kw'>break</span>, + <span class='prelude-val'>Ok</span>(<span class='ident'>bs</span>) <span class='op'>=></span> <span class='ident'>bs</span>, + }; + <span class='ident'>consumed</span> <span class='op'>=</span> <span class='ident'>bs</span>.<span class='ident'>len</span>(); <span class='comment'>// is shortened if we find a match</span> + <span class='kw'>for</span> (<span class='ident'>i</span>, <span class='kw-2'>&</span><span class='ident'>b</span>) <span class='kw'>in</span> <span class='ident'>bs</span>.<span class='ident'>iter</span>().<span class='ident'>enumerate</span>() { + <span class='self'>self</span>.<span class='ident'>si</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>next_state</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='ident'>b</span>); + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>has_match</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='number'>0</span>) { + <span class='ident'>m</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='prelude-val'>Ok</span>(<span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>get_match</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='number'>0</span>, <span class='self'>self</span>.<span class='ident'>texti</span>))); + <span class='ident'>consumed</span> <span class='op'>=</span> <span class='ident'>i</span> <span class='op'>+</span> <span class='number'>1</span>; + <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'>+=</span> <span class='number'>1</span>; + <span class='self'>self</span>.<span class='ident'>si</span> <span class='op'>=</span> <span class='ident'>ROOT_STATE</span>; + <span class='kw'>break</span> <span class='lifetime'>'LOOP</span>; + } + <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'>+=</span> <span class='number'>1</span>; + } + } + <span class='self'>self</span>.<span class='ident'>buf</span>.<span class='ident'>consume</span>(<span class='ident'>consumed</span>); + <span class='ident'>m</span> + } +} + +<span class='doccomment'>/// An iterator of overlapping matches for in-memory text.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This iterator yields `Match` values.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// `'a` is the lifetime of the automaton and `'s` is the lifetime of the</span> +<span class='doccomment'>/// search text.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>MatchesOverlapping</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='lifetime'>'s</span>, <span class='ident'>A</span>: <span class='lifetime'>'a</span> <span class='op'>+</span> <span class='ident'>Automaton</span><span class='op'>></span> { + <span class='ident'>aut</span>: <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>A</span>, + <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='lifetime'>'s</span> [<span class='ident'>u8</span>], + <span class='ident'>texti</span>: <span class='ident'>usize</span>, + <span class='ident'>si</span>: <span class='ident'>StateIdx</span>, + <span class='ident'>outi</span>: <span class='ident'>usize</span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='lifetime'>'s</span>, <span class='ident'>A</span>: <span class='ident'>Automaton</span><span class='op'>></span> <span class='ident'>Iterator</span> <span class='kw'>for</span> <span class='ident'>MatchesOverlapping</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='lifetime'>'s</span>, <span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Item</span> <span class='op'>=</span> <span class='ident'>Match</span>; + + <span class='kw'>fn</span> <span class='ident'>next</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Match</span><span class='op'>></span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>has_match</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='self'>self</span>.<span class='ident'>outi</span>) { + <span class='kw'>let</span> <span class='ident'>m</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>get_match</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='self'>self</span>.<span class='ident'>outi</span>, <span class='self'>self</span>.<span class='ident'>texti</span>); + <span class='self'>self</span>.<span class='ident'>outi</span> <span class='op'>+=</span> <span class='number'>1</span>; + <span class='kw'>if</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>has_match</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='self'>self</span>.<span class='ident'>outi</span>) { + <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'>+=</span> <span class='number'>1</span>; + } + <span class='kw'>return</span> <span class='prelude-val'>Some</span>(<span class='ident'>m</span>); + } + + <span class='self'>self</span>.<span class='ident'>outi</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>skip_to</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='self'>self</span>.<span class='ident'>text</span>, <span class='self'>self</span>.<span class='ident'>texti</span>); + <span class='kw'>while</span> <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'><</span> <span class='self'>self</span>.<span class='ident'>text</span>.<span class='ident'>len</span>() { + <span class='kw'>let</span> <span class='ident'>b</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>text</span>[<span class='self'>self</span>.<span class='ident'>texti</span>]; + <span class='self'>self</span>.<span class='ident'>si</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>next_state</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='ident'>b</span>); + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>has_match</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='self'>self</span>.<span class='ident'>outi</span>) { + <span class='kw'>return</span> <span class='self'>self</span>.<span class='ident'>next</span>(); + } + <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>skip_to</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='self'>self</span>.<span class='ident'>text</span>, <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'>+</span> <span class='number'>1</span>); + } + <span class='prelude-val'>None</span> + } +} + +<span class='doccomment'>/// An iterator of overlapping matches for streaming text.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This iterator yields `io::Result<Match>` values.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// `'a` is the lifetime of the automaton and `R` is the type of the underlying</span> +<span class='doccomment'>/// `io::Read`er.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>StreamMatchesOverlapping</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>R</span>, <span class='ident'>A</span>: <span class='lifetime'>'a</span> <span class='op'>+</span> <span class='ident'>Automaton</span><span class='op'>></span> { + <span class='ident'>aut</span>: <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>A</span>, + <span class='ident'>buf</span>: <span class='ident'>io</span>::<span class='ident'>BufReader</span><span class='op'><</span><span class='ident'>R</span><span class='op'>></span>, + <span class='ident'>texti</span>: <span class='ident'>usize</span>, + <span class='ident'>si</span>: <span class='ident'>StateIdx</span>, + <span class='ident'>outi</span>: <span class='ident'>usize</span>, +} + +<span class='kw'>impl</span><span class='op'><</span> + <span class='lifetime'>'a</span>, + <span class='ident'>R</span>: <span class='ident'>io</span>::<span class='ident'>Read</span>, + <span class='ident'>A</span>: <span class='ident'>Automaton</span>, +<span class='op'>></span> <span class='ident'>Iterator</span> <span class='kw'>for</span> <span class='ident'>StreamMatchesOverlapping</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>R</span>, <span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Item</span> <span class='op'>=</span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Match</span><span class='op'>></span>; + + <span class='kw'>fn</span> <span class='ident'>next</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Match</span><span class='op'>>></span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>has_match</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='self'>self</span>.<span class='ident'>outi</span>) { + <span class='kw'>let</span> <span class='ident'>m</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>get_match</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='self'>self</span>.<span class='ident'>outi</span>, <span class='self'>self</span>.<span class='ident'>texti</span>); + <span class='self'>self</span>.<span class='ident'>outi</span> <span class='op'>+=</span> <span class='number'>1</span>; + <span class='kw'>if</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>has_match</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='self'>self</span>.<span class='ident'>outi</span>) { + <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'>+=</span> <span class='number'>1</span>; + } + <span class='kw'>return</span> <span class='prelude-val'>Some</span>(<span class='prelude-val'>Ok</span>(<span class='ident'>m</span>)); + } + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>m</span> <span class='op'>=</span> <span class='prelude-val'>None</span>; + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>consumed</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='self'>self</span>.<span class='ident'>outi</span> <span class='op'>=</span> <span class='number'>0</span>; +<span class='lifetime'>'LOOP</span>: <span class='kw'>loop</span> { + <span class='self'>self</span>.<span class='ident'>buf</span>.<span class='ident'>consume</span>(<span class='ident'>consumed</span>); + <span class='kw'>let</span> <span class='ident'>bs</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>buf</span>.<span class='ident'>fill_buf</span>() { + <span class='prelude-val'>Err</span>(<span class='ident'>err</span>) <span class='op'>=></span> <span class='kw'>return</span> <span class='prelude-val'>Some</span>(<span class='prelude-val'>Err</span>(<span class='ident'>err</span>)), + <span class='prelude-val'>Ok</span>(<span class='ident'>bs</span>) <span class='kw'>if</span> <span class='ident'>bs</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>0</span> <span class='op'>=></span> <span class='kw'>break</span>, + <span class='prelude-val'>Ok</span>(<span class='ident'>bs</span>) <span class='op'>=></span> <span class='ident'>bs</span>, + }; + <span class='ident'>consumed</span> <span class='op'>=</span> <span class='ident'>bs</span>.<span class='ident'>len</span>(); <span class='comment'>// is shortened if we find a match</span> + <span class='kw'>for</span> (<span class='ident'>i</span>, <span class='kw-2'>&</span><span class='ident'>b</span>) <span class='kw'>in</span> <span class='ident'>bs</span>.<span class='ident'>iter</span>().<span class='ident'>enumerate</span>() { + <span class='self'>self</span>.<span class='ident'>si</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>next_state</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='ident'>b</span>); + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>has_match</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='self'>self</span>.<span class='ident'>outi</span>) { + <span class='ident'>m</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='prelude-val'>Ok</span>(<span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>get_match</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='self'>self</span>.<span class='ident'>outi</span>, + <span class='self'>self</span>.<span class='ident'>texti</span>))); + <span class='ident'>consumed</span> <span class='op'>=</span> <span class='ident'>i</span> <span class='op'>+</span> <span class='number'>1</span>; + <span class='self'>self</span>.<span class='ident'>outi</span> <span class='op'>+=</span> <span class='number'>1</span>; + <span class='kw'>if</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>aut</span>.<span class='ident'>has_match</span>(<span class='self'>self</span>.<span class='ident'>si</span>, <span class='self'>self</span>.<span class='ident'>outi</span>) { + <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'>+=</span> <span class='number'>1</span>; + } + <span class='kw'>break</span> <span class='lifetime'>'LOOP</span>; + } + <span class='self'>self</span>.<span class='ident'>texti</span> <span class='op'>+=</span> <span class='number'>1</span>; + } + } + <span class='self'>self</span>.<span class='ident'>buf</span>.<span class='ident'>consume</span>(<span class='ident'>consumed</span>); + <span class='ident'>m</span> + } +} + +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "aho_corasick"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/aho_corasick/full.rs.html b/src/aho_corasick/full.rs.html new file mode 100644 index 0000000..f9f4f65 --- /dev/null +++ b/src/aho_corasick/full.rs.html @@ -0,0 +1,329 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/aho-corasick-0.2.1/src/full.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>full.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>memchr</span>::<span class='ident'>memchr</span>; + +<span class='kw'>use</span> <span class='ident'>super</span>::{ + <span class='ident'>FAIL_STATE</span>, <span class='ident'>ROOT_STATE</span>, + <span class='ident'>StateIdx</span>, <span class='ident'>PatIdx</span>, + <span class='ident'>AcAutomaton</span>, <span class='ident'>Transitions</span>, <span class='ident'>Match</span>, +}; +<span class='kw'>use</span> <span class='ident'>super</span>::<span class='ident'>autiter</span>::<span class='ident'>Automaton</span>; + +<span class='doccomment'>/// A complete Aho-Corasick automaton.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This uses a single transition matrix that permits each input character</span> +<span class='doccomment'>/// to move to the next state with a single lookup in the matrix.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This is as fast as it gets, but it is guaranteed to use a lot of memory.</span> +<span class='doccomment'>/// Namely, it will use at least `4 * 256 * #states`, where the number of</span> +<span class='doccomment'>/// states is capped at length of all patterns concatenated.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>FullAcAutomaton</span> { + <span class='ident'>pats</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span>, + <span class='comment'>// i * #states + si</span> + <span class='ident'>trans</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>StateIdx</span><span class='op'>></span>, <span class='comment'>// row-major, where states are rows</span> + <span class='ident'>out</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Vec</span><span class='op'><</span><span class='ident'>PatIdx</span><span class='op'>>></span>, <span class='comment'>// indexed by StateIdx</span> + <span class='ident'>start_bytes</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, +} + +<span class='kw'>impl</span> <span class='ident'>FullAcAutomaton</span> { + <span class='doccomment'>/// Build a new expanded Aho-Corasick automaton from an existing</span> + <span class='doccomment'>/// Aho-Corasick automaton.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>Transitions</span><span class='op'>></span>(<span class='ident'>ac</span>: <span class='ident'>AcAutomaton</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>FullAcAutomaton</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>fac</span> <span class='op'>=</span> <span class='ident'>FullAcAutomaton</span> { + <span class='ident'>pats</span>: <span class='macro'>vec</span><span class='macro'>!</span>[], + <span class='ident'>trans</span>: <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>FAIL_STATE</span>; <span class='number'>256</span> <span class='op'>*</span> <span class='ident'>ac</span>.<span class='ident'>states</span>.<span class='ident'>len</span>()], + <span class='ident'>out</span>: <span class='macro'>vec</span><span class='macro'>!</span>[<span class='macro'>vec</span><span class='macro'>!</span>[]; <span class='ident'>ac</span>.<span class='ident'>states</span>.<span class='ident'>len</span>()], + <span class='ident'>start_bytes</span>: <span class='macro'>vec</span><span class='macro'>!</span>[], + }; + <span class='ident'>fac</span>.<span class='ident'>build_matrix</span>(<span class='kw-2'>&</span><span class='ident'>ac</span>); + <span class='ident'>fac</span>.<span class='ident'>pats</span> <span class='op'>=</span> <span class='ident'>ac</span>.<span class='ident'>pats</span>; + <span class='ident'>fac</span>.<span class='ident'>start_bytes</span> <span class='op'>=</span> <span class='ident'>ac</span>.<span class='ident'>start_bytes</span>; + <span class='ident'>fac</span> + } + + <span class='kw'>fn</span> <span class='ident'>set</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>si</span>: <span class='ident'>StateIdx</span>, <span class='ident'>i</span>: <span class='ident'>u8</span>, <span class='ident'>goto</span>: <span class='ident'>StateIdx</span>) { + <span class='kw'>let</span> <span class='ident'>ns</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>num_states</span>(); + <span class='self'>self</span>.<span class='ident'>trans</span>[<span class='ident'>i</span> <span class='kw'>as</span> <span class='ident'>usize</span> <span class='op'>*</span> <span class='ident'>ns</span> <span class='op'>+</span> <span class='ident'>si</span> <span class='kw'>as</span> <span class='ident'>usize</span>] <span class='op'>=</span> <span class='ident'>goto</span>; + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>num_states</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='self'>self</span>.<span class='ident'>out</span>.<span class='ident'>len</span>() + } +} + +<span class='kw'>impl</span> <span class='ident'>Automaton</span> <span class='kw'>for</span> <span class='ident'>FullAcAutomaton</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>next_state</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>si</span>: <span class='ident'>StateIdx</span>, <span class='ident'>i</span>: <span class='ident'>u8</span>) <span class='op'>-></span> <span class='ident'>StateIdx</span> { + <span class='self'>self</span>.<span class='ident'>trans</span>[<span class='ident'>i</span> <span class='kw'>as</span> <span class='ident'>usize</span> <span class='op'>*</span> <span class='self'>self</span>.<span class='ident'>num_states</span>() <span class='op'>+</span> <span class='ident'>si</span> <span class='kw'>as</span> <span class='ident'>usize</span>] + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>get_match</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>si</span>: <span class='ident'>StateIdx</span>, <span class='ident'>outi</span>: <span class='ident'>usize</span>, <span class='ident'>texti</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>Match</span> { + <span class='kw'>let</span> <span class='ident'>pati</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>out</span>[<span class='ident'>si</span> <span class='kw'>as</span> <span class='ident'>usize</span>][<span class='ident'>outi</span>]; + <span class='kw'>let</span> <span class='ident'>patlen</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>pats</span>[<span class='ident'>pati</span>].<span class='ident'>len</span>(); + <span class='kw'>let</span> <span class='ident'>start</span> <span class='op'>=</span> <span class='ident'>texti</span> <span class='op'>+</span> <span class='number'>1</span> <span class='op'>-</span> <span class='ident'>patlen</span>; + <span class='ident'>Match</span> { + <span class='ident'>pati</span>: <span class='ident'>pati</span>, + <span class='ident'>start</span>: <span class='ident'>start</span>, + <span class='ident'>end</span>: <span class='ident'>start</span> <span class='op'>+</span> <span class='ident'>patlen</span>, + } + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>has_match</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>si</span>: <span class='ident'>StateIdx</span>, <span class='ident'>outi</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='ident'>outi</span> <span class='op'><</span> <span class='self'>self</span>.<span class='ident'>out</span>[<span class='ident'>si</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>len</span>() + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>skip_to</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>si</span>: <span class='ident'>StateIdx</span>, <span class='ident'>text</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>], <span class='ident'>at</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='kw'>if</span> <span class='ident'>si</span> <span class='op'>!=</span> <span class='ident'>ROOT_STATE</span> <span class='op'>||</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>is_skippable</span>() { + <span class='kw'>return</span> <span class='ident'>at</span>; + } + <span class='kw'>let</span> <span class='ident'>b</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>start_bytes</span>[<span class='number'>0</span>]; + <span class='kw'>match</span> <span class='ident'>memchr</span>(<span class='ident'>b</span>, <span class='kw-2'>&</span><span class='ident'>text</span>[<span class='ident'>at</span>..]) { + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='ident'>text</span>.<span class='ident'>len</span>(), + <span class='prelude-val'>Some</span>(<span class='ident'>i</span>) <span class='op'>=></span> <span class='ident'>at</span> <span class='op'>+</span> <span class='ident'>i</span>, + } + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>is_skippable</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='self'>self</span>.<span class='ident'>start_bytes</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>1</span> + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>patterns</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span>[<span class='ident'>String</span>] { + <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>pats</span> + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>pattern</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>i</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>str</span> { + <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>pats</span>[<span class='ident'>i</span>] + } +} + +<span class='kw'>impl</span> <span class='ident'>FullAcAutomaton</span> { + <span class='kw'>fn</span> <span class='ident'>build_matrix</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>Transitions</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>ac</span>: <span class='kw-2'>&</span><span class='ident'>AcAutomaton</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span>) { + <span class='kw'>for</span> (<span class='ident'>si</span>, <span class='ident'>s</span>) <span class='kw'>in</span> <span class='ident'>ac</span>.<span class='ident'>states</span>.<span class='ident'>iter</span>().<span class='ident'>enumerate</span>().<span class='ident'>skip</span>(<span class='number'>1</span>) { + <span class='kw'>for</span> <span class='ident'>b</span> <span class='kw'>in</span> (<span class='number'>0</span>..<span class='number'>256</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>b</span><span class='op'>|</span> <span class='ident'>b</span> <span class='kw'>as</span> <span class='ident'>u8</span>) { + <span class='self'>self</span>.<span class='ident'>set</span>(<span class='ident'>si</span> <span class='kw'>as</span> <span class='ident'>StateIdx</span>, <span class='ident'>b</span>, <span class='ident'>ac</span>.<span class='ident'>next_state</span>(<span class='ident'>si</span> <span class='kw'>as</span> <span class='ident'>StateIdx</span>, <span class='ident'>b</span>)); + } + <span class='kw'>for</span> <span class='kw-2'>&</span><span class='ident'>pati</span> <span class='kw'>in</span> <span class='kw-2'>&</span><span class='ident'>s</span>.<span class='ident'>out</span> { + <span class='self'>self</span>.<span class='ident'>out</span>[<span class='ident'>si</span>].<span class='ident'>push</span>(<span class='ident'>pati</span>); + } + } + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "aho_corasick"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/aho_corasick/lib.rs.html b/src/aho_corasick/lib.rs.html new file mode 100644 index 0000000..e75bc4d --- /dev/null +++ b/src/aho_corasick/lib.rs.html @@ -0,0 +1,1823 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/aho-corasick-0.2.1/src/lib.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>lib.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +<span id="313">313</span> +<span id="314">314</span> +<span id="315">315</span> +<span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +<span id="326">326</span> +<span id="327">327</span> +<span id="328">328</span> +<span id="329">329</span> +<span id="330">330</span> +<span id="331">331</span> +<span id="332">332</span> +<span id="333">333</span> +<span id="334">334</span> +<span id="335">335</span> +<span id="336">336</span> +<span id="337">337</span> +<span id="338">338</span> +<span id="339">339</span> +<span id="340">340</span> +<span id="341">341</span> +<span id="342">342</span> +<span id="343">343</span> +<span id="344">344</span> +<span id="345">345</span> +<span id="346">346</span> +<span id="347">347</span> +<span id="348">348</span> +<span id="349">349</span> +<span id="350">350</span> +<span id="351">351</span> +<span id="352">352</span> +<span id="353">353</span> +<span id="354">354</span> +<span id="355">355</span> +<span id="356">356</span> +<span id="357">357</span> +<span id="358">358</span> +<span id="359">359</span> +<span id="360">360</span> +<span id="361">361</span> +<span id="362">362</span> +<span id="363">363</span> +<span id="364">364</span> +<span id="365">365</span> +<span id="366">366</span> +<span id="367">367</span> +<span id="368">368</span> +<span id="369">369</span> +<span id="370">370</span> +<span id="371">371</span> +<span id="372">372</span> +<span id="373">373</span> +<span id="374">374</span> +<span id="375">375</span> +<span id="376">376</span> +<span id="377">377</span> +<span id="378">378</span> +<span id="379">379</span> +<span id="380">380</span> +<span id="381">381</span> +<span id="382">382</span> +<span id="383">383</span> +<span id="384">384</span> +<span id="385">385</span> +<span id="386">386</span> +<span id="387">387</span> +<span id="388">388</span> +<span id="389">389</span> +<span id="390">390</span> +<span id="391">391</span> +<span id="392">392</span> +<span id="393">393</span> +<span id="394">394</span> +<span id="395">395</span> +<span id="396">396</span> +<span id="397">397</span> +<span id="398">398</span> +<span id="399">399</span> +<span id="400">400</span> +<span id="401">401</span> +<span id="402">402</span> +<span id="403">403</span> +<span id="404">404</span> +<span id="405">405</span> +<span id="406">406</span> +<span id="407">407</span> +<span id="408">408</span> +<span id="409">409</span> +<span id="410">410</span> +<span id="411">411</span> +<span id="412">412</span> +<span id="413">413</span> +<span id="414">414</span> +<span id="415">415</span> +<span id="416">416</span> +<span id="417">417</span> +<span id="418">418</span> +<span id="419">419</span> +<span id="420">420</span> +<span id="421">421</span> +<span id="422">422</span> +<span id="423">423</span> +<span id="424">424</span> +<span id="425">425</span> +<span id="426">426</span> +<span id="427">427</span> +<span id="428">428</span> +<span id="429">429</span> +<span id="430">430</span> +<span id="431">431</span> +<span id="432">432</span> +<span id="433">433</span> +<span id="434">434</span> +<span id="435">435</span> +<span id="436">436</span> +<span id="437">437</span> +<span id="438">438</span> +<span id="439">439</span> +<span id="440">440</span> +<span id="441">441</span> +<span id="442">442</span> +<span id="443">443</span> +<span id="444">444</span> +<span id="445">445</span> +<span id="446">446</span> +<span id="447">447</span> +<span id="448">448</span> +<span id="449">449</span> +<span id="450">450</span> +<span id="451">451</span> +<span id="452">452</span> +<span id="453">453</span> +<span id="454">454</span> +<span id="455">455</span> +<span id="456">456</span> +<span id="457">457</span> +<span id="458">458</span> +<span id="459">459</span> +<span id="460">460</span> +<span id="461">461</span> +<span id="462">462</span> +<span id="463">463</span> +<span id="464">464</span> +<span id="465">465</span> +<span id="466">466</span> +<span id="467">467</span> +<span id="468">468</span> +<span id="469">469</span> +<span id="470">470</span> +<span id="471">471</span> +<span id="472">472</span> +<span id="473">473</span> +<span id="474">474</span> +<span id="475">475</span> +<span id="476">476</span> +<span id="477">477</span> +<span id="478">478</span> +<span id="479">479</span> +<span id="480">480</span> +<span id="481">481</span> +<span id="482">482</span> +<span id="483">483</span> +<span id="484">484</span> +<span id="485">485</span> +<span id="486">486</span> +<span id="487">487</span> +<span id="488">488</span> +<span id="489">489</span> +<span id="490">490</span> +<span id="491">491</span> +<span id="492">492</span> +<span id="493">493</span> +<span id="494">494</span> +<span id="495">495</span> +<span id="496">496</span> +<span id="497">497</span> +<span id="498">498</span> +<span id="499">499</span> +<span id="500">500</span> +<span id="501">501</span> +<span id="502">502</span> +<span id="503">503</span> +<span id="504">504</span> +<span id="505">505</span> +<span id="506">506</span> +<span id="507">507</span> +<span id="508">508</span> +<span id="509">509</span> +<span id="510">510</span> +<span id="511">511</span> +<span id="512">512</span> +<span id="513">513</span> +<span id="514">514</span> +<span id="515">515</span> +<span id="516">516</span> +<span id="517">517</span> +<span id="518">518</span> +<span id="519">519</span> +<span id="520">520</span> +<span id="521">521</span> +<span id="522">522</span> +<span id="523">523</span> +<span id="524">524</span> +<span id="525">525</span> +<span id="526">526</span> +<span id="527">527</span> +<span id="528">528</span> +<span id="529">529</span> +<span id="530">530</span> +<span id="531">531</span> +<span id="532">532</span> +<span id="533">533</span> +<span id="534">534</span> +<span id="535">535</span> +<span id="536">536</span> +<span id="537">537</span> +<span id="538">538</span> +<span id="539">539</span> +<span id="540">540</span> +<span id="541">541</span> +<span id="542">542</span> +<span id="543">543</span> +<span id="544">544</span> +<span id="545">545</span> +<span id="546">546</span> +<span id="547">547</span> +<span id="548">548</span> +<span id="549">549</span> +<span id="550">550</span> +<span id="551">551</span> +<span id="552">552</span> +<span id="553">553</span> +<span id="554">554</span> +<span id="555">555</span> +<span id="556">556</span> +<span id="557">557</span> +<span id="558">558</span> +<span id="559">559</span> +<span id="560">560</span> +<span id="561">561</span> +<span id="562">562</span> +<span id="563">563</span> +<span id="564">564</span> +<span id="565">565</span> +<span id="566">566</span> +<span id="567">567</span> +<span id="568">568</span> +<span id="569">569</span> +<span id="570">570</span> +<span id="571">571</span> +<span id="572">572</span> +<span id="573">573</span> +<span id="574">574</span> +<span id="575">575</span> +<span id="576">576</span> +<span id="577">577</span> +<span id="578">578</span> +<span id="579">579</span> +<span id="580">580</span> +<span id="581">581</span> +<span id="582">582</span> +<span id="583">583</span> +<span id="584">584</span> +<span id="585">585</span> +<span id="586">586</span> +<span id="587">587</span> +<span id="588">588</span> +<span id="589">589</span> +<span id="590">590</span> +<span id="591">591</span> +<span id="592">592</span> +<span id="593">593</span> +<span id="594">594</span> +<span id="595">595</span> +<span id="596">596</span> +<span id="597">597</span> +<span id="598">598</span> +<span id="599">599</span> +<span id="600">600</span> +<span id="601">601</span> +<span id="602">602</span> +<span id="603">603</span> +<span id="604">604</span> +<span id="605">605</span> +<span id="606">606</span> +<span id="607">607</span> +<span id="608">608</span> +<span id="609">609</span> +<span id="610">610</span> +<span id="611">611</span> +<span id="612">612</span> +<span id="613">613</span> +<span id="614">614</span> +<span id="615">615</span> +<span id="616">616</span> +<span id="617">617</span> +<span id="618">618</span> +<span id="619">619</span> +<span id="620">620</span> +<span id="621">621</span> +<span id="622">622</span> +<span id="623">623</span> +<span id="624">624</span> +<span id="625">625</span> +<span id="626">626</span> +<span id="627">627</span> +<span id="628">628</span> +<span id="629">629</span> +<span id="630">630</span> +<span id="631">631</span> +<span id="632">632</span> +<span id="633">633</span> +<span id="634">634</span> +<span id="635">635</span> +<span id="636">636</span> +<span id="637">637</span> +<span id="638">638</span> +<span id="639">639</span> +<span id="640">640</span> +<span id="641">641</span> +<span id="642">642</span> +<span id="643">643</span> +<span id="644">644</span> +<span id="645">645</span> +<span id="646">646</span> +<span id="647">647</span> +<span id="648">648</span> +<span id="649">649</span> +<span id="650">650</span> +<span id="651">651</span> +<span id="652">652</span> +<span id="653">653</span> +<span id="654">654</span> +<span id="655">655</span> +<span id="656">656</span> +<span id="657">657</span> +<span id="658">658</span> +<span id="659">659</span> +<span id="660">660</span> +<span id="661">661</span> +<span id="662">662</span> +<span id="663">663</span> +<span id="664">664</span> +<span id="665">665</span> +<span id="666">666</span> +<span id="667">667</span> +<span id="668">668</span> +<span id="669">669</span> +<span id="670">670</span> +<span id="671">671</span> +<span id="672">672</span> +<span id="673">673</span> +<span id="674">674</span> +<span id="675">675</span> +<span id="676">676</span> +<span id="677">677</span> +<span id="678">678</span> +<span id="679">679</span> +<span id="680">680</span> +<span id="681">681</span> +<span id="682">682</span> +<span id="683">683</span> +<span id="684">684</span> +<span id="685">685</span> +<span id="686">686</span> +<span id="687">687</span> +<span id="688">688</span> +<span id="689">689</span> +<span id="690">690</span> +<span id="691">691</span> +<span id="692">692</span> +<span id="693">693</span> +<span id="694">694</span> +<span id="695">695</span> +<span id="696">696</span> +<span id="697">697</span> +<span id="698">698</span> +<span id="699">699</span> +<span id="700">700</span> +<span id="701">701</span> +<span id="702">702</span> +<span id="703">703</span> +<span id="704">704</span> +<span id="705">705</span> +<span id="706">706</span> +<span id="707">707</span> +<span id="708">708</span> +<span id="709">709</span> +<span id="710">710</span> +<span id="711">711</span> +<span id="712">712</span> +<span id="713">713</span> +<span id="714">714</span> +<span id="715">715</span> +<span id="716">716</span> +<span id="717">717</span> +<span id="718">718</span> +<span id="719">719</span> +<span id="720">720</span> +<span id="721">721</span> +<span id="722">722</span> +<span id="723">723</span> +<span id="724">724</span> +<span id="725">725</span> +<span id="726">726</span> +<span id="727">727</span> +<span id="728">728</span> +<span id="729">729</span> +<span id="730">730</span> +<span id="731">731</span> +<span id="732">732</span> +<span id="733">733</span> +<span id="734">734</span> +<span id="735">735</span> +<span id="736">736</span> +<span id="737">737</span> +<span id="738">738</span> +<span id="739">739</span> +<span id="740">740</span> +<span id="741">741</span> +<span id="742">742</span> +<span id="743">743</span> +<span id="744">744</span> +<span id="745">745</span> +<span id="746">746</span> +<span id="747">747</span> +<span id="748">748</span> +<span id="749">749</span> +<span id="750">750</span> +<span id="751">751</span> +<span id="752">752</span> +<span id="753">753</span> +<span id="754">754</span> +<span id="755">755</span> +<span id="756">756</span> +<span id="757">757</span> +<span id="758">758</span> +<span id="759">759</span> +<span id="760">760</span> +<span id="761">761</span> +<span id="762">762</span> +<span id="763">763</span> +<span id="764">764</span> +<span id="765">765</span> +<span id="766">766</span> +<span id="767">767</span> +<span id="768">768</span> +<span id="769">769</span> +<span id="770">770</span> +<span id="771">771</span> +<span id="772">772</span> +<span id="773">773</span> +<span id="774">774</span> +<span id="775">775</span> +<span id="776">776</span> +<span id="777">777</span> +<span id="778">778</span> +<span id="779">779</span> +<span id="780">780</span> +<span id="781">781</span> +<span id="782">782</span> +<span id="783">783</span> +<span id="784">784</span> +<span id="785">785</span> +<span id="786">786</span> +<span id="787">787</span> +<span id="788">788</span> +<span id="789">789</span> +<span id="790">790</span> +<span id="791">791</span> +<span id="792">792</span> +<span id="793">793</span> +<span id="794">794</span> +<span id="795">795</span> +<span id="796">796</span> +<span id="797">797</span> +<span id="798">798</span> +<span id="799">799</span> +<span id="800">800</span> +<span id="801">801</span> +<span id="802">802</span> +<span id="803">803</span> +<span id="804">804</span> +<span id="805">805</span> +<span id="806">806</span> +<span id="807">807</span> +<span id="808">808</span> +<span id="809">809</span> +<span id="810">810</span> +<span id="811">811</span> +<span id="812">812</span> +<span id="813">813</span> +<span id="814">814</span> +<span id="815">815</span> +<span id="816">816</span> +<span id="817">817</span> +<span id="818">818</span> +<span id="819">819</span> +<span id="820">820</span> +<span id="821">821</span> +<span id="822">822</span> +<span id="823">823</span> +<span id="824">824</span> +<span id="825">825</span> +<span id="826">826</span> +<span id="827">827</span> +<span id="828">828</span> +<span id="829">829</span> +<span id="830">830</span> +<span id="831">831</span> +<span id="832">832</span> +<span id="833">833</span> +<span id="834">834</span> +<span id="835">835</span> +<span id="836">836</span> +<span id="837">837</span> +<span id="838">838</span> +<span id="839">839</span> +<span id="840">840</span> +<span id="841">841</span> +<span id="842">842</span> +<span id="843">843</span> +<span id="844">844</span> +<span id="845">845</span> +<span id="846">846</span> +<span id="847">847</span> +<span id="848">848</span> +<span id="849">849</span> +<span id="850">850</span> +<span id="851">851</span> +<span id="852">852</span> +<span id="853">853</span> +<span id="854">854</span> +<span id="855">855</span> +<span id="856">856</span> +<span id="857">857</span> +<span id="858">858</span> +<span id="859">859</span> +<span id="860">860</span> +<span id="861">861</span> +<span id="862">862</span> +<span id="863">863</span> +</pre><pre class='rust '> +<span class='doccomment'>/*! +An implementation of the +[Aho-Corasick string search algorithm](https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_string_matching_algorithm). + +The Aho-Corasick algorithm is principally useful when you need to search many +large texts for a fixed (possibly large) set of keywords. In particular, the +Aho-Corasick algorithm preprocesses the set of keywords by constructing a +finite state machine. The search phase is then a quick linear scan through the +text. Each character in the search text causes a state transition in the +automaton. Matches are reported when the automaton enters a match state. + +# Examples + +The main type exposed by this crate is `AcAutomaton`, which can be constructed +from an iterator of pattern strings: + +```rust +use aho_corasick::{Automaton, AcAutomaton}; + +let aut = AcAutomaton::new(vec!["apple", "maple"]); + +// AcAutomaton also implements `FromIterator`: +let aut: AcAutomaton = ["apple", "maple"].iter().cloned().collect(); +``` + +Finding matches can be done with `find`: + +```rust +use aho_corasick::{Automaton, AcAutomaton, Match}; + +let aut = AcAutomaton::new(vec!["apple", "maple"]); +let mut it = aut.find("I like maple apples."); +assert_eq!(it.next(), Some(Match { + pati: 1, + start: 7, + end: 12, +})); +assert_eq!(it.next(), Some(Match { + pati: 0, + start: 13, + end: 18, +})); +assert_eq!(it.next(), None); +``` + +Use `find_overlapping` if you want to report all matches, even if they +overlap with each other. + +```rust +use aho_corasick::{Automaton, AcAutomaton, Match}; + +let aut = AcAutomaton::new(vec!["abc", "a"]); +let matches: Vec<_> = aut.find_overlapping("abc").collect(); +assert_eq!(matches, vec![ + Match { pati: 1, start: 0, end: 1}, Match { pati: 0, start: 0, end: 3 }, +]); + +// Regular `find` will report only one match: +let matches: Vec<_> = aut.find("abc").collect(); +assert_eq!(matches, vec![Match { pati: 1, start: 0, end: 1}]); +``` + +Finally, there are also methods for finding matches on *streams*. Namely, the +search text does not have to live in memory. It's useful to run this on files +that can't fit into memory: + +```no_run +use std::fs::File; + +use aho_corasick::{Automaton, AcAutomaton}; + +let aut = AcAutomaton::new(vec!["foo", "bar", "baz"]); +let rdr = File::open("search.txt").unwrap(); +for m in aut.stream_find(rdr) { + let m = m.unwrap(); // could be an IO error + println!("Pattern '{}' matched at: ({}, {})", + aut.pattern(m.pati), m.start, m.end); +} +``` + +There is also `stream_find_overlapping`, which is just like `find_overlapping`, +but it operates on streams. + +Please see `dict-search.rs` in this crate's `examples` directory for a more +complete example. It creates a large automaton from a dictionary and can do a +streaming match over arbitrarily large data. + +# Memory usage + +A key aspect of an Aho-Corasick implementation is how the state transitions +are represented. The easiest way to make the automaton fast is to store a +sparse 256-slot map in each state. It maps an input byte to a state index. +This makes the matching loop extremely fast, since it translates to a simple +pointer read. + +The problem is that as the automaton accumulates more states, you end up paying +a `256 * 4` (`4` is for the `u32` state index) byte penalty for every state +regardless of how many transitions it has. + +To solve this, only states near the root of the automaton have this sparse +map representation. States near the leaves of the automaton use a dense mapping +that requires a linear scan. + +(The specific limit currently set is `3`, so that states with a depth less than +or equal to `3` are less memory efficient. The result is that the memory usage +of the automaton stops growing rapidly past ~60MB, even for automatons with +thousands of patterns.) + +If you'd like to opt for the less-memory-efficient-but-faster version, then +you can construct an `AcAutomaton` with a `Sparse` transition strategy: + +```rust +use aho_corasick::{Automaton, AcAutomaton, Match, Sparse}; + +let aut = AcAutomaton::<Sparse>::with_transitions(vec!["abc", "a"]); +let matches: Vec<_> = aut.find("abc").collect(); +assert_eq!(matches, vec![Match { pati: 1, start: 0, end: 1}]); +``` +*/</span> + +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>deny</span>(<span class='ident'>missing_docs</span>)]</span> + +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>memchr</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> <span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>quickcheck</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> <span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>rand</span>; + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>VecDeque</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>fmt</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>iter</span>::<span class='ident'>FromIterator</span>; + +<span class='kw'>use</span> <span class='ident'>memchr</span>::<span class='ident'>memchr</span>; + +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>autiter</span>::{ + <span class='ident'>Automaton</span>, <span class='ident'>Match</span>, + <span class='ident'>Matches</span>, <span class='ident'>MatchesOverlapping</span>, <span class='ident'>StreamMatches</span>, <span class='ident'>StreamMatchesOverlapping</span>, +}; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>full</span>::<span class='ident'>FullAcAutomaton</span>; + +<span class='comment'>// We're specifying paths explicitly so that we can use</span> +<span class='comment'>// these modules simultaneously from `main.rs`.</span> +<span class='comment'>// Should probably make just make `main.rs` a separate crate.</span> +<span class='attribute'>#[<span class='ident'>path</span> <span class='op'>=</span> <span class='string'>"autiter.rs"</span>]</span> +<span class='kw'>mod</span> <span class='ident'>autiter</span>; +<span class='attribute'>#[<span class='ident'>path</span> <span class='op'>=</span> <span class='string'>"full.rs"</span>]</span> +<span class='kw'>mod</span> <span class='ident'>full</span>; + +<span class='doccomment'>/// The integer type used for the state index.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Limiting this to 32 bit integers can have a big impact on memory usage</span> +<span class='doccomment'>/// when using the `Sparse` transition representation.</span> +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>StateIdx</span> <span class='op'>=</span> <span class='ident'>u32</span>; + +<span class='kw'>type</span> <span class='ident'>PatIdx</span> <span class='op'>=</span> <span class='ident'>usize</span>; + +<span class='comment'>// Constants for special state indexes.</span> +<span class='kw'>const</span> <span class='ident'>FAIL_STATE</span>: <span class='ident'>u32</span> <span class='op'>=</span> <span class='number'>0</span>; +<span class='kw'>const</span> <span class='ident'>ROOT_STATE</span>: <span class='ident'>u32</span> <span class='op'>=</span> <span class='number'>1</span>; + +<span class='comment'>// Limit the depth at which we use a dense alphabet map. Once the limit is</span> +<span class='comment'>// reached, a sparse set is used (and lookup becomes O(n)).</span> +<span class='comment'>//</span> +<span class='comment'>// This does have a performance hit, but the (straight forward) alternative</span> +<span class='comment'>// is to have a `256 * 4` byte overhead for every state.</span> +<span class='comment'>// Given that Aho-Corasick is typically used for dictionary searching, this</span> +<span class='comment'>// can lead to dramatic memory bloat.</span> +<span class='comment'>//</span> +<span class='comment'>// This limit should only be increased at your peril. Namely, in the worst</span> +<span class='comment'>// case, `256^DENSE_DEPTH_THRESHOLD * 4` corresponds to the memory usage in</span> +<span class='comment'>// bytes. A value of `3` gives us a solid cap at around 64MB, which works</span> +<span class='comment'>// well in practice even for dictionary sized automatons.</span> +<span class='comment'>//</span> +<span class='comment'>// Why not make this user configurable? Well, it doesn't make much sense</span> +<span class='comment'>// because we pay for it with case analysis in the matching loop. Increasing it</span> +<span class='comment'>// doesn't have much impact on performance (outside of pathological cases?).</span> +<span class='comment'>//</span> +<span class='comment'>// There is probably room for adding a new automaton type that doesn't have</span> +<span class='comment'>// this restriction.</span> +<span class='comment'>//</span> +<span class='comment'>// N.B. Someone else seems to have discovered an alternative, but I haven't</span> +<span class='comment'>// grokked it yet: https://github.com/mischasan/aho-corasick</span> +<span class='kw'>const</span> <span class='ident'>DENSE_DEPTH_THRESHOLD</span>: <span class='ident'>u32</span> <span class='op'>=</span> <span class='number'>3</span>; + +<span class='doccomment'>/// An Aho-Corasick finite automaton.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>AcAutomaton</span><span class='op'><</span><span class='ident'>T</span><span class='op'>=</span><span class='ident'>Dense</span><span class='op'>></span> { + <span class='ident'>pats</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span>, + <span class='ident'>states</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>State</span><span class='op'><</span><span class='ident'>T</span><span class='op'>>></span>, + <span class='ident'>start_bytes</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, +} + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>)]</span> +<span class='kw'>struct</span> <span class='ident'>State</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='ident'>out</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>PatIdx</span><span class='op'>></span>, + <span class='ident'>fail</span>: <span class='ident'>StateIdx</span>, + <span class='ident'>goto</span>: <span class='ident'>T</span>, + <span class='ident'>depth</span>: <span class='ident'>u32</span>, +} + +<span class='kw'>impl</span> <span class='ident'>AcAutomaton</span> { + <span class='doccomment'>/// Create a new automaton from an iterator of patterns.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The patterns must be convertible to Unicode `String` values via the</span> + <span class='doccomment'>/// `Into` trait.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span><span class='op'><</span><span class='ident'>S</span>, <span class='ident'>I</span><span class='op'>></span>(<span class='ident'>pats</span>: <span class='ident'>I</span>) <span class='op'>-></span> <span class='ident'>AcAutomaton</span><span class='op'><</span><span class='ident'>Dense</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>S</span>: <span class='ident'>Into</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span>, <span class='ident'>I</span>: <span class='ident'>IntoIterator</span><span class='op'><</span><span class='ident'>Item</span><span class='op'>=</span><span class='ident'>S</span><span class='op'>></span> { + <span class='ident'>AcAutomaton</span>::<span class='ident'>with_transitions</span>(<span class='ident'>pats</span>) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>Transitions</span><span class='op'>></span> <span class='ident'>AcAutomaton</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='doccomment'>/// Create a new automaton from an iterator of patterns.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This constructor allows one to choose the transition representation.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The patterns must be convertible to Unicode `String` values via the</span> + <span class='doccomment'>/// `Into` trait.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>with_transitions</span><span class='op'><</span><span class='ident'>S</span>, <span class='ident'>I</span><span class='op'>></span>(<span class='ident'>pats</span>: <span class='ident'>I</span>) <span class='op'>-></span> <span class='ident'>AcAutomaton</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>S</span>: <span class='ident'>Into</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span>, <span class='ident'>I</span>: <span class='ident'>IntoIterator</span><span class='op'><</span><span class='ident'>Item</span><span class='op'>=</span><span class='ident'>S</span><span class='op'>></span> { + <span class='ident'>AcAutomaton</span> { + <span class='ident'>pats</span>: <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='comment'>// filled in later, avoid wrath of borrow checker</span> + <span class='ident'>states</span>: <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>State</span>::<span class='ident'>new</span>(<span class='number'>0</span>), <span class='ident'>State</span>::<span class='ident'>new</span>(<span class='number'>0</span>)], <span class='comment'>// empty and root</span> + <span class='ident'>start_bytes</span>: <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='comment'>// also filled in later</span> + }.<span class='ident'>build</span>(<span class='ident'>pats</span>.<span class='ident'>into_iter</span>().<span class='ident'>map</span>(<span class='ident'>Into</span>::<span class='ident'>into</span>).<span class='ident'>collect</span>()) + } + + <span class='doccomment'>/// Build out the entire automaton into a single matrix.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This will make searching as fast as possible at the expense of using</span> + <span class='doccomment'>/// at least `4 * 256 * #states` bytes of memory.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>into_full</span>(<span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>FullAcAutomaton</span> { + <span class='ident'>FullAcAutomaton</span>::<span class='ident'>new</span>(<span class='self'>self</span>) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>Transitions</span><span class='op'>></span> <span class='ident'>Automaton</span> <span class='kw'>for</span> <span class='ident'>AcAutomaton</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>next_state</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='kw-2'>mut</span> <span class='ident'>si</span>: <span class='ident'>StateIdx</span>, <span class='ident'>b</span>: <span class='ident'>u8</span>) <span class='op'>-></span> <span class='ident'>StateIdx</span> { + <span class='kw'>loop</span> { + <span class='kw'>let</span> <span class='ident'>maybe_si</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>si</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>goto</span>(<span class='ident'>b</span>); + <span class='kw'>if</span> <span class='ident'>maybe_si</span> <span class='op'>!=</span> <span class='ident'>FAIL_STATE</span> { + <span class='ident'>si</span> <span class='op'>=</span> <span class='ident'>maybe_si</span>; + <span class='kw'>break</span>; + } <span class='kw'>else</span> { + <span class='ident'>si</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>si</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>fail</span>; + } + } + <span class='ident'>si</span> + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>get_match</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>si</span>: <span class='ident'>StateIdx</span>, <span class='ident'>outi</span>: <span class='ident'>usize</span>, <span class='ident'>texti</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>Match</span> { + <span class='kw'>let</span> <span class='ident'>pati</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>si</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>out</span>[<span class='ident'>outi</span>]; + <span class='kw'>let</span> <span class='ident'>patlen</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>pats</span>[<span class='ident'>pati</span>].<span class='ident'>len</span>(); + <span class='kw'>let</span> <span class='ident'>start</span> <span class='op'>=</span> <span class='ident'>texti</span> <span class='op'>+</span> <span class='number'>1</span> <span class='op'>-</span> <span class='ident'>patlen</span>; + <span class='ident'>Match</span> { + <span class='ident'>pati</span>: <span class='ident'>pati</span>, + <span class='ident'>start</span>: <span class='ident'>start</span>, + <span class='ident'>end</span>: <span class='ident'>start</span> <span class='op'>+</span> <span class='ident'>patlen</span>, + } + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>has_match</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>si</span>: <span class='ident'>StateIdx</span>, <span class='ident'>outi</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='ident'>outi</span> <span class='op'><</span> <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>si</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>out</span>.<span class='ident'>len</span>() + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>skip_to</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>si</span>: <span class='ident'>StateIdx</span>, <span class='ident'>text</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>], <span class='ident'>at</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='kw'>if</span> <span class='ident'>si</span> <span class='op'>!=</span> <span class='ident'>ROOT_STATE</span> <span class='op'>||</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>is_skippable</span>() { + <span class='kw'>return</span> <span class='ident'>at</span>; + } + <span class='kw'>let</span> <span class='ident'>b</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>start_bytes</span>[<span class='number'>0</span>]; + <span class='kw'>match</span> <span class='ident'>memchr</span>(<span class='ident'>b</span>, <span class='kw-2'>&</span><span class='ident'>text</span>[<span class='ident'>at</span>..]) { + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='ident'>text</span>.<span class='ident'>len</span>(), + <span class='prelude-val'>Some</span>(<span class='ident'>i</span>) <span class='op'>=></span> <span class='ident'>at</span> <span class='op'>+</span> <span class='ident'>i</span>, + } + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>is_skippable</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='self'>self</span>.<span class='ident'>start_bytes</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>1</span> + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>patterns</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span>[<span class='ident'>String</span>] { + <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>pats</span> + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>pattern</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>i</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>str</span> { + <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>pats</span>[<span class='ident'>i</span>] + } +} + +<span class='comment'>// Below contains code for *building* the automaton. It's a reasonably faithful</span> +<span class='comment'>// translation of the description/psuedo-code from:</span> +<span class='comment'>// http://www.cs.uku.fi/~kilpelai/BSA05/lectures/slides04.pdf</span> + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>Transitions</span><span class='op'>></span> <span class='ident'>AcAutomaton</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='comment'>// This is the first phase and builds the initial keyword tree.</span> + <span class='kw'>fn</span> <span class='ident'>build</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>pats</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>AcAutomaton</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='kw'>for</span> (<span class='ident'>pati</span>, <span class='ident'>pat</span>) <span class='kw'>in</span> <span class='ident'>pats</span>.<span class='ident'>iter</span>().<span class='ident'>enumerate</span>() { + <span class='kw'>if</span> <span class='ident'>pat</span>.<span class='ident'>is_empty</span>() { + <span class='kw'>continue</span>; + } + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>previ</span> <span class='op'>=</span> <span class='ident'>ROOT_STATE</span>; + <span class='kw'>for</span> <span class='kw-2'>&</span><span class='ident'>b</span> <span class='kw'>in</span> <span class='ident'>pat</span>.<span class='ident'>as_bytes</span>() { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>previ</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>goto</span>(<span class='ident'>b</span>) <span class='op'>!=</span> <span class='ident'>FAIL_STATE</span> { + <span class='ident'>previ</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>previ</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>goto</span>(<span class='ident'>b</span>); + } <span class='kw'>else</span> { + <span class='kw'>let</span> <span class='ident'>depth</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>previ</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>depth</span> <span class='op'>+</span> <span class='number'>1</span>; + <span class='kw'>let</span> <span class='ident'>nexti</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>add_state</span>(<span class='ident'>State</span>::<span class='ident'>new</span>(<span class='ident'>depth</span>)); + <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>previ</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>set_goto</span>(<span class='ident'>b</span>, <span class='ident'>nexti</span>); + <span class='ident'>previ</span> <span class='op'>=</span> <span class='ident'>nexti</span>; + } + } + <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>previ</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>out</span>.<span class='ident'>push</span>(<span class='ident'>pati</span>); + } + <span class='kw'>for</span> <span class='ident'>c</span> <span class='kw'>in</span> (<span class='number'>0</span>..<span class='number'>256</span>).<span class='ident'>into_iter</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='kw'>as</span> <span class='ident'>u8</span>) { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>ROOT_STATE</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>goto</span>(<span class='ident'>c</span>) <span class='op'>==</span> <span class='ident'>FAIL_STATE</span> { + <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>ROOT_STATE</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>set_goto</span>(<span class='ident'>c</span>, <span class='ident'>ROOT_STATE</span>); + } <span class='kw'>else</span> { + <span class='self'>self</span>.<span class='ident'>start_bytes</span>.<span class='ident'>push</span>(<span class='ident'>c</span>); + } + } + <span class='self'>self</span>.<span class='ident'>pats</span> <span class='op'>=</span> <span class='ident'>pats</span>; + <span class='self'>self</span>.<span class='ident'>fill</span>() + } + + <span class='comment'>// The second phase that fills in the back links.</span> + <span class='kw'>fn</span> <span class='ident'>fill</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>AcAutomaton</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='comment'>// Fill up the queue with all non-root transitions out of the root</span> + <span class='comment'>// node. Then proceed by breadth first traversal.</span> + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>q</span> <span class='op'>=</span> <span class='ident'>VecDeque</span>::<span class='ident'>new</span>(); + <span class='kw'>for</span> <span class='ident'>c</span> <span class='kw'>in</span> (<span class='number'>0</span>..<span class='number'>256</span>).<span class='ident'>into_iter</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='kw'>as</span> <span class='ident'>u8</span>) { + <span class='kw'>let</span> <span class='ident'>si</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>ROOT_STATE</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>goto</span>(<span class='ident'>c</span>); + <span class='kw'>if</span> <span class='ident'>si</span> <span class='op'>!=</span> <span class='ident'>ROOT_STATE</span> { + <span class='ident'>q</span>.<span class='ident'>push_front</span>(<span class='ident'>si</span>); + } + } + <span class='kw'>while</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>si</span>) <span class='op'>=</span> <span class='ident'>q</span>.<span class='ident'>pop_back</span>() { + <span class='kw'>for</span> <span class='ident'>c</span> <span class='kw'>in</span> (<span class='number'>0</span>..<span class='number'>256</span>).<span class='ident'>into_iter</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='kw'>as</span> <span class='ident'>u8</span>) { + <span class='kw'>let</span> <span class='ident'>u</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>si</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>goto</span>(<span class='ident'>c</span>); + <span class='kw'>if</span> <span class='ident'>u</span> <span class='op'>!=</span> <span class='ident'>FAIL_STATE</span> { + <span class='ident'>q</span>.<span class='ident'>push_front</span>(<span class='ident'>u</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>si</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>fail</span>; + <span class='kw'>while</span> <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>v</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>goto</span>(<span class='ident'>c</span>) <span class='op'>==</span> <span class='ident'>FAIL_STATE</span> { + <span class='ident'>v</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>v</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>fail</span>; + } + <span class='kw'>let</span> <span class='ident'>ufail</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>v</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>goto</span>(<span class='ident'>c</span>); + <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>u</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>fail</span> <span class='op'>=</span> <span class='ident'>ufail</span>; + <span class='kw'>let</span> <span class='ident'>ufail_out</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>ufail</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>out</span>.<span class='ident'>clone</span>(); + <span class='self'>self</span>.<span class='ident'>states</span>[<span class='ident'>u</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>out</span>.<span class='ident'>extend</span>(<span class='ident'>ufail_out</span>); + } + } + } + <span class='self'>self</span> + } + + <span class='kw'>fn</span> <span class='ident'>add_state</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>state</span>: <span class='ident'>State</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>StateIdx</span> { + <span class='kw'>let</span> <span class='ident'>i</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>states</span>.<span class='ident'>len</span>(); + <span class='self'>self</span>.<span class='ident'>states</span>.<span class='ident'>push</span>(<span class='ident'>state</span>); + <span class='ident'>i</span> <span class='kw'>as</span> <span class='ident'>StateIdx</span> + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>Transitions</span><span class='op'>></span> <span class='ident'>State</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>depth</span>: <span class='ident'>u32</span>) <span class='op'>-></span> <span class='ident'>State</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='ident'>State</span> { + <span class='ident'>out</span>: <span class='macro'>vec</span><span class='macro'>!</span>[], + <span class='ident'>fail</span>: <span class='number'>1</span>, + <span class='ident'>goto</span>: <span class='ident'>Transitions</span>::<span class='ident'>new</span>(<span class='ident'>depth</span>), + <span class='ident'>depth</span>: <span class='ident'>depth</span>, + } + } + + <span class='kw'>fn</span> <span class='ident'>goto</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>b</span>: <span class='ident'>u8</span>) <span class='op'>-></span> <span class='ident'>StateIdx</span> { <span class='self'>self</span>.<span class='ident'>goto</span>.<span class='ident'>goto</span>(<span class='ident'>b</span>) } + <span class='kw'>fn</span> <span class='ident'>set_goto</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>b</span>: <span class='ident'>u8</span>, <span class='ident'>si</span>: <span class='ident'>StateIdx</span>) { <span class='self'>self</span>.<span class='ident'>goto</span>.<span class='ident'>set_goto</span>(<span class='ident'>b</span>, <span class='ident'>si</span>); } +} + +<span class='doccomment'>/// An abstraction over state transition strategies.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This is an attempt to let the caller choose the space/time trade offs</span> +<span class='doccomment'>/// used for state transitions.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// (It's possible that this interface is merely good enough for just the two</span> +<span class='doccomment'>/// implementations in this crate.)</span> +<span class='kw'>pub</span> <span class='kw'>trait</span> <span class='ident'>Transitions</span> { + <span class='doccomment'>/// Return a new state at the given depth.</span> + <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>depth</span>: <span class='ident'>u32</span>) <span class='op'>-></span> <span class='kw'>Self</span>; + <span class='doccomment'>/// Return the next state index given the next character.</span> + <span class='kw'>fn</span> <span class='ident'>goto</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>alpha</span>: <span class='ident'>u8</span>) <span class='op'>-></span> <span class='ident'>StateIdx</span>; + <span class='doccomment'>/// Set the next state index for the character given.</span> + <span class='kw'>fn</span> <span class='ident'>set_goto</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>alpha</span>: <span class='ident'>u8</span>, <span class='ident'>si</span>: <span class='ident'>StateIdx</span>); +} + +<span class='doccomment'>/// State transitions that can be stored either sparsely or densely.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This uses less space but at the expense of slower matching.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Dense</span>(<span class='ident'>DenseChoice</span>); + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Debug</span>)]</span> +<span class='kw'>enum</span> <span class='ident'>DenseChoice</span> { + <span class='ident'>Sparse</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>StateIdx</span><span class='op'>></span>), <span class='comment'>// indexed by alphabet</span> + <span class='ident'>Dense</span>(<span class='ident'>Vec</span><span class='op'><</span>(<span class='ident'>u8</span>, <span class='ident'>StateIdx</span>)<span class='op'>></span>), +} + +<span class='kw'>impl</span> <span class='ident'>Transitions</span> <span class='kw'>for</span> <span class='ident'>Dense</span> { + <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>depth</span>: <span class='ident'>u32</span>) <span class='op'>-></span> <span class='ident'>Dense</span> { + <span class='kw'>if</span> <span class='ident'>depth</span> <span class='op'><=</span> <span class='ident'>DENSE_DEPTH_THRESHOLD</span> { + <span class='ident'>Dense</span>(<span class='ident'>DenseChoice</span>::<span class='ident'>Sparse</span>(<span class='macro'>vec</span><span class='macro'>!</span>[<span class='number'>0</span>; <span class='number'>256</span>])) + } <span class='kw'>else</span> { + <span class='ident'>Dense</span>(<span class='ident'>DenseChoice</span>::<span class='ident'>Dense</span>(<span class='macro'>vec</span><span class='macro'>!</span>[])) + } + } + + <span class='kw'>fn</span> <span class='ident'>goto</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>b1</span>: <span class='ident'>u8</span>) <span class='op'>-></span> <span class='ident'>StateIdx</span> { + <span class='kw'>match</span> <span class='self'>self</span>.<span class='number'>0</span> { + <span class='ident'>DenseChoice</span>::<span class='ident'>Sparse</span>(<span class='kw-2'>ref</span> <span class='ident'>m</span>) <span class='op'>=></span> <span class='ident'>m</span>[<span class='ident'>b1</span> <span class='kw'>as</span> <span class='ident'>usize</span>], + <span class='ident'>DenseChoice</span>::<span class='ident'>Dense</span>(<span class='kw-2'>ref</span> <span class='ident'>m</span>) <span class='op'>=></span> { + <span class='kw'>for</span> <span class='kw-2'>&</span>(<span class='ident'>b2</span>, <span class='ident'>si</span>) <span class='kw'>in</span> <span class='ident'>m</span> { + <span class='kw'>if</span> <span class='ident'>b1</span> <span class='op'>==</span> <span class='ident'>b2</span> { + <span class='kw'>return</span> <span class='ident'>si</span>; + } + } + <span class='ident'>FAIL_STATE</span> + } + } + } + + <span class='kw'>fn</span> <span class='ident'>set_goto</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>b</span>: <span class='ident'>u8</span>, <span class='ident'>si</span>: <span class='ident'>StateIdx</span>) { + <span class='kw'>match</span> <span class='self'>self</span>.<span class='number'>0</span> { + <span class='ident'>DenseChoice</span>::<span class='ident'>Sparse</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>m</span>) <span class='op'>=></span> <span class='ident'>m</span>[<span class='ident'>b</span> <span class='kw'>as</span> <span class='ident'>usize</span>] <span class='op'>=</span> <span class='ident'>si</span>, + <span class='ident'>DenseChoice</span>::<span class='ident'>Dense</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>m</span>) <span class='op'>=></span> <span class='ident'>m</span>.<span class='ident'>push</span>((<span class='ident'>b</span>, <span class='ident'>si</span>)), + } + } +} + +<span class='doccomment'>/// State transitions that are always sparse.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This can use enormous amounts of memory when there are many patterns,</span> +<span class='doccomment'>/// but matching is very fast.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Sparse</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>StateIdx</span><span class='op'>></span>); + +<span class='kw'>impl</span> <span class='ident'>Transitions</span> <span class='kw'>for</span> <span class='ident'>Sparse</span> { + <span class='kw'>fn</span> <span class='ident'>new</span>(_: <span class='ident'>u32</span>) <span class='op'>-></span> <span class='ident'>Sparse</span> { + <span class='ident'>Sparse</span>(<span class='macro'>vec</span><span class='macro'>!</span>[<span class='number'>0</span>; <span class='number'>256</span>]) + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>goto</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>b</span>: <span class='ident'>u8</span>) <span class='op'>-></span> <span class='ident'>StateIdx</span> { + <span class='self'>self</span>.<span class='number'>0</span>[<span class='ident'>b</span> <span class='kw'>as</span> <span class='ident'>usize</span>] + } + + <span class='kw'>fn</span> <span class='ident'>set_goto</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>b</span>: <span class='ident'>u8</span>, <span class='ident'>si</span>: <span class='ident'>StateIdx</span>) { + <span class='self'>self</span>.<span class='number'>0</span>[<span class='ident'>b</span> <span class='kw'>as</span> <span class='ident'>usize</span>] <span class='op'>=</span> <span class='ident'>si</span>; + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>S</span>: <span class='ident'>Into</span><span class='op'><</span><span class='ident'>String</span><span class='op'>>></span> <span class='ident'>FromIterator</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>AcAutomaton</span> { + <span class='doccomment'>/// Create an automaton from an iterator of strings.</span> + <span class='kw'>fn</span> <span class='ident'>from_iter</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span>(<span class='ident'>it</span>: <span class='ident'>T</span>) <span class='op'>-></span> <span class='ident'>AcAutomaton</span> <span class='kw'>where</span> <span class='ident'>T</span>: <span class='ident'>IntoIterator</span><span class='op'><</span><span class='ident'>Item</span><span class='op'>=</span><span class='ident'>S</span><span class='op'>></span> { + <span class='ident'>AcAutomaton</span>::<span class='ident'>new</span>(<span class='ident'>it</span>) + } +} + +<span class='comment'>// Provide some question debug impls for viewing automatons.</span> +<span class='comment'>// The custom impls mostly exist for special showing of sparse maps.</span> + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>Transitions</span><span class='op'>></span> <span class='ident'>fmt</span>::<span class='ident'>Debug</span> <span class='kw'>for</span> <span class='ident'>AcAutomaton</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>iter</span>::<span class='ident'>repeat</span>; + + <span class='macro'>try</span><span class='macro'>!</span>(<span class='macro'>writeln</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"{}"</span>, <span class='ident'>repeat</span>(<span class='string'>'-'</span>).<span class='ident'>take</span>(<span class='number'>79</span>).<span class='ident'>collect</span>::<span class='op'><</span><span class='ident'>String</span><span class='op'>></span>())); + <span class='macro'>try</span><span class='macro'>!</span>(<span class='macro'>writeln</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Patterns: {:?}"</span>, <span class='self'>self</span>.<span class='ident'>pats</span>)); + <span class='kw'>for</span> (<span class='ident'>i</span>, <span class='ident'>state</span>) <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>states</span>.<span class='ident'>iter</span>().<span class='ident'>enumerate</span>().<span class='ident'>skip</span>(<span class='number'>1</span>) { + <span class='macro'>try</span><span class='macro'>!</span>(<span class='macro'>writeln</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"{:3}: {}"</span>, <span class='ident'>i</span>, <span class='ident'>state</span>.<span class='ident'>debug</span>(<span class='ident'>i</span> <span class='op'>==</span> <span class='number'>1</span>))); + } + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"{}"</span>, <span class='ident'>repeat</span>(<span class='string'>'-'</span>).<span class='ident'>take</span>(<span class='number'>79</span>).<span class='ident'>collect</span>::<span class='op'><</span><span class='ident'>String</span><span class='op'>></span>()) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>Transitions</span><span class='op'>></span> <span class='ident'>State</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>debug</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>root</span>: <span class='ident'>bool</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"State {{ depth: {:?}, out: {:?}, fail: {:?}, goto: {{{}}} }}"</span>, + <span class='self'>self</span>.<span class='ident'>depth</span>, <span class='self'>self</span>.<span class='ident'>out</span>, <span class='self'>self</span>.<span class='ident'>fail</span>, <span class='self'>self</span>.<span class='ident'>goto_string</span>(<span class='ident'>root</span>)) + } + + <span class='kw'>fn</span> <span class='ident'>goto_string</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>root</span>: <span class='ident'>bool</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>char</span>::<span class='ident'>from_u32</span>; + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>goto</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[]; + <span class='kw'>for</span> <span class='ident'>b</span> <span class='kw'>in</span> (<span class='number'>0</span>..<span class='number'>256</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>b</span><span class='op'>|</span> <span class='ident'>b</span> <span class='kw'>as</span> <span class='ident'>u8</span>) { + <span class='kw'>let</span> <span class='ident'>si</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>goto</span>(<span class='ident'>b</span>); + <span class='kw'>if</span> (<span class='op'>!</span><span class='ident'>root</span> <span class='op'>&&</span> <span class='ident'>si</span> <span class='op'>==</span> <span class='ident'>FAIL_STATE</span>) <span class='op'>||</span> (<span class='ident'>root</span> <span class='op'>&&</span> <span class='ident'>si</span> <span class='op'>==</span> <span class='ident'>ROOT_STATE</span>) { + <span class='kw'>continue</span>; + } + <span class='ident'>goto</span>.<span class='ident'>push</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{} => {}"</span>, <span class='ident'>from_u32</span>(<span class='ident'>b</span> <span class='kw'>as</span> <span class='ident'>u32</span>).<span class='ident'>unwrap</span>(), <span class='ident'>si</span>)); + } + <span class='ident'>goto</span>.<span class='ident'>connect</span>(<span class='string'>", "</span>) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>Transitions</span><span class='op'>></span> <span class='ident'>fmt</span>::<span class='ident'>Debug</span> <span class='kw'>for</span> <span class='ident'>State</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"{}"</span>, <span class='self'>self</span>.<span class='ident'>debug</span>(<span class='boolval'>false</span>)) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>Transitions</span><span class='op'>></span> <span class='ident'>AcAutomaton</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>dot</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>fmt</span>::<span class='ident'>Write</span>; + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>out</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>new</span>(); + <span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>w</span> { + (<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>w</span>:<span class='ident'>expr</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>tt</span>:<span class='ident'>tt</span>)<span class='op'>*</span>) <span class='op'>=></span> { {<span class='macro'>write</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>w</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>tt</span>)<span class='op'>*</span>)}.<span class='ident'>unwrap</span>() } + } + + <span class='macro'>w</span><span class='macro'>!</span>(<span class='ident'>out</span>, <span class='string'>r#" +digraph automaton {{ + label=<<FONT POINT-SIZE="20">{}</FONT>>; + labelloc="l"; + labeljust="l"; + rankdir="LR"; +"#</span>, <span class='self'>self</span>.<span class='ident'>pats</span>.<span class='ident'>connect</span>(<span class='string'>", "</span>)); + <span class='kw'>for</span> (<span class='ident'>i</span>, <span class='ident'>s</span>) <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>states</span>.<span class='ident'>iter</span>().<span class='ident'>enumerate</span>().<span class='ident'>skip</span>(<span class='number'>1</span>) { + <span class='kw'>let</span> <span class='ident'>i</span> <span class='op'>=</span> <span class='ident'>i</span> <span class='kw'>as</span> <span class='ident'>u32</span>; + <span class='kw'>if</span> <span class='ident'>s</span>.<span class='ident'>out</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>0</span> { + <span class='macro'>w</span><span class='macro'>!</span>(<span class='ident'>out</span>, <span class='string'>" {};\n"</span>, <span class='ident'>i</span>); + } <span class='kw'>else</span> { + <span class='macro'>w</span><span class='macro'>!</span>(<span class='ident'>out</span>, <span class='string'>" {} [peripheries=2];\n"</span>, <span class='ident'>i</span>); + } + <span class='macro'>w</span><span class='macro'>!</span>(<span class='ident'>out</span>, <span class='string'>" {} -> {} [style=dashed];\n"</span>, <span class='ident'>i</span>, <span class='ident'>s</span>.<span class='ident'>fail</span>); + <span class='kw'>for</span> <span class='ident'>b</span> <span class='kw'>in</span> (<span class='number'>0</span>..<span class='number'>256</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>b</span><span class='op'>|</span> <span class='ident'>b</span> <span class='kw'>as</span> <span class='ident'>u8</span>) { + <span class='kw'>let</span> <span class='ident'>si</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>goto</span>(<span class='ident'>b</span>); + <span class='kw'>if</span> <span class='ident'>si</span> <span class='op'>==</span> <span class='ident'>FAIL_STATE</span> <span class='op'>||</span> (<span class='ident'>i</span> <span class='op'>==</span> <span class='ident'>ROOT_STATE</span> <span class='op'>&&</span> <span class='ident'>si</span> <span class='op'>==</span> <span class='ident'>ROOT_STATE</span>) { + <span class='kw'>continue</span>; + } + <span class='macro'>w</span><span class='macro'>!</span>(<span class='ident'>out</span>, <span class='string'>" {} -> {} [label={}];\n"</span>, <span class='ident'>i</span>, <span class='ident'>si</span>, <span class='ident'>b</span> <span class='kw'>as</span> <span class='ident'>char</span>); + } + } + <span class='macro'>w</span><span class='macro'>!</span>(<span class='ident'>out</span>, <span class='string'>"}}"</span>); + <span class='ident'>out</span> + } +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>tests</span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashSet</span>; + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>; + + <span class='kw'>use</span> <span class='ident'>quickcheck</span>::{<span class='ident'>Arbitrary</span>, <span class='ident'>Gen</span>, <span class='ident'>quickcheck</span>}; + <span class='kw'>use</span> <span class='ident'>rand</span>::<span class='ident'>Rng</span>; + + <span class='kw'>use</span> <span class='ident'>super</span>::{<span class='ident'>Automaton</span>, <span class='ident'>AcAutomaton</span>, <span class='ident'>Match</span>}; + + <span class='kw'>fn</span> <span class='ident'>aut_find</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span>(<span class='ident'>xs</span>: <span class='kw-2'>&</span>[<span class='ident'>S</span>], <span class='ident'>haystack</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Match</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>S</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Into</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='ident'>AcAutomaton</span>::<span class='ident'>new</span>(<span class='ident'>xs</span>.<span class='ident'>to_vec</span>()).<span class='ident'>find</span>(<span class='kw-2'>&</span><span class='ident'>haystack</span>).<span class='ident'>collect</span>() + } + + <span class='kw'>fn</span> <span class='ident'>aut_finds</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span>(<span class='ident'>xs</span>: <span class='kw-2'>&</span>[<span class='ident'>S</span>], <span class='ident'>haystack</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Match</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>S</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Into</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>cur</span> <span class='op'>=</span> <span class='ident'>io</span>::<span class='ident'>Cursor</span>::<span class='ident'>new</span>(<span class='ident'>haystack</span>.<span class='ident'>as_bytes</span>()); + <span class='ident'>AcAutomaton</span>::<span class='ident'>new</span>(<span class='ident'>xs</span>.<span class='ident'>to_vec</span>()) + .<span class='ident'>stream_find</span>(<span class='ident'>cur</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>r</span><span class='op'>|</span> <span class='ident'>r</span>.<span class='ident'>unwrap</span>()).<span class='ident'>collect</span>() + } + + <span class='kw'>fn</span> <span class='ident'>aut_findf</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span>(<span class='ident'>xs</span>: <span class='kw-2'>&</span>[<span class='ident'>S</span>], <span class='ident'>haystack</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Match</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>S</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Into</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='ident'>AcAutomaton</span>::<span class='ident'>new</span>(<span class='ident'>xs</span>.<span class='ident'>to_vec</span>()).<span class='ident'>into_full</span>().<span class='ident'>find</span>(<span class='ident'>haystack</span>).<span class='ident'>collect</span>() + } + + <span class='kw'>fn</span> <span class='ident'>aut_findfs</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span>(<span class='ident'>xs</span>: <span class='kw-2'>&</span>[<span class='ident'>S</span>], <span class='ident'>haystack</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Match</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>S</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Into</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>cur</span> <span class='op'>=</span> <span class='ident'>io</span>::<span class='ident'>Cursor</span>::<span class='ident'>new</span>(<span class='ident'>haystack</span>.<span class='ident'>as_bytes</span>()); + <span class='ident'>AcAutomaton</span>::<span class='ident'>new</span>(<span class='ident'>xs</span>.<span class='ident'>to_vec</span>()) + .<span class='ident'>into_full</span>() + .<span class='ident'>stream_find</span>(<span class='ident'>cur</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>r</span><span class='op'>|</span> <span class='ident'>r</span>.<span class='ident'>unwrap</span>()).<span class='ident'>collect</span>() + } + + <span class='kw'>fn</span> <span class='ident'>aut_findo</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span>(<span class='ident'>xs</span>: <span class='kw-2'>&</span>[<span class='ident'>S</span>], <span class='ident'>haystack</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Match</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>S</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Into</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='ident'>AcAutomaton</span>::<span class='ident'>new</span>(<span class='ident'>xs</span>.<span class='ident'>to_vec</span>()).<span class='ident'>find_overlapping</span>(<span class='ident'>haystack</span>).<span class='ident'>collect</span>() + } + + <span class='kw'>fn</span> <span class='ident'>aut_findos</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span>(<span class='ident'>xs</span>: <span class='kw-2'>&</span>[<span class='ident'>S</span>], <span class='ident'>haystack</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Match</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>S</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Into</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>cur</span> <span class='op'>=</span> <span class='ident'>io</span>::<span class='ident'>Cursor</span>::<span class='ident'>new</span>(<span class='ident'>haystack</span>.<span class='ident'>as_bytes</span>()); + <span class='ident'>AcAutomaton</span>::<span class='ident'>new</span>(<span class='ident'>xs</span>.<span class='ident'>to_vec</span>()) + .<span class='ident'>stream_find_overlapping</span>(<span class='ident'>cur</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>r</span><span class='op'>|</span> <span class='ident'>r</span>.<span class='ident'>unwrap</span>()).<span class='ident'>collect</span>() + } + + <span class='kw'>fn</span> <span class='ident'>aut_findfo</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span>(<span class='ident'>xs</span>: <span class='kw-2'>&</span>[<span class='ident'>S</span>], <span class='ident'>haystack</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Match</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>S</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Into</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='ident'>AcAutomaton</span>::<span class='ident'>new</span>(<span class='ident'>xs</span>.<span class='ident'>to_vec</span>()) + .<span class='ident'>into_full</span>().<span class='ident'>find_overlapping</span>(<span class='ident'>haystack</span>).<span class='ident'>collect</span>() + } + + <span class='kw'>fn</span> <span class='ident'>aut_findfos</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span>(<span class='ident'>xs</span>: <span class='kw-2'>&</span>[<span class='ident'>S</span>], <span class='ident'>haystack</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Match</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>S</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Into</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>cur</span> <span class='op'>=</span> <span class='ident'>io</span>::<span class='ident'>Cursor</span>::<span class='ident'>new</span>(<span class='ident'>haystack</span>.<span class='ident'>as_bytes</span>()); + <span class='ident'>AcAutomaton</span>::<span class='ident'>new</span>(<span class='ident'>xs</span>.<span class='ident'>to_vec</span>()) + .<span class='ident'>into_full</span>() + .<span class='ident'>stream_find_overlapping</span>(<span class='ident'>cur</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>r</span><span class='op'>|</span> <span class='ident'>r</span>.<span class='ident'>unwrap</span>()).<span class='ident'>collect</span>() + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>one_pattern_one_match</span>() { + <span class='kw'>let</span> <span class='ident'>ns</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"a"</span>]; + <span class='kw'>let</span> <span class='ident'>hay</span> <span class='op'>=</span> <span class='string'>"za"</span>; + <span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>0</span>, <span class='ident'>start</span>: <span class='number'>1</span>, <span class='ident'>end</span>: <span class='number'>2</span> }, + ]; + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_find</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_finds</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findf</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findfs</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>one_pattern_many_match</span>() { + <span class='kw'>let</span> <span class='ident'>ns</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"a"</span>]; + <span class='kw'>let</span> <span class='ident'>hay</span> <span class='op'>=</span> <span class='string'>"zazazzzza"</span>; + <span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>0</span>, <span class='ident'>start</span>: <span class='number'>1</span>, <span class='ident'>end</span>: <span class='number'>2</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>0</span>, <span class='ident'>start</span>: <span class='number'>3</span>, <span class='ident'>end</span>: <span class='number'>4</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>0</span>, <span class='ident'>start</span>: <span class='number'>8</span>, <span class='ident'>end</span>: <span class='number'>9</span> }, + ]; + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_find</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_finds</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findf</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findfs</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>one_longer_pattern_one_match</span>() { + <span class='kw'>let</span> <span class='ident'>ns</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"abc"</span>]; + <span class='kw'>let</span> <span class='ident'>hay</span> <span class='op'>=</span> <span class='string'>"zazabcz"</span>; + <span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[ <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>0</span>, <span class='ident'>start</span>: <span class='number'>3</span>, <span class='ident'>end</span>: <span class='number'>6</span> } ]; + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_find</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_finds</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findf</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findfs</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>one_longer_pattern_many_match</span>() { + <span class='kw'>let</span> <span class='ident'>ns</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"abc"</span>]; + <span class='kw'>let</span> <span class='ident'>hay</span> <span class='op'>=</span> <span class='string'>"zazabczzzzazzzabc"</span>; + <span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>0</span>, <span class='ident'>start</span>: <span class='number'>3</span>, <span class='ident'>end</span>: <span class='number'>6</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>0</span>, <span class='ident'>start</span>: <span class='number'>14</span>, <span class='ident'>end</span>: <span class='number'>17</span> }, + ]; + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_find</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_finds</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findf</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findfs</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>many_pattern_one_match</span>() { + <span class='kw'>let</span> <span class='ident'>ns</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"a"</span>, <span class='string'>"b"</span>]; + <span class='kw'>let</span> <span class='ident'>hay</span> <span class='op'>=</span> <span class='string'>"zb"</span>; + <span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[ <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>1</span>, <span class='ident'>start</span>: <span class='number'>1</span>, <span class='ident'>end</span>: <span class='number'>2</span> } ]; + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_find</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_finds</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findf</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findfs</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>many_pattern_many_match</span>() { + <span class='kw'>let</span> <span class='ident'>ns</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"a"</span>, <span class='string'>"b"</span>]; + <span class='kw'>let</span> <span class='ident'>hay</span> <span class='op'>=</span> <span class='string'>"zbzazzzzb"</span>; + <span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>1</span>, <span class='ident'>start</span>: <span class='number'>1</span>, <span class='ident'>end</span>: <span class='number'>2</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>0</span>, <span class='ident'>start</span>: <span class='number'>3</span>, <span class='ident'>end</span>: <span class='number'>4</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>1</span>, <span class='ident'>start</span>: <span class='number'>8</span>, <span class='ident'>end</span>: <span class='number'>9</span> }, + ]; + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_find</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_finds</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findf</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findfs</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>many_longer_pattern_one_match</span>() { + <span class='kw'>let</span> <span class='ident'>ns</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"abc"</span>, <span class='string'>"xyz"</span>]; + <span class='kw'>let</span> <span class='ident'>hay</span> <span class='op'>=</span> <span class='string'>"zazxyzz"</span>; + <span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[ <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>1</span>, <span class='ident'>start</span>: <span class='number'>3</span>, <span class='ident'>end</span>: <span class='number'>6</span> } ]; + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_find</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_finds</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findf</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findfs</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>many_longer_pattern_many_match</span>() { + <span class='kw'>let</span> <span class='ident'>ns</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"abc"</span>, <span class='string'>"xyz"</span>]; + <span class='kw'>let</span> <span class='ident'>hay</span> <span class='op'>=</span> <span class='string'>"zazxyzzzzzazzzabcxyz"</span>; + <span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>1</span>, <span class='ident'>start</span>: <span class='number'>3</span>, <span class='ident'>end</span>: <span class='number'>6</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>0</span>, <span class='ident'>start</span>: <span class='number'>14</span>, <span class='ident'>end</span>: <span class='number'>17</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>1</span>, <span class='ident'>start</span>: <span class='number'>17</span>, <span class='ident'>end</span>: <span class='number'>20</span> }, + ]; + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_find</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_finds</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findf</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findfs</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>many_longer_pattern_overlap_one_match</span>() { + <span class='kw'>let</span> <span class='ident'>ns</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"abc"</span>, <span class='string'>"bc"</span>]; + <span class='kw'>let</span> <span class='ident'>hay</span> <span class='op'>=</span> <span class='string'>"zazabcz"</span>; + <span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>0</span>, <span class='ident'>start</span>: <span class='number'>3</span>, <span class='ident'>end</span>: <span class='number'>6</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>1</span>, <span class='ident'>start</span>: <span class='number'>4</span>, <span class='ident'>end</span>: <span class='number'>6</span> }, + ]; + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findo</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findos</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findfo</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findfos</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>many_longer_pattern_overlap_one_match_reverse</span>() { + <span class='kw'>let</span> <span class='ident'>ns</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"abc"</span>, <span class='string'>"bc"</span>]; + <span class='kw'>let</span> <span class='ident'>hay</span> <span class='op'>=</span> <span class='string'>"xbc"</span>; + <span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[ <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>1</span>, <span class='ident'>start</span>: <span class='number'>1</span>, <span class='ident'>end</span>: <span class='number'>3</span> } ]; + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findo</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findos</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findfo</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findfos</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>many_longer_pattern_overlap_many_match</span>() { + <span class='kw'>let</span> <span class='ident'>ns</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"abc"</span>, <span class='string'>"bc"</span>, <span class='string'>"c"</span>]; + <span class='kw'>let</span> <span class='ident'>hay</span> <span class='op'>=</span> <span class='string'>"zzzabczzzbczzzc"</span>; + <span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>0</span>, <span class='ident'>start</span>: <span class='number'>3</span>, <span class='ident'>end</span>: <span class='number'>6</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>1</span>, <span class='ident'>start</span>: <span class='number'>4</span>, <span class='ident'>end</span>: <span class='number'>6</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>2</span>, <span class='ident'>start</span>: <span class='number'>5</span>, <span class='ident'>end</span>: <span class='number'>6</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>1</span>, <span class='ident'>start</span>: <span class='number'>9</span>, <span class='ident'>end</span>: <span class='number'>11</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>2</span>, <span class='ident'>start</span>: <span class='number'>10</span>, <span class='ident'>end</span>: <span class='number'>11</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>2</span>, <span class='ident'>start</span>: <span class='number'>14</span>, <span class='ident'>end</span>: <span class='number'>15</span> }, + ]; + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findo</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findos</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findfo</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findfos</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>many_longer_pattern_overlap_many_match_reverse</span>() { + <span class='kw'>let</span> <span class='ident'>ns</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"abc"</span>, <span class='string'>"bc"</span>, <span class='string'>"c"</span>]; + <span class='kw'>let</span> <span class='ident'>hay</span> <span class='op'>=</span> <span class='string'>"zzzczzzbczzzabc"</span>; + <span class='kw'>let</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>2</span>, <span class='ident'>start</span>: <span class='number'>3</span>, <span class='ident'>end</span>: <span class='number'>4</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>1</span>, <span class='ident'>start</span>: <span class='number'>7</span>, <span class='ident'>end</span>: <span class='number'>9</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>2</span>, <span class='ident'>start</span>: <span class='number'>8</span>, <span class='ident'>end</span>: <span class='number'>9</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>0</span>, <span class='ident'>start</span>: <span class='number'>12</span>, <span class='ident'>end</span>: <span class='number'>15</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>1</span>, <span class='ident'>start</span>: <span class='number'>13</span>, <span class='ident'>end</span>: <span class='number'>15</span> }, + <span class='ident'>Match</span> { <span class='ident'>pati</span>: <span class='number'>2</span>, <span class='ident'>start</span>: <span class='number'>14</span>, <span class='ident'>end</span>: <span class='number'>15</span> }, + ]; + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findo</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findos</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findfo</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>aut_findfos</span>(<span class='kw-2'>&</span><span class='ident'>ns</span>, <span class='ident'>hay</span>), <span class='kw-2'>&</span><span class='ident'>matches</span>); + } + + <span class='comment'>// Quickcheck time.</span> + + <span class='comment'>// This generates very small ascii strings, which makes them more likely</span> + <span class='comment'>// to interact in interesting ways with larger haystack strings.</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Debug</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>, <span class='ident'>PartialOrd</span>, <span class='ident'>Ord</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>SmallAscii</span>(<span class='ident'>String</span>); + + <span class='kw'>impl</span> <span class='ident'>Arbitrary</span> <span class='kw'>for</span> <span class='ident'>SmallAscii</span> { + <span class='kw'>fn</span> <span class='ident'>arbitrary</span><span class='op'><</span><span class='ident'>G</span>: <span class='ident'>Gen</span><span class='op'>></span>(<span class='ident'>g</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>G</span>) <span class='op'>-></span> <span class='ident'>SmallAscii</span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>char</span>::<span class='ident'>from_u32</span>; + <span class='ident'>SmallAscii</span>((<span class='number'>0</span>..<span class='number'>2</span>) + .<span class='ident'>map</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='ident'>from_u32</span>(<span class='ident'>g</span>.<span class='ident'>gen_range</span>(<span class='number'>97</span>, <span class='number'>123</span>)).<span class='ident'>unwrap</span>()) + .<span class='ident'>collect</span>()) + } + + <span class='kw'>fn</span> <span class='ident'>shrink</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Box</span><span class='op'><</span><span class='ident'>Iterator</span><span class='op'><</span><span class='ident'>Item</span><span class='op'>=</span><span class='ident'>SmallAscii</span><span class='op'>>></span> { + <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='self'>self</span>.<span class='number'>0</span>.<span class='ident'>shrink</span>().<span class='ident'>map</span>(<span class='ident'>SmallAscii</span>)) + } + } + + <span class='kw'>impl</span> <span class='ident'>From</span><span class='op'><</span><span class='ident'>SmallAscii</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>String</span> { + <span class='kw'>fn</span> <span class='ident'>from</span>(<span class='ident'>s</span>: <span class='ident'>SmallAscii</span>) <span class='op'>-></span> <span class='ident'>String</span> { <span class='ident'>s</span>.<span class='number'>0</span> } + } + + <span class='comment'>// This is the same arbitrary impl as `String`, except it has a bias toward</span> + <span class='comment'>// ASCII characters.</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Debug</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>, <span class='ident'>PartialOrd</span>, <span class='ident'>Ord</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>BiasAscii</span>(<span class='ident'>String</span>); + + <span class='kw'>impl</span> <span class='ident'>Arbitrary</span> <span class='kw'>for</span> <span class='ident'>BiasAscii</span> { + <span class='kw'>fn</span> <span class='ident'>arbitrary</span><span class='op'><</span><span class='ident'>G</span>: <span class='ident'>Gen</span><span class='op'>></span>(<span class='ident'>g</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>G</span>) <span class='op'>-></span> <span class='ident'>BiasAscii</span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>char</span>::<span class='ident'>from_u32</span>; + <span class='kw'>let</span> <span class='ident'>size</span> <span class='op'>=</span> { <span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>g</span>.<span class='ident'>size</span>(); <span class='ident'>g</span>.<span class='ident'>gen_range</span>(<span class='number'>0</span>, <span class='ident'>s</span>) }; + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='ident'>size</span>); + <span class='kw'>for</span> _ <span class='kw'>in</span> <span class='number'>0</span>..<span class='ident'>size</span> { + <span class='kw'>if</span> <span class='ident'>g</span>.<span class='ident'>gen_weighted_bool</span>(<span class='number'>3</span>) { + <span class='ident'>s</span>.<span class='ident'>push</span>(<span class='ident'>char</span>::<span class='ident'>arbitrary</span>(<span class='ident'>g</span>)); + } <span class='kw'>else</span> { + <span class='kw'>for</span> _ <span class='kw'>in</span> <span class='number'>0</span>..<span class='number'>5</span> { + <span class='ident'>s</span>.<span class='ident'>push</span>(<span class='ident'>from_u32</span>(<span class='ident'>g</span>.<span class='ident'>gen_range</span>(<span class='number'>97</span>, <span class='number'>123</span>)).<span class='ident'>unwrap</span>()); + } + } + } + <span class='ident'>BiasAscii</span>(<span class='ident'>s</span>) + } + + <span class='kw'>fn</span> <span class='ident'>shrink</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Box</span><span class='op'><</span><span class='ident'>Iterator</span><span class='op'><</span><span class='ident'>Item</span><span class='op'>=</span><span class='ident'>BiasAscii</span><span class='op'>>></span> { + <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='self'>self</span>.<span class='number'>0</span>.<span class='ident'>shrink</span>().<span class='ident'>map</span>(<span class='ident'>BiasAscii</span>)) + } + } + + <span class='kw'>fn</span> <span class='ident'>naive_find</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span>(<span class='ident'>xs</span>: <span class='kw-2'>&</span>[<span class='ident'>S</span>], <span class='ident'>haystack</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Match</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>S</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Into</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>needles</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> <span class='op'>=</span> + <span class='ident'>xs</span>.<span class='ident'>to_vec</span>().<span class='ident'>into_iter</span>().<span class='ident'>map</span>(<span class='ident'>Into</span>::<span class='ident'>into</span>).<span class='ident'>collect</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>matches</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[]; + <span class='kw'>for</span> <span class='ident'>hi</span> <span class='kw'>in</span> <span class='number'>0</span>..<span class='ident'>haystack</span>.<span class='ident'>len</span>() { + <span class='kw'>for</span> (<span class='ident'>pati</span>, <span class='ident'>needle</span>) <span class='kw'>in</span> <span class='ident'>needles</span>.<span class='ident'>iter</span>().<span class='ident'>enumerate</span>() { + <span class='kw'>let</span> <span class='ident'>needle</span> <span class='op'>=</span> <span class='ident'>needle</span>.<span class='ident'>as_bytes</span>(); + <span class='kw'>if</span> <span class='ident'>needle</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>0</span> <span class='op'>||</span> <span class='ident'>needle</span>.<span class='ident'>len</span>() <span class='op'>></span> <span class='ident'>haystack</span>.<span class='ident'>len</span>() <span class='op'>-</span> <span class='ident'>hi</span> { + <span class='kw'>continue</span>; + } + <span class='kw'>if</span> <span class='ident'>needle</span> <span class='op'>==</span> <span class='kw-2'>&</span><span class='ident'>haystack</span>.<span class='ident'>as_bytes</span>()[<span class='ident'>hi</span>..<span class='ident'>hi</span><span class='op'>+</span><span class='ident'>needle</span>.<span class='ident'>len</span>()] { + <span class='ident'>matches</span>.<span class='ident'>push</span>(<span class='ident'>Match</span> { + <span class='ident'>pati</span>: <span class='ident'>pati</span>, + <span class='ident'>start</span>: <span class='ident'>hi</span>, + <span class='ident'>end</span>: <span class='ident'>hi</span> <span class='op'>+</span> <span class='ident'>needle</span>.<span class='ident'>len</span>(), + }); + } + } + } + <span class='ident'>matches</span> + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>qc_ac_equals_naive</span>() { + <span class='kw'>fn</span> <span class='ident'>prop</span>(<span class='ident'>needles</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>SmallAscii</span><span class='op'>></span>, <span class='ident'>haystack</span>: <span class='ident'>BiasAscii</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>let</span> <span class='ident'>aut_matches</span> <span class='op'>=</span> <span class='ident'>aut_findo</span>(<span class='kw-2'>&</span><span class='ident'>needles</span>, <span class='kw-2'>&</span><span class='ident'>haystack</span>.<span class='number'>0</span>); + <span class='kw'>let</span> <span class='ident'>naive_matches</span> <span class='op'>=</span> <span class='ident'>naive_find</span>(<span class='kw-2'>&</span><span class='ident'>needles</span>, <span class='kw-2'>&</span><span class='ident'>haystack</span>.<span class='number'>0</span>); + <span class='comment'>// Ordering isn't always the same. I don't think we care, so do</span> + <span class='comment'>// an unordered comparison.</span> + <span class='kw'>let</span> <span class='ident'>aset</span>: <span class='ident'>HashSet</span><span class='op'><</span><span class='ident'>Match</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>aut_matches</span>.<span class='ident'>iter</span>().<span class='ident'>cloned</span>().<span class='ident'>collect</span>(); + <span class='kw'>let</span> <span class='ident'>nset</span>: <span class='ident'>HashSet</span><span class='op'><</span><span class='ident'>Match</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>naive_matches</span>.<span class='ident'>iter</span>().<span class='ident'>cloned</span>().<span class='ident'>collect</span>(); + <span class='ident'>aset</span> <span class='op'>==</span> <span class='ident'>nset</span> + } + <span class='ident'>quickcheck</span>(<span class='ident'>prop</span> <span class='kw'>as</span> <span class='kw'>fn</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>SmallAscii</span><span class='op'>></span>, <span class='ident'>BiasAscii</span>) <span class='op'>-></span> <span class='ident'>bool</span>); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "aho_corasick"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/bitflags/lib.rs.html b/src/bitflags/lib.rs.html new file mode 100644 index 0000000..83312e8 --- /dev/null +++ b/src/bitflags/lib.rs.html @@ -0,0 +1,1121 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/bitflags-0.2.1/src/lib.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>lib.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +<span id="313">313</span> +<span id="314">314</span> +<span id="315">315</span> +<span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +<span id="326">326</span> +<span id="327">327</span> +<span id="328">328</span> +<span id="329">329</span> +<span id="330">330</span> +<span id="331">331</span> +<span id="332">332</span> +<span id="333">333</span> +<span id="334">334</span> +<span id="335">335</span> +<span id="336">336</span> +<span id="337">337</span> +<span id="338">338</span> +<span id="339">339</span> +<span id="340">340</span> +<span id="341">341</span> +<span id="342">342</span> +<span id="343">343</span> +<span id="344">344</span> +<span id="345">345</span> +<span id="346">346</span> +<span id="347">347</span> +<span id="348">348</span> +<span id="349">349</span> +<span id="350">350</span> +<span id="351">351</span> +<span id="352">352</span> +<span id="353">353</span> +<span id="354">354</span> +<span id="355">355</span> +<span id="356">356</span> +<span id="357">357</span> +<span id="358">358</span> +<span id="359">359</span> +<span id="360">360</span> +<span id="361">361</span> +<span id="362">362</span> +<span id="363">363</span> +<span id="364">364</span> +<span id="365">365</span> +<span id="366">366</span> +<span id="367">367</span> +<span id="368">368</span> +<span id="369">369</span> +<span id="370">370</span> +<span id="371">371</span> +<span id="372">372</span> +<span id="373">373</span> +<span id="374">374</span> +<span id="375">375</span> +<span id="376">376</span> +<span id="377">377</span> +<span id="378">378</span> +<span id="379">379</span> +<span id="380">380</span> +<span id="381">381</span> +<span id="382">382</span> +<span id="383">383</span> +<span id="384">384</span> +<span id="385">385</span> +<span id="386">386</span> +<span id="387">387</span> +<span id="388">388</span> +<span id="389">389</span> +<span id="390">390</span> +<span id="391">391</span> +<span id="392">392</span> +<span id="393">393</span> +<span id="394">394</span> +<span id="395">395</span> +<span id="396">396</span> +<span id="397">397</span> +<span id="398">398</span> +<span id="399">399</span> +<span id="400">400</span> +<span id="401">401</span> +<span id="402">402</span> +<span id="403">403</span> +<span id="404">404</span> +<span id="405">405</span> +<span id="406">406</span> +<span id="407">407</span> +<span id="408">408</span> +<span id="409">409</span> +<span id="410">410</span> +<span id="411">411</span> +<span id="412">412</span> +<span id="413">413</span> +<span id="414">414</span> +<span id="415">415</span> +<span id="416">416</span> +<span id="417">417</span> +<span id="418">418</span> +<span id="419">419</span> +<span id="420">420</span> +<span id="421">421</span> +<span id="422">422</span> +<span id="423">423</span> +<span id="424">424</span> +<span id="425">425</span> +<span id="426">426</span> +<span id="427">427</span> +<span id="428">428</span> +<span id="429">429</span> +<span id="430">430</span> +<span id="431">431</span> +<span id="432">432</span> +<span id="433">433</span> +<span id="434">434</span> +<span id="435">435</span> +<span id="436">436</span> +<span id="437">437</span> +<span id="438">438</span> +<span id="439">439</span> +<span id="440">440</span> +<span id="441">441</span> +<span id="442">442</span> +<span id="443">443</span> +<span id="444">444</span> +<span id="445">445</span> +<span id="446">446</span> +<span id="447">447</span> +<span id="448">448</span> +<span id="449">449</span> +<span id="450">450</span> +<span id="451">451</span> +<span id="452">452</span> +<span id="453">453</span> +<span id="454">454</span> +<span id="455">455</span> +<span id="456">456</span> +<span id="457">457</span> +<span id="458">458</span> +<span id="459">459</span> +<span id="460">460</span> +<span id="461">461</span> +<span id="462">462</span> +<span id="463">463</span> +<span id="464">464</span> +<span id="465">465</span> +<span id="466">466</span> +<span id="467">467</span> +<span id="468">468</span> +<span id="469">469</span> +<span id="470">470</span> +<span id="471">471</span> +<span id="472">472</span> +<span id="473">473</span> +<span id="474">474</span> +<span id="475">475</span> +<span id="476">476</span> +<span id="477">477</span> +<span id="478">478</span> +<span id="479">479</span> +<span id="480">480</span> +<span id="481">481</span> +<span id="482">482</span> +<span id="483">483</span> +<span id="484">484</span> +<span id="485">485</span> +<span id="486">486</span> +<span id="487">487</span> +<span id="488">488</span> +<span id="489">489</span> +<span id="490">490</span> +<span id="491">491</span> +<span id="492">492</span> +<span id="493">493</span> +<span id="494">494</span> +<span id="495">495</span> +<span id="496">496</span> +<span id="497">497</span> +<span id="498">498</span> +<span id="499">499</span> +<span id="500">500</span> +<span id="501">501</span> +<span id="502">502</span> +<span id="503">503</span> +<span id="504">504</span> +<span id="505">505</span> +<span id="506">506</span> +<span id="507">507</span> +<span id="508">508</span> +<span id="509">509</span> +<span id="510">510</span> +<span id="511">511</span> +<span id="512">512</span> +</pre><pre class='rust '> +<span class='comment'>// Copyright 2014 The Rust Project Developers. See the COPYRIGHT</span> +<span class='comment'>// file at the top-level directory of this distribution and at</span> +<span class='comment'>// http://rust-lang.org/COPYRIGHT.</span> +<span class='comment'>//</span> +<span class='comment'>// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or</span> +<span class='comment'>// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license</span> +<span class='comment'>// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your</span> +<span class='comment'>// option. This file may not be copied, modified, or distributed</span> +<span class='comment'>// except according to those terms.</span> + +<span class='doccomment'>//! A typesafe bitmask flag generator.</span> + +<span class='doccomment'>/// The `bitflags!` macro generates a `struct` that holds a set of C-style</span> +<span class='doccomment'>/// bitmask flags. It is useful for creating typesafe wrappers for C APIs.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The flags should only be defined for integer types, otherwise unexpected</span> +<span class='doccomment'>/// type errors may occur at compile time.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Example</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ```{.rust}</span> +<span class='doccomment'>/// #[macro_use]</span> +<span class='doccomment'>/// extern crate bitflags;</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// bitflags! {</span> +<span class='doccomment'>/// flags Flags: u32 {</span> +<span class='doccomment'>/// const FLAG_A = 0b00000001,</span> +<span class='doccomment'>/// const FLAG_B = 0b00000010,</span> +<span class='doccomment'>/// const FLAG_C = 0b00000100,</span> +<span class='doccomment'>/// const FLAG_ABC = FLAG_A.bits</span> +<span class='doccomment'>/// | FLAG_B.bits</span> +<span class='doccomment'>/// | FLAG_C.bits,</span> +<span class='doccomment'>/// }</span> +<span class='doccomment'>/// }</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// fn main() {</span> +<span class='doccomment'>/// let e1 = FLAG_A | FLAG_C;</span> +<span class='doccomment'>/// let e2 = FLAG_B | FLAG_C;</span> +<span class='doccomment'>/// assert!((e1 | e2) == FLAG_ABC); // union</span> +<span class='doccomment'>/// assert!((e1 & e2) == FLAG_C); // intersection</span> +<span class='doccomment'>/// assert!((e1 - e2) == FLAG_A); // set difference</span> +<span class='doccomment'>/// assert!(!e2 == FLAG_A); // set complement</span> +<span class='doccomment'>/// }</span> +<span class='doccomment'>/// ```</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The generated `struct`s can also be extended with type and trait</span> +<span class='doccomment'>/// implementations:</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ```{.rust}</span> +<span class='doccomment'>/// #[macro_use]</span> +<span class='doccomment'>/// extern crate bitflags;</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// use std::fmt;</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// bitflags! {</span> +<span class='doccomment'>/// flags Flags: u32 {</span> +<span class='doccomment'>/// const FLAG_A = 0b00000001,</span> +<span class='doccomment'>/// const FLAG_B = 0b00000010,</span> +<span class='doccomment'>/// }</span> +<span class='doccomment'>/// }</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// impl Flags {</span> +<span class='doccomment'>/// pub fn clear(&mut self) {</span> +<span class='doccomment'>/// self.bits = 0; // The `bits` field can be accessed from within the</span> +<span class='doccomment'>/// // same module where the `bitflags!` macro was invoked.</span> +<span class='doccomment'>/// }</span> +<span class='doccomment'>/// }</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// impl fmt::Display for Flags {</span> +<span class='doccomment'>/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {</span> +<span class='doccomment'>/// write!(f, "hi!")</span> +<span class='doccomment'>/// }</span> +<span class='doccomment'>/// }</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// fn main() {</span> +<span class='doccomment'>/// let mut flags = FLAG_A | FLAG_B;</span> +<span class='doccomment'>/// flags.clear();</span> +<span class='doccomment'>/// assert!(flags.is_empty());</span> +<span class='doccomment'>/// assert_eq!(format!("{}", flags), "hi!");</span> +<span class='doccomment'>/// assert_eq!(format!("{:?}", FLAG_A | FLAG_B), "Flags { bits: 0b11 }");</span> +<span class='doccomment'>/// assert_eq!(format!("{:?}", FLAG_B), "Flags { bits: 0b10 }");</span> +<span class='doccomment'>/// }</span> +<span class='doccomment'>/// ```</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Attributes</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Attributes can be attached to the generated `struct` by placing them</span> +<span class='doccomment'>/// before the `flags` keyword.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Derived traits</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The `PartialEq` and `Clone` traits are automatically derived for the</span> +<span class='doccomment'>/// `struct` using the `deriving` attribute. Additional traits can be derived by</span> +<span class='doccomment'>/// providing an explicit `deriving` attribute on `flags`. The `Debug` trait is</span> +<span class='doccomment'>/// also implemented by displaying the bits value of the internal struct.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Operators</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The following operator traits are implemented for the generated `struct`:</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// - `BitOr`: union</span> +<span class='doccomment'>/// - `BitAnd`: intersection</span> +<span class='doccomment'>/// - `BitXor`: toggle</span> +<span class='doccomment'>/// - `Sub`: set difference</span> +<span class='doccomment'>/// - `Not`: set complement</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Methods</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The following methods are defined for the generated `struct`:</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// - `empty`: an empty set of flags</span> +<span class='doccomment'>/// - `all`: the set of all flags</span> +<span class='doccomment'>/// - `bits`: the raw value of the flags currently stored</span> +<span class='doccomment'>/// - `from_bits`: convert from underlying bit representation, unless that</span> +<span class='doccomment'>/// representation contains bits that do not correspond to a flag</span> +<span class='doccomment'>/// - `from_bits_truncate`: convert from underlying bit representation, dropping</span> +<span class='doccomment'>/// any bits that do not correspond to flags</span> +<span class='doccomment'>/// - `is_empty`: `true` if no flags are currently stored</span> +<span class='doccomment'>/// - `is_all`: `true` if all flags are currently set</span> +<span class='doccomment'>/// - `intersects`: `true` if there are flags common to both `self` and `other`</span> +<span class='doccomment'>/// - `contains`: `true` all of the flags in `other` are contained within `self`</span> +<span class='doccomment'>/// - `insert`: inserts the specified flags in-place</span> +<span class='doccomment'>/// - `remove`: removes the specified flags in-place</span> +<span class='doccomment'>/// - `toggle`: the specified flags will be inserted if not present, and removed</span> +<span class='doccomment'>/// if they are.</span> +<span class='attribute'>#[<span class='ident'>macro_export</span>]</span> +<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>bitflags</span> { + ($(<span class='attribute'>#[<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>attr</span>:<span class='ident'>meta</span>]</span>)<span class='op'>*</span> <span class='ident'>flags</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>:<span class='ident'>ident</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span>:<span class='ident'>ty</span> { + $($(<span class='attribute'>#[<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>Flag_attr</span>:<span class='ident'>meta</span>]</span>)<span class='op'>*</span> <span class='kw'>const</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>Flag</span>:<span class='ident'>ident</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>value</span>:<span class='ident'>expr</span>),<span class='op'>+</span> + }) <span class='op'>=></span> { + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>, <span class='ident'>Clone</span>, <span class='ident'>PartialOrd</span>, <span class='ident'>Ord</span>, <span class='ident'>Hash</span>)]</span> + $(<span class='attribute'>#[<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>attr</span>]</span>)<span class='op'>*</span> + <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { + <span class='ident'>bits</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span>, + } + + $($(<span class='attribute'>#[<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>Flag_attr</span>]</span>)<span class='op'>*</span> <span class='kw'>pub</span> <span class='kw'>const</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>Flag</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { <span class='ident'>bits</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>value</span> };)<span class='op'>+</span> + + <span class='kw'>impl</span> ::<span class='ident'>std</span>::<span class='ident'>fmt</span>::<span class='ident'>Debug</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> ::<span class='ident'>std</span>::<span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> ::<span class='ident'>std</span>::<span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='kw'>let</span> <span class='ident'>out</span> <span class='op'>=</span> <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{} {{ bits: {:#b} }}"</span>, + <span class='macro'>stringify</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>), + <span class='self'>self</span>.<span class='ident'>bits</span>); + <span class='ident'>f</span>.<span class='ident'>write_str</span>(<span class='kw-2'>&</span><span class='ident'>out</span>[..]) + } + } + + <span class='kw'>impl</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { + <span class='doccomment'>/// Returns an empty set of flags.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>empty</span>() <span class='op'>-></span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { + <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { <span class='ident'>bits</span>: <span class='number'>0</span> } + } + + <span class='doccomment'>/// Returns the set containing all flags.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>all</span>() <span class='op'>-></span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { + <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { <span class='ident'>bits</span>: $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>value</span>)<span class='op'>|</span><span class='op'>+</span> } + } + + <span class='doccomment'>/// Returns the raw value of the flags currently stored.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>bits</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span> { + <span class='self'>self</span>.<span class='ident'>bits</span> + } + + <span class='doccomment'>/// Convert from underlying bit representation, unless that</span> + <span class='doccomment'>/// representation contains bits that do not correspond to a flag.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>from_bits</span>(<span class='ident'>bits</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span>) <span class='op'>-></span> ::<span class='ident'>std</span>::<span class='ident'>option</span>::<span class='prelude-ty'>Option</span><span class='op'><</span><span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span><span class='op'>></span> { + <span class='kw'>if</span> (<span class='ident'>bits</span> <span class='kw-2'>&</span> <span class='op'>!</span><span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>::<span class='ident'>all</span>().<span class='ident'>bits</span>()) <span class='op'>!=</span> <span class='number'>0</span> { + ::<span class='ident'>std</span>::<span class='ident'>option</span>::<span class='prelude-ty'>Option</span>::<span class='prelude-val'>None</span> + } <span class='kw'>else</span> { + ::<span class='ident'>std</span>::<span class='ident'>option</span>::<span class='prelude-ty'>Option</span>::<span class='prelude-val'>Some</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { <span class='ident'>bits</span>: <span class='ident'>bits</span> }) + } + } + + <span class='doccomment'>/// Convert from underlying bit representation, dropping any bits</span> + <span class='doccomment'>/// that do not correspond to flags.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>from_bits_truncate</span>(<span class='ident'>bits</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span>) <span class='op'>-></span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { + <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { <span class='ident'>bits</span>: <span class='ident'>bits</span> } <span class='kw-2'>&</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>::<span class='ident'>all</span>() + } + + <span class='doccomment'>/// Returns `true` if no flags are currently stored.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_empty</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='op'>*</span><span class='self'>self</span> <span class='op'>==</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>::<span class='ident'>empty</span>() + } + + <span class='doccomment'>/// Returns `true` if all flags are currently set.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_all</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='op'>*</span><span class='self'>self</span> <span class='op'>==</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>::<span class='ident'>all</span>() + } + + <span class='doccomment'>/// Returns `true` if there are flags common to both `self` and `other`.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>intersects</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='op'>!</span>(<span class='op'>*</span><span class='self'>self</span> <span class='kw-2'>&</span> <span class='ident'>other</span>).<span class='ident'>is_empty</span>() + } + + <span class='doccomment'>/// Returns `true` all of the flags in `other` are contained within `self`.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>contains</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + (<span class='op'>*</span><span class='self'>self</span> <span class='kw-2'>&</span> <span class='ident'>other</span>) <span class='op'>==</span> <span class='ident'>other</span> + } + + <span class='doccomment'>/// Inserts the specified flags in-place.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>insert</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>other</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>) { + <span class='self'>self</span>.<span class='ident'>bits</span> <span class='op'>|=</span> <span class='ident'>other</span>.<span class='ident'>bits</span>; + } + + <span class='doccomment'>/// Removes the specified flags in-place.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>remove</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>other</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>) { + <span class='self'>self</span>.<span class='ident'>bits</span> <span class='op'>&=</span> <span class='op'>!</span><span class='ident'>other</span>.<span class='ident'>bits</span>; + } + + <span class='doccomment'>/// Toggles the specified flags in-place.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>toggle</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>other</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>) { + <span class='self'>self</span>.<span class='ident'>bits</span> <span class='op'>^=</span> <span class='ident'>other</span>.<span class='ident'>bits</span>; + } + } + + <span class='kw'>impl</span> ::<span class='ident'>std</span>::<span class='ident'>ops</span>::<span class='ident'>BitOr</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { + <span class='kw'>type</span> <span class='ident'>Output</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>; + + <span class='doccomment'>/// Returns the union of the two sets of flags.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>bitor</span>(<span class='self'>self</span>, <span class='ident'>other</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>) <span class='op'>-></span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { + <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { <span class='ident'>bits</span>: <span class='self'>self</span>.<span class='ident'>bits</span> <span class='op'>|</span> <span class='ident'>other</span>.<span class='ident'>bits</span> } + } + } + + <span class='kw'>impl</span> ::<span class='ident'>std</span>::<span class='ident'>ops</span>::<span class='ident'>BitXor</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { + <span class='kw'>type</span> <span class='ident'>Output</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>; + + <span class='doccomment'>/// Returns the left flags, but with all the right flags toggled.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>bitxor</span>(<span class='self'>self</span>, <span class='ident'>other</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>) <span class='op'>-></span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { + <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { <span class='ident'>bits</span>: <span class='self'>self</span>.<span class='ident'>bits</span> <span class='op'>^</span> <span class='ident'>other</span>.<span class='ident'>bits</span> } + } + } + + <span class='kw'>impl</span> ::<span class='ident'>std</span>::<span class='ident'>ops</span>::<span class='ident'>BitAnd</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { + <span class='kw'>type</span> <span class='ident'>Output</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>; + + <span class='doccomment'>/// Returns the intersection between the two sets of flags.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>bitand</span>(<span class='self'>self</span>, <span class='ident'>other</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>) <span class='op'>-></span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { + <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { <span class='ident'>bits</span>: <span class='self'>self</span>.<span class='ident'>bits</span> <span class='kw-2'>&</span> <span class='ident'>other</span>.<span class='ident'>bits</span> } + } + } + + <span class='kw'>impl</span> ::<span class='ident'>std</span>::<span class='ident'>ops</span>::<span class='ident'>Sub</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { + <span class='kw'>type</span> <span class='ident'>Output</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>; + + <span class='doccomment'>/// Returns the set difference of the two sets of flags.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>sub</span>(<span class='self'>self</span>, <span class='ident'>other</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>) <span class='op'>-></span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { + <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { <span class='ident'>bits</span>: <span class='self'>self</span>.<span class='ident'>bits</span> <span class='kw-2'>&</span> <span class='op'>!</span><span class='ident'>other</span>.<span class='ident'>bits</span> } + } + } + + <span class='kw'>impl</span> ::<span class='ident'>std</span>::<span class='ident'>ops</span>::<span class='ident'>Not</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { + <span class='kw'>type</span> <span class='ident'>Output</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>; + + <span class='doccomment'>/// Returns the complement of this set of flags.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>not</span>(<span class='self'>self</span>) <span class='op'>-></span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { + <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span> { <span class='ident'>bits</span>: <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>bits</span> } <span class='kw-2'>&</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>::<span class='ident'>all</span>() + } + } + }; + ($(<span class='attribute'>#[<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>attr</span>:<span class='ident'>meta</span>]</span>)<span class='op'>*</span> <span class='ident'>flags</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>:<span class='ident'>ident</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span>:<span class='ident'>ty</span> { + $($(<span class='attribute'>#[<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>Flag_attr</span>:<span class='ident'>meta</span>]</span>)<span class='op'>*</span> <span class='kw'>const</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>Flag</span>:<span class='ident'>ident</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>value</span>:<span class='ident'>expr</span>),<span class='op'>+</span>, + }) <span class='op'>=></span> { + <span class='macro'>bitflags</span><span class='macro'>!</span> { + $(<span class='attribute'>#[<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>attr</span>]</span>)<span class='op'>*</span> + <span class='ident'>flags</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>BitFlags</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span> { + $($(<span class='attribute'>#[<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>Flag_attr</span>]</span>)<span class='op'>*</span> <span class='kw'>const</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>Flag</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>value</span>),<span class='op'>+</span> + } + } + }; +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>non_upper_case_globals</span>, <span class='ident'>dead_code</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>tests</span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>hash</span>::{<span class='ident'>SipHasher</span>, <span class='ident'>Hash</span>, <span class='ident'>Hasher</span>}; + + <span class='macro'>bitflags</span><span class='macro'>!</span> { + <span class='attribute'>#[<span class='ident'>doc</span> <span class='op'>=</span> <span class='string'>"> The first principle is that you must not fool yourself — and"</span>]</span> + <span class='attribute'>#[<span class='ident'>doc</span> <span class='op'>=</span> <span class='string'>"> you are the easiest person to fool."</span>]</span> + <span class='attribute'>#[<span class='ident'>doc</span> <span class='op'>=</span> <span class='string'>"> "</span>]</span> + <span class='attribute'>#[<span class='ident'>doc</span> <span class='op'>=</span> <span class='string'>"> - Richard Feynman"</span>]</span> + <span class='ident'>flags</span> <span class='ident'>Flags</span>: <span class='ident'>u32</span> { + <span class='kw'>const</span> <span class='ident'>FlagA</span> <span class='op'>=</span> <span class='number'>0b00000001</span>, + <span class='attribute'>#[<span class='ident'>doc</span> <span class='op'>=</span> <span class='string'>"<pcwalton> macros are way better at generating code than trans is"</span>]</span> + <span class='kw'>const</span> <span class='ident'>FlagB</span> <span class='op'>=</span> <span class='number'>0b00000010</span>, + <span class='kw'>const</span> <span class='ident'>FlagC</span> <span class='op'>=</span> <span class='number'>0b00000100</span>, + <span class='attribute'>#[<span class='ident'>doc</span> <span class='op'>=</span> <span class='string'>"* cmr bed"</span>]</span> + <span class='attribute'>#[<span class='ident'>doc</span> <span class='op'>=</span> <span class='string'>"* strcat table"</span>]</span> + <span class='attribute'>#[<span class='ident'>doc</span> <span class='op'>=</span> <span class='string'>"<strcat> wait what?"</span>]</span> + <span class='kw'>const</span> <span class='ident'>FlagABC</span> <span class='op'>=</span> <span class='ident'>FlagA</span>.<span class='ident'>bits</span> + <span class='op'>|</span> <span class='ident'>FlagB</span>.<span class='ident'>bits</span> + <span class='op'>|</span> <span class='ident'>FlagC</span>.<span class='ident'>bits</span>, + } + } + + <span class='macro'>bitflags</span><span class='macro'>!</span> { + <span class='ident'>flags</span> <span class='ident'>_CfgFlags</span>: <span class='ident'>u32</span> { + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>windows</span>)]</span> + <span class='kw'>const</span> <span class='ident'>_CfgA</span> <span class='op'>=</span> <span class='number'>0b01</span>, + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>unix</span>)]</span> + <span class='kw'>const</span> <span class='ident'>_CfgB</span> <span class='op'>=</span> <span class='number'>0b01</span>, + } + } + + <span class='macro'>bitflags</span><span class='macro'>!</span> { + <span class='ident'>flags</span> <span class='ident'>AnotherSetOfFlags</span>: <span class='ident'>i8</span> { + <span class='kw'>const</span> <span class='ident'>AnotherFlag</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>1_i8</span>, + } + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_bits</span>(){ + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>Flags</span>::<span class='ident'>empty</span>().<span class='ident'>bits</span>(), <span class='number'>0b00000000</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>FlagA</span>.<span class='ident'>bits</span>(), <span class='number'>0b00000001</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>FlagABC</span>.<span class='ident'>bits</span>(), <span class='number'>0b00000111</span>); + + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>AnotherSetOfFlags</span>::<span class='ident'>empty</span>().<span class='ident'>bits</span>(), <span class='number'>0b00</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>AnotherFlag</span>.<span class='ident'>bits</span>(), <span class='op'>!</span><span class='number'>0_i8</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_from_bits</span>() { + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>Flags</span>::<span class='ident'>from_bits</span>(<span class='number'>0</span>) <span class='op'>==</span> <span class='prelude-val'>Some</span>(<span class='ident'>Flags</span>::<span class='ident'>empty</span>())); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>Flags</span>::<span class='ident'>from_bits</span>(<span class='number'>0b1</span>) <span class='op'>==</span> <span class='prelude-val'>Some</span>(<span class='ident'>FlagA</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>Flags</span>::<span class='ident'>from_bits</span>(<span class='number'>0b10</span>) <span class='op'>==</span> <span class='prelude-val'>Some</span>(<span class='ident'>FlagB</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>Flags</span>::<span class='ident'>from_bits</span>(<span class='number'>0b11</span>) <span class='op'>==</span> <span class='prelude-val'>Some</span>(<span class='ident'>FlagA</span> <span class='op'>|</span> <span class='ident'>FlagB</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>Flags</span>::<span class='ident'>from_bits</span>(<span class='number'>0b1000</span>) <span class='op'>==</span> <span class='prelude-val'>None</span>); + + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>AnotherSetOfFlags</span>::<span class='ident'>from_bits</span>(<span class='op'>!</span><span class='number'>0_i8</span>) <span class='op'>==</span> <span class='prelude-val'>Some</span>(<span class='ident'>AnotherFlag</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_from_bits_truncate</span>() { + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>Flags</span>::<span class='ident'>from_bits_truncate</span>(<span class='number'>0</span>) <span class='op'>==</span> <span class='ident'>Flags</span>::<span class='ident'>empty</span>()); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>Flags</span>::<span class='ident'>from_bits_truncate</span>(<span class='number'>0b1</span>) <span class='op'>==</span> <span class='ident'>FlagA</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>Flags</span>::<span class='ident'>from_bits_truncate</span>(<span class='number'>0b10</span>) <span class='op'>==</span> <span class='ident'>FlagB</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>Flags</span>::<span class='ident'>from_bits_truncate</span>(<span class='number'>0b11</span>) <span class='op'>==</span> (<span class='ident'>FlagA</span> <span class='op'>|</span> <span class='ident'>FlagB</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>Flags</span>::<span class='ident'>from_bits_truncate</span>(<span class='number'>0b1000</span>) <span class='op'>==</span> <span class='ident'>Flags</span>::<span class='ident'>empty</span>()); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>Flags</span>::<span class='ident'>from_bits_truncate</span>(<span class='number'>0b1001</span>) <span class='op'>==</span> <span class='ident'>FlagA</span>); + + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>AnotherSetOfFlags</span>::<span class='ident'>from_bits_truncate</span>(<span class='number'>0_i8</span>) <span class='op'>==</span> <span class='ident'>AnotherSetOfFlags</span>::<span class='ident'>empty</span>()); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_is_empty</span>(){ + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>Flags</span>::<span class='ident'>empty</span>().<span class='ident'>is_empty</span>()); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>FlagA</span>.<span class='ident'>is_empty</span>()); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>FlagABC</span>.<span class='ident'>is_empty</span>()); + + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>AnotherFlag</span>.<span class='ident'>is_empty</span>()); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_is_all</span>() { + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>Flags</span>::<span class='ident'>all</span>().<span class='ident'>is_all</span>()); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>FlagA</span>.<span class='ident'>is_all</span>()); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>FlagABC</span>.<span class='ident'>is_all</span>()); + + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>AnotherFlag</span>.<span class='ident'>is_all</span>()); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_two_empties_do_not_intersect</span>() { + <span class='kw'>let</span> <span class='ident'>e1</span> <span class='op'>=</span> <span class='ident'>Flags</span>::<span class='ident'>empty</span>(); + <span class='kw'>let</span> <span class='ident'>e2</span> <span class='op'>=</span> <span class='ident'>Flags</span>::<span class='ident'>empty</span>(); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>e1</span>.<span class='ident'>intersects</span>(<span class='ident'>e2</span>)); + + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>AnotherFlag</span>.<span class='ident'>intersects</span>(<span class='ident'>AnotherFlag</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_empty_does_not_intersect_with_full</span>() { + <span class='kw'>let</span> <span class='ident'>e1</span> <span class='op'>=</span> <span class='ident'>Flags</span>::<span class='ident'>empty</span>(); + <span class='kw'>let</span> <span class='ident'>e2</span> <span class='op'>=</span> <span class='ident'>FlagABC</span>; + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>e1</span>.<span class='ident'>intersects</span>(<span class='ident'>e2</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_disjoint_intersects</span>() { + <span class='kw'>let</span> <span class='ident'>e1</span> <span class='op'>=</span> <span class='ident'>FlagA</span>; + <span class='kw'>let</span> <span class='ident'>e2</span> <span class='op'>=</span> <span class='ident'>FlagB</span>; + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>e1</span>.<span class='ident'>intersects</span>(<span class='ident'>e2</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_overlapping_intersects</span>() { + <span class='kw'>let</span> <span class='ident'>e1</span> <span class='op'>=</span> <span class='ident'>FlagA</span>; + <span class='kw'>let</span> <span class='ident'>e2</span> <span class='op'>=</span> <span class='ident'>FlagA</span> <span class='op'>|</span> <span class='ident'>FlagB</span>; + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>e1</span>.<span class='ident'>intersects</span>(<span class='ident'>e2</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_contains</span>() { + <span class='kw'>let</span> <span class='ident'>e1</span> <span class='op'>=</span> <span class='ident'>FlagA</span>; + <span class='kw'>let</span> <span class='ident'>e2</span> <span class='op'>=</span> <span class='ident'>FlagA</span> <span class='op'>|</span> <span class='ident'>FlagB</span>; + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>e1</span>.<span class='ident'>contains</span>(<span class='ident'>e2</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>e2</span>.<span class='ident'>contains</span>(<span class='ident'>e1</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>FlagABC</span>.<span class='ident'>contains</span>(<span class='ident'>e2</span>)); + + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>AnotherFlag</span>.<span class='ident'>contains</span>(<span class='ident'>AnotherFlag</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_insert</span>(){ + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>e1</span> <span class='op'>=</span> <span class='ident'>FlagA</span>; + <span class='kw'>let</span> <span class='ident'>e2</span> <span class='op'>=</span> <span class='ident'>FlagA</span> <span class='op'>|</span> <span class='ident'>FlagB</span>; + <span class='ident'>e1</span>.<span class='ident'>insert</span>(<span class='ident'>e2</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>e1</span> <span class='op'>==</span> <span class='ident'>e2</span>); + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>e3</span> <span class='op'>=</span> <span class='ident'>AnotherSetOfFlags</span>::<span class='ident'>empty</span>(); + <span class='ident'>e3</span>.<span class='ident'>insert</span>(<span class='ident'>AnotherFlag</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>e3</span> <span class='op'>==</span> <span class='ident'>AnotherFlag</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_remove</span>(){ + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>e1</span> <span class='op'>=</span> <span class='ident'>FlagA</span> <span class='op'>|</span> <span class='ident'>FlagB</span>; + <span class='kw'>let</span> <span class='ident'>e2</span> <span class='op'>=</span> <span class='ident'>FlagA</span> <span class='op'>|</span> <span class='ident'>FlagC</span>; + <span class='ident'>e1</span>.<span class='ident'>remove</span>(<span class='ident'>e2</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>e1</span> <span class='op'>==</span> <span class='ident'>FlagB</span>); + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>e3</span> <span class='op'>=</span> <span class='ident'>AnotherFlag</span>; + <span class='ident'>e3</span>.<span class='ident'>remove</span>(<span class='ident'>AnotherFlag</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>e3</span> <span class='op'>==</span> <span class='ident'>AnotherSetOfFlags</span>::<span class='ident'>empty</span>()); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_operators</span>() { + <span class='kw'>let</span> <span class='ident'>e1</span> <span class='op'>=</span> <span class='ident'>FlagA</span> <span class='op'>|</span> <span class='ident'>FlagC</span>; + <span class='kw'>let</span> <span class='ident'>e2</span> <span class='op'>=</span> <span class='ident'>FlagB</span> <span class='op'>|</span> <span class='ident'>FlagC</span>; + <span class='macro'>assert</span><span class='macro'>!</span>((<span class='ident'>e1</span> <span class='op'>|</span> <span class='ident'>e2</span>) <span class='op'>==</span> <span class='ident'>FlagABC</span>); <span class='comment'>// union</span> + <span class='macro'>assert</span><span class='macro'>!</span>((<span class='ident'>e1</span> <span class='kw-2'>&</span> <span class='ident'>e2</span>) <span class='op'>==</span> <span class='ident'>FlagC</span>); <span class='comment'>// intersection</span> + <span class='macro'>assert</span><span class='macro'>!</span>((<span class='ident'>e1</span> <span class='op'>-</span> <span class='ident'>e2</span>) <span class='op'>==</span> <span class='ident'>FlagA</span>); <span class='comment'>// set difference</span> + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>e2</span> <span class='op'>==</span> <span class='ident'>FlagA</span>); <span class='comment'>// set complement</span> + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>e1</span> <span class='op'>^</span> <span class='ident'>e2</span> <span class='op'>==</span> <span class='ident'>FlagA</span> <span class='op'>|</span> <span class='ident'>FlagB</span>); <span class='comment'>// toggle</span> + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>e3</span> <span class='op'>=</span> <span class='ident'>e1</span>; + <span class='ident'>e3</span>.<span class='ident'>toggle</span>(<span class='ident'>e2</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>e3</span> <span class='op'>==</span> <span class='ident'>FlagA</span> <span class='op'>|</span> <span class='ident'>FlagB</span>); + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>m4</span> <span class='op'>=</span> <span class='ident'>AnotherSetOfFlags</span>::<span class='ident'>empty</span>(); + <span class='ident'>m4</span>.<span class='ident'>toggle</span>(<span class='ident'>AnotherSetOfFlags</span>::<span class='ident'>empty</span>()); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>m4</span> <span class='op'>==</span> <span class='ident'>AnotherSetOfFlags</span>::<span class='ident'>empty</span>()); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_lt</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>Flags</span>::<span class='ident'>empty</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>b</span> <span class='op'>=</span> <span class='ident'>Flags</span>::<span class='ident'>empty</span>(); + + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span>(<span class='ident'>a</span> <span class='op'><</span> <span class='ident'>b</span>) <span class='op'>&&</span> <span class='op'>!</span>(<span class='ident'>b</span> <span class='op'><</span> <span class='ident'>a</span>)); + <span class='ident'>b</span> <span class='op'>=</span> <span class='ident'>FlagB</span>; + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>a</span> <span class='op'><</span> <span class='ident'>b</span>); + <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>FlagC</span>; + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span>(<span class='ident'>a</span> <span class='op'><</span> <span class='ident'>b</span>) <span class='op'>&&</span> <span class='ident'>b</span> <span class='op'><</span> <span class='ident'>a</span>); + <span class='ident'>b</span> <span class='op'>=</span> <span class='ident'>FlagC</span> <span class='op'>|</span> <span class='ident'>FlagB</span>; + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>a</span> <span class='op'><</span> <span class='ident'>b</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_ord</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>Flags</span>::<span class='ident'>empty</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>b</span> <span class='op'>=</span> <span class='ident'>Flags</span>::<span class='ident'>empty</span>(); + + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>a</span> <span class='op'><=</span> <span class='ident'>b</span> <span class='op'>&&</span> <span class='ident'>a</span> <span class='op'>>=</span> <span class='ident'>b</span>); + <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>FlagA</span>; + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>a</span> <span class='op'>></span> <span class='ident'>b</span> <span class='op'>&&</span> <span class='ident'>a</span> <span class='op'>>=</span> <span class='ident'>b</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>b</span> <span class='op'><</span> <span class='ident'>a</span> <span class='op'>&&</span> <span class='ident'>b</span> <span class='op'><=</span> <span class='ident'>a</span>); + <span class='ident'>b</span> <span class='op'>=</span> <span class='ident'>FlagB</span>; + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>b</span> <span class='op'>></span> <span class='ident'>a</span> <span class='op'>&&</span> <span class='ident'>b</span> <span class='op'>>=</span> <span class='ident'>a</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>a</span> <span class='op'><</span> <span class='ident'>b</span> <span class='op'>&&</span> <span class='ident'>a</span> <span class='op'><=</span> <span class='ident'>b</span>); + } + + <span class='kw'>fn</span> <span class='ident'>hash</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>Hash</span><span class='op'>></span>(<span class='ident'>t</span>: <span class='kw-2'>&</span><span class='ident'>T</span>) <span class='op'>-></span> <span class='ident'>u64</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>SipHasher</span>::<span class='ident'>new_with_keys</span>(<span class='number'>0</span>, <span class='number'>0</span>); + <span class='ident'>t</span>.<span class='ident'>hash</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>s</span>); + <span class='ident'>s</span>.<span class='ident'>finish</span>() + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_hash</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>x</span> <span class='op'>=</span> <span class='ident'>Flags</span>::<span class='ident'>empty</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>y</span> <span class='op'>=</span> <span class='ident'>Flags</span>::<span class='ident'>empty</span>(); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>hash</span>(<span class='kw-2'>&</span><span class='ident'>x</span>) <span class='op'>==</span> <span class='ident'>hash</span>(<span class='kw-2'>&</span><span class='ident'>y</span>)); + <span class='ident'>x</span> <span class='op'>=</span> <span class='ident'>Flags</span>::<span class='ident'>all</span>(); + <span class='ident'>y</span> <span class='op'>=</span> <span class='ident'>FlagABC</span>; + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>hash</span>(<span class='kw-2'>&</span><span class='ident'>x</span>) <span class='op'>==</span> <span class='ident'>hash</span>(<span class='kw-2'>&</span><span class='ident'>y</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_debug</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{:?}"</span>, <span class='ident'>FlagA</span> <span class='op'>|</span> <span class='ident'>FlagB</span>), <span class='string'>"Flags { bits: 0b11 }"</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{:?}"</span>, <span class='ident'>FlagABC</span>), <span class='string'>"Flags { bits: 0b111 }"</span>); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "bitflags"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/carboxyl/lib.rs.html b/src/carboxyl/lib.rs.html new file mode 100644 index 0000000..912fa0d --- /dev/null +++ b/src/carboxyl/lib.rs.html @@ -0,0 +1,419 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/carboxyl-0.1.1/src/lib.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>lib.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +</pre><pre class='rust '> +<span class='doccomment'>//! *Carboxyl* provides primitives for functional reactive programming in Rust.</span> +<span class='doccomment'>//! It draws inspiration from the [Sodium][sodium] libraries and Push-Pull FRP,</span> +<span class='doccomment'>//! as described by [Elliott (2009)][elliott_push_pull].</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! [sodium]: https://github.com/SodiumFRP/sodium/</span> +<span class='doccomment'>//! [elliott_push_pull]: http://conal.net/papers/push-pull-frp/push-pull-frp.pdf</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # Overview</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Functional reactive programming (FRP) is a composable and modular</span> +<span class='doccomment'>//! abstraction for creating dynamic and reactive systems. In its most general</span> +<span class='doccomment'>//! form it models these systems as a composition of two basic primitives:</span> +<span class='doccomment'>//! *streams* are a series of singular events and *signals* are continuously</span> +<span class='doccomment'>//! changing values.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! *Carboxyl* is an imperative, hybrid push- and pull-based implementation of</span> +<span class='doccomment'>//! FRP. Streams and the discrete components of signals are data-driven, i.e.</span> +<span class='doccomment'>//! whenever an event occurs the resulting changes are propagated to everything</span> +<span class='doccomment'>//! that depends on it.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! However, the continuous components of signals are demand-driven. Internally,</span> +<span class='doccomment'>//! *Carboxyl* stores the state of a signal as a function. This function has to</span> +<span class='doccomment'>//! be evaluated by consumers of a signal to obtain a concrete value.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Nonetheless, *Carboxyl* has no explicit notion of time. Its signals are</span> +<span class='doccomment'>//! functions that can be evaluated at any time, but they do not carry any</span> +<span class='doccomment'>//! inherent notion of time. Synchronization and atomicity is achieved by a</span> +<span class='doccomment'>//! transaction system.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # Functional reactive primitives</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! This library provides two basic types: `Stream` and `Signal`. A stream is a</span> +<span class='doccomment'>//! discrete sequence of events, a signal is a container for values that change</span> +<span class='doccomment'>//! (discretely) over time.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! The FRP primitives are mostly implemented as methods of the basic types to</span> +<span class='doccomment'>//! ease method chaining, except for the various lifting functions, as they do</span> +<span class='doccomment'>//! not really belong to any type in particular.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! In addition, the `Sink` type allows one to create a stream of events by</span> +<span class='doccomment'>//! sending values into it. It is the only way to create a stream from scratch,</span> +<span class='doccomment'>//! i.e. without using any of the other primitives.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # Usage example</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Here is a simple example of how you can use the primitives provided by</span> +<span class='doccomment'>//! *Carboxyl*. First of all, events can be sent into a *sink*. From a sink one</span> +<span class='doccomment'>//! can create a *stream* of events. Streams can also be filtered, mapped and</span> +<span class='doccomment'>//! merged. One can e.g. hold the last event from a stream as a signal.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//! use carboxyl::Sink;</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! let sink = Sink::new();</span> +<span class='doccomment'>//! let stream = sink.stream();</span> +<span class='doccomment'>//! let signal = stream.hold(3);</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! // The current value of the signal is initially 3</span> +<span class='doccomment'>//! assert_eq!(signal.sample(), 3);</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! // When we fire an event, the signal get updated accordingly</span> +<span class='doccomment'>//! sink.send(5);</span> +<span class='doccomment'>//! assert_eq!(signal.sample(), 5);</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! One can also directly iterate over the stream instead of holding it in a</span> +<span class='doccomment'>//! signal:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//! # use carboxyl::Sink;</span> +<span class='doccomment'>//! # let sink = Sink::new();</span> +<span class='doccomment'>//! # let stream = sink.stream();</span> +<span class='doccomment'>//! let mut events = stream.events();</span> +<span class='doccomment'>//! sink.send(4);</span> +<span class='doccomment'>//! assert_eq!(events.next(), Some(4));</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Streams and signals can be combined using various primitives. We can map a</span> +<span class='doccomment'>//! stream to another stream using a function:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//! # use carboxyl::Sink;</span> +<span class='doccomment'>//! # let sink: Sink<i32> = Sink::new();</span> +<span class='doccomment'>//! # let stream = sink.stream();</span> +<span class='doccomment'>//! let squares = stream.map(|x| x * x).hold(0);</span> +<span class='doccomment'>//! sink.send(4);</span> +<span class='doccomment'>//! assert_eq!(squares.sample(), 16);</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Or we can filter a stream to create a new one that only contains events that</span> +<span class='doccomment'>//! satisfy a certain predicate:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//! # use carboxyl::Sink;</span> +<span class='doccomment'>//! # let sink: Sink<i32> = Sink::new();</span> +<span class='doccomment'>//! # let stream = sink.stream();</span> +<span class='doccomment'>//! let negatives = stream.filter(|&x| x < 0).hold(0);</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! // This won't arrive at the signal.</span> +<span class='doccomment'>//! sink.send(4);</span> +<span class='doccomment'>//! assert_eq!(negatives.sample(), 0);</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! // But this will!</span> +<span class='doccomment'>//! sink.send(-3);</span> +<span class='doccomment'>//! assert_eq!(negatives.sample(), -3);</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! There are some other methods on streams and signals, that you can find in</span> +<span class='doccomment'>//! their respective APIs.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Note that all these objects are `Send + Sync + Clone`. This means you can</span> +<span class='doccomment'>//! easily pass them around in your code, make clones, give them to another</span> +<span class='doccomment'>//! thread, and they will still be updated correctly.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! You may have noticed that certain primitives take a function as an argument.</span> +<span class='doccomment'>//! There is a limitation on what kind of functions can and should be used here.</span> +<span class='doccomment'>//! In general, as FRP provides an abstraction around mutable state, they should</span> +<span class='doccomment'>//! be pure functions (i.e. free of side effects).</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! For the most part this is guaranteed by Rust's type system. A static</span> +<span class='doccomment'>//! function with a matching signature always works. A closure though is very</span> +<span class='doccomment'>//! restricted: it must not borrow its environment, as it is impossible to</span> +<span class='doccomment'>//! satisfy the lifetime requirements for that. So you can only move stuff into</span> +<span class='doccomment'>//! it from the environment. However, the moved contents of the closure may also</span> +<span class='doccomment'>//! not be altered, which is guaranteed by the `Fn(…) -> …)` trait bound.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! However, both closures and functions could still have side effects such as</span> +<span class='doccomment'>//! I/O, changing mutable state via `Mutex` or `RefCell`, etc. While Rust's type</span> +<span class='doccomment'>//! system cannot prevent this, you should generally not pass such functions to</span> +<span class='doccomment'>//! the FRP primitives, as they break the benefits you get from using FRP.</span> +<span class='doccomment'>//! (An exception here is debugging output.)</span> + +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>feature</span>(<span class='ident'>arc_weak</span>, <span class='ident'>fnbox</span>)]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>cfg_attr</span>(<span class='ident'>test</span>, <span class='ident'>feature</span>(<span class='ident'>test</span>, <span class='ident'>scoped</span>))]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>warn</span>(<span class='ident'>missing_docs</span>)]</span> + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>test</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>rand</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>quickcheck</span>; +<span class='attribute'>#[<span class='ident'>macro_use</span>(<span class='ident'>lazy_static</span>)]</span> +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>lazy_static</span>; + +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>stream</span>::{ <span class='ident'>Sink</span>, <span class='ident'>Stream</span> }; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>signal</span>::{ <span class='ident'>Signal</span>, <span class='ident'>SignalMut</span> }; + +<span class='kw'>mod</span> <span class='ident'>transaction</span>; +<span class='kw'>mod</span> <span class='ident'>source</span>; +<span class='kw'>mod</span> <span class='ident'>pending</span>; +<span class='kw'>mod</span> <span class='ident'>readonly</span>; +<span class='kw'>mod</span> <span class='ident'>stream</span>; +<span class='kw'>mod</span> <span class='ident'>signal</span>; +<span class='attribute'>#[<span class='ident'>macro_use</span>]</span> +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>lift</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>testing</span>; +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "carboxyl"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/carboxyl/lift.rs.html b/src/carboxyl/lift.rs.html new file mode 100644 index 0000000..224dbe8 --- /dev/null +++ b/src/carboxyl/lift.rs.html @@ -0,0 +1,605 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/carboxyl-0.1.1/src/lift.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>lift.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +</pre><pre class='rust '> +<span class='doccomment'>//! Lifting of n-ary functions.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! A lift maps a function on values to a function on signals. Given a function of</span> +<span class='doccomment'>//! type `F: Fn(A, B, …) -> R` and signals of types `Signal<A>, Signal<B>, …` the</span> +<span class='doccomment'>//! `lift!` macro creates a `Signal<R>`, whose content is computed using the</span> +<span class='doccomment'>//! function.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Currently lift is only implemented for functions with up to four arguments.</span> +<span class='doccomment'>//! This limitation is due to the current implementation strategy (and maybe</span> +<span class='doccomment'>//! limitations of Rust's type system), but it can be increased to arbitrary but</span> +<span class='doccomment'>//! finite arity if required.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # Example</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//! # #[macro_use] extern crate carboxyl;</span> +<span class='doccomment'>//! # fn main() {</span> +<span class='doccomment'>//! # use carboxyl::Sink;</span> +<span class='doccomment'>//! let sink_a = Sink::new();</span> +<span class='doccomment'>//! let sink_b = Sink::new();</span> +<span class='doccomment'>//! let product = lift!(</span> +<span class='doccomment'>//! |a, b| a * b,</span> +<span class='doccomment'>//! &sink_a.stream().hold(0),</span> +<span class='doccomment'>//! &sink_b.stream().hold(0)</span> +<span class='doccomment'>//! );</span> +<span class='doccomment'>//! assert_eq!(product.sample(), 0);</span> +<span class='doccomment'>//! sink_a.send(3);</span> +<span class='doccomment'>//! sink_b.send(5);</span> +<span class='doccomment'>//! assert_eq!(product.sample(), 15);</span> +<span class='doccomment'>//! # }</span> +<span class='doccomment'>//! ```</span> + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>sync</span>::<span class='ident'>Arc</span>; +<span class='kw'>use</span> <span class='ident'>signal</span>::{ <span class='ident'>Signal</span>, <span class='ident'>SignalFn</span>, <span class='ident'>signal_build</span>, <span class='ident'>signal_current</span>, <span class='ident'>signal_source</span>, <span class='ident'>reg_signal</span>, <span class='ident'>sample_raw</span> }; +<span class='kw'>use</span> <span class='ident'>transaction</span>::<span class='ident'>commit</span>; + + +<span class='attribute'>#[<span class='ident'>macro_export</span>]</span> +<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>lift</span> { + (<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>f</span>: <span class='ident'>expr</span>) + <span class='op'>=></span> ( <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>lift</span>::<span class='ident'>lift0</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>f</span>) ); + + (<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>f</span>: <span class='ident'>expr</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>a</span>: <span class='ident'>expr</span>) + <span class='op'>=></span> ( <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>lift</span>::<span class='ident'>lift1</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>f</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>a</span>) ); + + (<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>f</span>: <span class='ident'>expr</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>a</span>: <span class='ident'>expr</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>b</span>: <span class='ident'>expr</span>) + <span class='op'>=></span> ( <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>lift</span>::<span class='ident'>lift2</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>f</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>a</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>b</span>) ); + + (<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>f</span>: <span class='ident'>expr</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>a</span>: <span class='ident'>expr</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>b</span>: <span class='ident'>expr</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>c</span>: <span class='ident'>expr</span>) + <span class='op'>=></span> ( <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>lift</span>::<span class='ident'>lift3</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>f</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>a</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>b</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>c</span>) ); + + (<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>f</span>: <span class='ident'>expr</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>a</span>: <span class='ident'>expr</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>b</span>: <span class='ident'>expr</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>c</span>: <span class='ident'>expr</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>d</span>: <span class='ident'>expr</span>) + <span class='op'>=></span> ( <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>lift</span>::<span class='ident'>lift4</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>f</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>a</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>b</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>c</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>d</span>) ); +} + + +<span class='doccomment'>/// Lift a 0-ary function.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>lift0</span><span class='op'><</span><span class='ident'>A</span>, <span class='ident'>F</span><span class='op'>></span>(<span class='ident'>f</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>F</span>: <span class='ident'>Fn</span>() <span class='op'>-></span> <span class='ident'>A</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span> +{ + <span class='ident'>commit</span>(<span class='op'>||</span> <span class='ident'>signal_build</span>(<span class='ident'>SignalFn</span>::<span class='ident'>from_fn</span>(<span class='ident'>f</span>), ())) +} + + +<span class='doccomment'>/// Lift a unary function.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>lift1</span><span class='op'><</span><span class='ident'>A</span>, <span class='ident'>B</span>, <span class='ident'>F</span><span class='op'>></span>(<span class='ident'>f</span>: <span class='ident'>F</span>, <span class='ident'>sa</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>B</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='ident'>A</span>) <span class='op'>-></span> <span class='ident'>B</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, +{ + <span class='kw'>fn</span> <span class='ident'>make_callback</span><span class='op'><</span><span class='ident'>A</span>, <span class='ident'>B</span>, <span class='ident'>F</span><span class='op'>></span>(<span class='ident'>f</span>: <span class='kw-2'>&</span><span class='ident'>Arc</span><span class='op'><</span><span class='ident'>F</span><span class='op'>></span>, <span class='ident'>parent</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>SignalFn</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>B</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='ident'>A</span>) <span class='op'>-></span> <span class='ident'>B</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + { + <span class='kw'>let</span> <span class='ident'>pclone</span> <span class='op'>=</span> <span class='ident'>parent</span>.<span class='ident'>clone</span>(); + <span class='kw'>let</span> <span class='ident'>f</span> <span class='op'>=</span> <span class='ident'>f</span>.<span class='ident'>clone</span>(); + <span class='kw'>match</span> <span class='op'>*</span><span class='ident'>signal_current</span>(<span class='kw-2'>&</span><span class='ident'>parent</span>).<span class='ident'>read</span>().<span class='ident'>unwrap</span>().<span class='ident'>future</span>() { + <span class='ident'>SignalFn</span>::<span class='ident'>Const</span>(<span class='kw-2'>ref</span> <span class='ident'>a</span>) <span class='op'>=></span> <span class='ident'>SignalFn</span>::<span class='ident'>Const</span>(<span class='ident'>f</span>(<span class='ident'>a</span>.<span class='ident'>clone</span>())), + <span class='ident'>SignalFn</span>::<span class='ident'>Func</span>(_) <span class='op'>=></span> <span class='ident'>SignalFn</span>::<span class='ident'>from_fn</span>(<span class='kw'>move</span> <span class='op'>||</span> <span class='ident'>f</span>(<span class='ident'>sample_raw</span>(<span class='kw-2'>&</span><span class='ident'>pclone</span>))), + } + } + + <span class='ident'>commit</span>(<span class='op'>||</span> { + <span class='kw'>let</span> <span class='ident'>f</span> <span class='op'>=</span> <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>f</span>); + <span class='kw'>let</span> <span class='ident'>signal</span> <span class='op'>=</span> <span class='ident'>signal_build</span>(<span class='ident'>make_callback</span>(<span class='kw-2'>&</span><span class='ident'>f</span>, <span class='kw-2'>&</span><span class='ident'>sa</span>), ()); + <span class='kw'>let</span> <span class='ident'>sa_clone</span> <span class='op'>=</span> <span class='ident'>sa</span>.<span class='ident'>clone</span>(); + <span class='ident'>reg_signal</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>signal_source</span>(<span class='kw-2'>&</span><span class='ident'>sa</span>).<span class='ident'>write</span>().<span class='ident'>unwrap</span>(), <span class='kw-2'>&</span><span class='ident'>signal</span>, + <span class='kw'>move</span> <span class='op'>|</span>_<span class='op'>|</span> <span class='ident'>make_callback</span>(<span class='kw-2'>&</span><span class='ident'>f</span>, <span class='kw-2'>&</span><span class='ident'>sa_clone</span>)); + <span class='ident'>signal</span> + }) +} + + +<span class='doccomment'>/// Lift a binary function.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>lift2</span><span class='op'><</span><span class='ident'>A</span>, <span class='ident'>B</span>, <span class='ident'>C</span>, <span class='ident'>F</span><span class='op'>></span>(<span class='ident'>f</span>: <span class='ident'>F</span>, <span class='ident'>sa</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>, <span class='ident'>sb</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>C</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>B</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>C</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='ident'>A</span>, <span class='ident'>B</span>) <span class='op'>-></span> <span class='ident'>C</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, +{ + <span class='kw'>fn</span> <span class='ident'>make_callback</span><span class='op'><</span><span class='ident'>A</span>, <span class='ident'>B</span>, <span class='ident'>C</span>, <span class='ident'>F</span><span class='op'>></span>(<span class='ident'>f</span>: <span class='kw-2'>&</span><span class='ident'>Arc</span><span class='op'><</span><span class='ident'>F</span><span class='op'>></span>, <span class='ident'>sa</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>, <span class='ident'>sb</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>SignalFn</span><span class='op'><</span><span class='ident'>C</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>B</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>C</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='ident'>A</span>, <span class='ident'>B</span>) <span class='op'>-></span> <span class='ident'>C</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + { + <span class='kw'>use</span> <span class='ident'>signal</span>::<span class='ident'>SignalFn</span>::{ <span class='ident'>Const</span>, <span class='ident'>Func</span> }; + <span class='kw'>let</span> <span class='ident'>sa_clone</span> <span class='op'>=</span> <span class='ident'>sa</span>.<span class='ident'>clone</span>(); + <span class='kw'>let</span> <span class='ident'>sb_clone</span> <span class='op'>=</span> <span class='ident'>sb</span>.<span class='ident'>clone</span>(); + <span class='kw'>let</span> <span class='ident'>f</span> <span class='op'>=</span> <span class='ident'>f</span>.<span class='ident'>clone</span>(); + <span class='kw'>match</span> ( + <span class='ident'>signal_current</span>(<span class='kw-2'>&</span><span class='ident'>sa</span>).<span class='ident'>read</span>().<span class='ident'>unwrap</span>().<span class='ident'>future</span>(), + <span class='ident'>signal_current</span>(<span class='kw-2'>&</span><span class='ident'>sb</span>).<span class='ident'>read</span>().<span class='ident'>unwrap</span>().<span class='ident'>future</span>(), + ) { + (<span class='kw-2'>&</span><span class='ident'>Const</span>(<span class='kw-2'>ref</span> <span class='ident'>a</span>), <span class='kw-2'>&</span><span class='ident'>Const</span>(<span class='kw-2'>ref</span> <span class='ident'>b</span>)) <span class='op'>=></span> <span class='ident'>Const</span>(<span class='ident'>f</span>(<span class='ident'>a</span>.<span class='ident'>clone</span>(), <span class='ident'>b</span>.<span class='ident'>clone</span>())), + (<span class='kw-2'>&</span><span class='ident'>Const</span>(<span class='kw-2'>ref</span> <span class='ident'>a</span>), <span class='kw-2'>&</span><span class='ident'>Func</span>(_)) <span class='op'>=></span> { + <span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>a</span>.<span class='ident'>clone</span>(); + <span class='ident'>SignalFn</span>::<span class='ident'>from_fn</span>(<span class='kw'>move</span> <span class='op'>||</span> <span class='ident'>f</span>(<span class='ident'>a</span>.<span class='ident'>clone</span>(), <span class='ident'>sample_raw</span>(<span class='kw-2'>&</span><span class='ident'>sb_clone</span>))) + }, + (<span class='kw-2'>&</span><span class='ident'>Func</span>(_), <span class='kw-2'>&</span><span class='ident'>Const</span>(<span class='kw-2'>ref</span> <span class='ident'>b</span>)) <span class='op'>=></span> { + <span class='kw'>let</span> <span class='ident'>b</span> <span class='op'>=</span> <span class='ident'>b</span>.<span class='ident'>clone</span>(); + <span class='ident'>SignalFn</span>::<span class='ident'>from_fn</span>(<span class='kw'>move</span> <span class='op'>||</span> <span class='ident'>f</span>(<span class='ident'>sample_raw</span>(<span class='kw-2'>&</span><span class='ident'>sa_clone</span>), <span class='ident'>b</span>.<span class='ident'>clone</span>())) + }, + (<span class='kw-2'>&</span><span class='ident'>Func</span>(_), <span class='kw-2'>&</span><span class='ident'>Func</span>(_)) <span class='op'>=></span> <span class='ident'>SignalFn</span>::<span class='ident'>from_fn</span>( + <span class='kw'>move</span> <span class='op'>||</span> <span class='ident'>f</span>(<span class='ident'>sample_raw</span>(<span class='kw-2'>&</span><span class='ident'>sa_clone</span>), <span class='ident'>sample_raw</span>(<span class='kw-2'>&</span><span class='ident'>sb_clone</span>)) + ), + } + } + + <span class='ident'>commit</span>(<span class='kw'>move</span> <span class='op'>||</span> { + <span class='kw'>let</span> <span class='ident'>f</span> <span class='op'>=</span> <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>f</span>); + <span class='kw'>let</span> <span class='ident'>signal</span> <span class='op'>=</span> <span class='ident'>signal_build</span>(<span class='ident'>make_callback</span>(<span class='kw-2'>&</span><span class='ident'>f</span>, <span class='kw-2'>&</span><span class='ident'>sa</span>, <span class='kw-2'>&</span><span class='ident'>sb</span>), ()); + <span class='ident'>reg_signal</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>signal_source</span>(<span class='kw-2'>&</span><span class='ident'>sa</span>).<span class='ident'>write</span>().<span class='ident'>unwrap</span>(), <span class='kw-2'>&</span><span class='ident'>signal</span>, { + <span class='kw'>let</span> <span class='ident'>sa_clone</span> <span class='op'>=</span> <span class='ident'>sa</span>.<span class='ident'>clone</span>(); + <span class='kw'>let</span> <span class='ident'>sb_clone</span> <span class='op'>=</span> <span class='ident'>sb</span>.<span class='ident'>clone</span>(); + <span class='kw'>let</span> <span class='ident'>f</span> <span class='op'>=</span> <span class='ident'>f</span>.<span class='ident'>clone</span>(); + <span class='kw'>move</span> <span class='op'>|</span>_<span class='op'>|</span> <span class='ident'>make_callback</span>(<span class='kw-2'>&</span><span class='ident'>f</span>, <span class='kw-2'>&</span><span class='ident'>sa_clone</span>, <span class='kw-2'>&</span><span class='ident'>sb_clone</span>) + }); + <span class='ident'>reg_signal</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>signal_source</span>(<span class='kw-2'>&</span><span class='ident'>sb</span>).<span class='ident'>write</span>().<span class='ident'>unwrap</span>(), <span class='kw-2'>&</span><span class='ident'>signal</span>, { + <span class='kw'>let</span> <span class='ident'>sa_clone</span> <span class='op'>=</span> <span class='ident'>sa</span>.<span class='ident'>clone</span>(); + <span class='kw'>let</span> <span class='ident'>sb_clone</span> <span class='op'>=</span> <span class='ident'>sb</span>.<span class='ident'>clone</span>(); + <span class='kw'>move</span> <span class='op'>|</span>_<span class='op'>|</span> <span class='ident'>make_callback</span>(<span class='kw-2'>&</span><span class='ident'>f</span>, <span class='kw-2'>&</span><span class='ident'>sa_clone</span>, <span class='kw-2'>&</span><span class='ident'>sb_clone</span>) + }); + <span class='ident'>signal</span> + }) +} + +<span class='doccomment'>/// Lift a ternary function.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>lift3</span><span class='op'><</span><span class='ident'>F</span>, <span class='ident'>A</span>, <span class='ident'>B</span>, <span class='ident'>C</span>, <span class='ident'>Ret</span><span class='op'>></span>(<span class='ident'>f</span>: <span class='ident'>F</span>, <span class='ident'>ca</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>, <span class='ident'>cb</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span>, <span class='ident'>cc</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>C</span><span class='op'>></span>) + <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>Ret</span><span class='op'>></span> +<span class='kw'>where</span> <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='ident'>A</span>, <span class='ident'>B</span>, <span class='ident'>C</span>) <span class='op'>-></span> <span class='ident'>Ret</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>B</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>C</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>Ret</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, +{ + <span class='ident'>lift2</span>(<span class='kw'>move</span> <span class='op'>|</span>(<span class='ident'>a</span>, <span class='ident'>b</span>), <span class='ident'>c</span><span class='op'>|</span> <span class='ident'>f</span>(<span class='ident'>a</span>, <span class='ident'>b</span>, <span class='ident'>c</span>), <span class='kw-2'>&</span><span class='ident'>lift2</span>(<span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>b</span><span class='op'>|</span> (<span class='ident'>a</span>, <span class='ident'>b</span>), <span class='ident'>ca</span>, <span class='ident'>cb</span>), <span class='ident'>cc</span>) +} + +<span class='doccomment'>/// Lift a quarternary function.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>lift4</span><span class='op'><</span><span class='ident'>F</span>, <span class='ident'>A</span>, <span class='ident'>B</span>, <span class='ident'>C</span>, <span class='ident'>D</span>, <span class='ident'>Ret</span><span class='op'>></span>(<span class='ident'>f</span>: <span class='ident'>F</span>, <span class='ident'>ca</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>, <span class='ident'>cb</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span>, <span class='ident'>cc</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>C</span><span class='op'>></span>, <span class='ident'>cd</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>D</span><span class='op'>></span>) + <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>Ret</span><span class='op'>></span> +<span class='kw'>where</span> <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='ident'>A</span>, <span class='ident'>B</span>, <span class='ident'>C</span>, <span class='ident'>D</span>) <span class='op'>-></span> <span class='ident'>Ret</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>B</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>C</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>D</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>Ret</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, +{ + <span class='ident'>lift2</span>( + <span class='kw'>move</span> <span class='op'>|</span>(<span class='ident'>a</span>, <span class='ident'>b</span>), (<span class='ident'>c</span>, <span class='ident'>d</span>)<span class='op'>|</span> <span class='ident'>f</span>(<span class='ident'>a</span>, <span class='ident'>b</span>, <span class='ident'>c</span>, <span class='ident'>d</span>), + <span class='kw-2'>&</span><span class='ident'>lift2</span>(<span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>b</span><span class='op'>|</span> (<span class='ident'>a</span>, <span class='ident'>b</span>), <span class='ident'>ca</span>, <span class='ident'>cb</span>), + <span class='kw-2'>&</span><span class='ident'>lift2</span>(<span class='op'>|</span><span class='ident'>c</span>, <span class='ident'>d</span><span class='op'>|</span> (<span class='ident'>c</span>, <span class='ident'>d</span>), <span class='ident'>cc</span>, <span class='ident'>cd</span>) + ) +} + + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>test</span> { + <span class='kw'>use</span> <span class='ident'>stream</span>::<span class='ident'>Sink</span>; + <span class='kw'>use</span> <span class='ident'>signal</span>::<span class='ident'>Signal</span>; + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>lift0</span>() { + <span class='kw'>let</span> <span class='ident'>signal</span> <span class='op'>=</span> <span class='macro'>lift</span><span class='macro'>!</span>(<span class='op'>||</span> <span class='number'>3</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>signal</span>.<span class='ident'>sample</span>(), <span class='number'>3</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>lift1</span>() { + <span class='kw'>let</span> <span class='ident'>sig2</span> <span class='op'>=</span> <span class='macro'>lift</span><span class='macro'>!</span>(<span class='op'>|</span><span class='ident'>n</span><span class='op'>|</span> <span class='ident'>n</span> <span class='op'>+</span> <span class='number'>2</span>, <span class='kw-2'>&</span><span class='ident'>Signal</span>::<span class='ident'>new</span>(<span class='number'>3</span>)); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>sig2</span>.<span class='ident'>sample</span>(), <span class='number'>5</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>lift2</span>() { + <span class='kw'>let</span> <span class='ident'>sink1</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>sink2</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>lifted</span> <span class='op'>=</span> <span class='macro'>lift</span><span class='macro'>!</span>(<span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>b</span><span class='op'>|</span> <span class='ident'>a</span> <span class='op'>+</span> <span class='ident'>b</span>, <span class='kw-2'>&</span><span class='ident'>sink1</span>.<span class='ident'>stream</span>().<span class='ident'>hold</span>(<span class='number'>0</span>), + <span class='kw-2'>&</span><span class='ident'>sink2</span>.<span class='ident'>stream</span>().<span class='ident'>hold</span>(<span class='number'>3</span>)); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>lifted</span>.<span class='ident'>sample</span>(), <span class='number'>3</span>); + <span class='ident'>sink1</span>.<span class='ident'>send</span>(<span class='number'>1</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>lifted</span>.<span class='ident'>sample</span>(), <span class='number'>4</span>); + <span class='ident'>sink2</span>.<span class='ident'>send</span>(<span class='number'>11</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>lifted</span>.<span class='ident'>sample</span>(), <span class='number'>12</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>lift2_identical</span>() { + <span class='kw'>let</span> <span class='ident'>sig</span> <span class='op'>=</span> <span class='ident'>Signal</span>::<span class='ident'>new</span>(<span class='number'>16</span>); + <span class='kw'>let</span> <span class='ident'>sig2</span> <span class='op'>=</span> <span class='macro'>lift</span><span class='macro'>!</span>(<span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>b</span><span class='op'>|</span> <span class='ident'>a</span> <span class='op'>+</span> <span class='ident'>b</span>, <span class='kw-2'>&</span><span class='ident'>sig</span>, <span class='kw-2'>&</span><span class='ident'>sig</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>sig2</span>.<span class='ident'>sample</span>(), <span class='number'>32</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>lift3</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='macro'>assert_eq</span><span class='macro'>!</span>( + <span class='macro'>lift</span><span class='macro'>!</span>(<span class='op'>|</span><span class='ident'>x</span>, <span class='ident'>y</span>, <span class='ident'>z</span><span class='op'>|</span> <span class='ident'>x</span> <span class='op'>+</span> <span class='number'>2</span> <span class='op'>*</span> <span class='ident'>y</span> <span class='op'>+</span> <span class='ident'>z</span>, + <span class='kw-2'>&</span><span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>hold</span>(<span class='number'>5</span>), + <span class='kw-2'>&</span><span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>hold</span>(<span class='number'>3</span>), + <span class='kw-2'>&</span><span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>hold</span>(<span class='op'>-</span><span class='number'>4</span>) + ).<span class='ident'>sample</span>(), + <span class='number'>7</span> + ); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>lift4</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='macro'>assert_eq</span><span class='macro'>!</span>( + <span class='macro'>lift</span><span class='macro'>!</span>(<span class='op'>|</span><span class='ident'>w</span>, <span class='ident'>x</span>, <span class='ident'>y</span>, <span class='ident'>z</span><span class='op'>|</span> <span class='number'>4</span> <span class='op'>*</span> <span class='ident'>w</span> <span class='op'>+</span> <span class='ident'>x</span> <span class='op'>+</span> <span class='number'>2</span> <span class='op'>*</span> <span class='ident'>y</span> <span class='op'>+</span> <span class='ident'>z</span>, + <span class='kw-2'>&</span><span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>hold</span>(<span class='op'>-</span><span class='number'>2</span>), + <span class='kw-2'>&</span><span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>hold</span>(<span class='number'>5</span>), + <span class='kw-2'>&</span><span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>hold</span>(<span class='number'>3</span>), + <span class='kw-2'>&</span><span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>hold</span>(<span class='op'>-</span><span class='number'>4</span>) + ).<span class='ident'>sample</span>(), + <span class='op'>-</span><span class='number'>1</span> + ); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>lift0_equal_within_transaction</span>() { + <span class='kw'>use</span> <span class='ident'>rand</span>::<span class='ident'>random</span>; + <span class='comment'>// Generate a completely random signal</span> + <span class='kw'>let</span> <span class='ident'>rnd</span> <span class='op'>=</span> <span class='macro'>lift</span><span class='macro'>!</span>(<span class='ident'>random</span>::<span class='op'><</span><span class='ident'>i64</span><span class='op'>></span>); + <span class='comment'>// Make a tuple with itself</span> + <span class='kw'>let</span> <span class='ident'>gather</span> <span class='op'>=</span> <span class='macro'>lift</span><span class='macro'>!</span>(<span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>b</span><span class='op'>|</span> (<span class='ident'>a</span>, <span class='ident'>b</span>), <span class='kw-2'>&</span><span class='ident'>rnd</span>, <span class='kw-2'>&</span><span class='ident'>rnd</span>); + <span class='comment'>// Both components should be equal</span> + <span class='kw'>let</span> (<span class='ident'>a</span>, <span class='ident'>b</span>) <span class='op'>=</span> <span class='ident'>gather</span>.<span class='ident'>sample</span>(); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>a</span>, <span class='ident'>b</span>); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "carboxyl"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/carboxyl/pending.rs.html b/src/carboxyl/pending.rs.html new file mode 100644 index 0000000..6e0f11f --- /dev/null +++ b/src/carboxyl/pending.rs.html @@ -0,0 +1,271 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/carboxyl-0.1.1/src/pending.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>pending.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10">10</span> +<span id="11">11</span> +<span id="12">12</span> +<span id="13">13</span> +<span id="14">14</span> +<span id="15">15</span> +<span id="16">16</span> +<span id="17">17</span> +<span id="18">18</span> +<span id="19">19</span> +<span id="20">20</span> +<span id="21">21</span> +<span id="22">22</span> +<span id="23">23</span> +<span id="24">24</span> +<span id="25">25</span> +<span id="26">26</span> +<span id="27">27</span> +<span id="28">28</span> +<span id="29">29</span> +<span id="30">30</span> +<span id="31">31</span> +<span id="32">32</span> +<span id="33">33</span> +<span id="34">34</span> +<span id="35">35</span> +<span id="36">36</span> +<span id="37">37</span> +<span id="38">38</span> +<span id="39">39</span> +<span id="40">40</span> +<span id="41">41</span> +<span id="42">42</span> +<span id="43">43</span> +<span id="44">44</span> +<span id="45">45</span> +<span id="46">46</span> +<span id="47">47</span> +<span id="48">48</span> +<span id="49">49</span> +<span id="50">50</span> +<span id="51">51</span> +<span id="52">52</span> +<span id="53">53</span> +<span id="54">54</span> +<span id="55">55</span> +<span id="56">56</span> +<span id="57">57</span> +<span id="58">58</span> +<span id="59">59</span> +<span id="60">60</span> +<span id="61">61</span> +<span id="62">62</span> +<span id="63">63</span> +<span id="64">64</span> +<span id="65">65</span> +<span id="66">66</span> +<span id="67">67</span> +<span id="68">68</span> +<span id="69">69</span> +<span id="70">70</span> +<span id="71">71</span> +<span id="72">72</span> +<span id="73">73</span> +<span id="74">74</span> +<span id="75">75</span> +<span id="76">76</span> +<span id="77">77</span> +<span id="78">78</span> +<span id="79">79</span> +<span id="80">80</span> +<span id="81">81</span> +<span id="82">82</span> +<span id="83">83</span> +<span id="84">84</span> +<span id="85">85</span> +<span id="86">86</span> +<span id="87">87</span> +</pre><pre class='rust '> +<span class='doccomment'>//! Pending wrapper</span> + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ops</span>::<span class='ident'>Deref</span>; + + +<span class='doccomment'>/// A pending value. This is a wrapper type that allows one to queue one new</span> +<span class='doccomment'>/// value without actually overwriting the old value. Later the most recently</span> +<span class='doccomment'>/// queued value can be updated.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Pending</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='ident'>current</span>: <span class='ident'>T</span>, + <span class='ident'>update</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> <span class='ident'>Pending</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='doccomment'>/// Create a new pending value.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>t</span>: <span class='ident'>T</span>) <span class='op'>-></span> <span class='ident'>Pending</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='ident'>Pending</span> { <span class='ident'>current</span>: <span class='ident'>t</span>, <span class='ident'>update</span>: <span class='prelude-val'>None</span> } + } + + <span class='doccomment'>/// Put an item in the queue. Ignores any previously queued items.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>queue</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>new</span>: <span class='ident'>T</span>) { + <span class='self'>self</span>.<span class='ident'>update</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>new</span>); + } + + <span class='doccomment'>/// Updates any update pending.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>update</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>t</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>update</span>.<span class='ident'>take</span>() { + <span class='self'>self</span>.<span class='ident'>current</span> <span class='op'>=</span> <span class='ident'>t</span>; + } + } + + <span class='doccomment'>/// Get the future value.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>future</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>T</span> { + <span class='self'>self</span>.<span class='ident'>update</span>.<span class='ident'>as_ref</span>().<span class='ident'>unwrap_or</span>(<span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>current</span>) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> <span class='ident'>Deref</span> <span class='kw'>for</span> <span class='ident'>Pending</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Target</span> <span class='op'>=</span> <span class='ident'>T</span>; + <span class='kw'>fn</span> <span class='ident'>deref</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>T</span> { <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>current</span> } +} + + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>test</span> { + <span class='kw'>use</span> <span class='ident'>super</span>::<span class='op'>*</span>; + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>new_derefs_identical</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='op'>*</span><span class='ident'>Pending</span>::<span class='ident'>new</span>(<span class='number'>3</span>), <span class='number'>3</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>queue_does_not_affect_deref</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>p</span> <span class='op'>=</span> <span class='ident'>Pending</span>::<span class='ident'>new</span>(<span class='number'>2</span>); + <span class='ident'>p</span>.<span class='ident'>queue</span>(<span class='number'>4</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='op'>*</span><span class='ident'>p</span>, <span class='number'>2</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>new_future_identical</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='op'>*</span><span class='ident'>Pending</span>::<span class='ident'>new</span>(<span class='number'>5</span>).<span class='ident'>future</span>(), <span class='number'>5</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>queue_affects_future</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>p</span> <span class='op'>=</span> <span class='ident'>Pending</span>::<span class='ident'>new</span>(<span class='number'>10</span>); + <span class='ident'>p</span>.<span class='ident'>queue</span>(<span class='number'>6</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='op'>*</span><span class='ident'>p</span>.<span class='ident'>future</span>(), <span class='number'>6</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>updated_deref</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>p</span> <span class='op'>=</span> <span class='ident'>Pending</span>::<span class='ident'>new</span>(<span class='op'>-</span><span class='number'>2</span>); + <span class='ident'>p</span>.<span class='ident'>queue</span>(<span class='number'>2</span>); + <span class='ident'>p</span>.<span class='ident'>update</span>(); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='op'>*</span><span class='ident'>p</span>, <span class='number'>2</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>updated_future</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>p</span> <span class='op'>=</span> <span class='ident'>Pending</span>::<span class='ident'>new</span>(<span class='op'>-</span><span class='number'>7</span>); + <span class='ident'>p</span>.<span class='ident'>queue</span>(<span class='number'>0</span>); + <span class='ident'>p</span>.<span class='ident'>update</span>(); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='op'>*</span><span class='ident'>p</span>.<span class='ident'>future</span>(), <span class='number'>0</span>); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "carboxyl"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/carboxyl/readonly.rs.html b/src/carboxyl/readonly.rs.html new file mode 100644 index 0000000..84fce7f --- /dev/null +++ b/src/carboxyl/readonly.rs.html @@ -0,0 +1,173 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/carboxyl-0.1.1/src/readonly.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>readonly.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10">10</span> +<span id="11">11</span> +<span id="12">12</span> +<span id="13">13</span> +<span id="14">14</span> +<span id="15">15</span> +<span id="16">16</span> +<span id="17">17</span> +<span id="18">18</span> +<span id="19">19</span> +<span id="20">20</span> +<span id="21">21</span> +<span id="22">22</span> +<span id="23">23</span> +<span id="24">24</span> +<span id="25">25</span> +<span id="26">26</span> +<span id="27">27</span> +<span id="28">28</span> +<span id="29">29</span> +<span id="30">30</span> +<span id="31">31</span> +<span id="32">32</span> +<span id="33">33</span> +<span id="34">34</span> +<span id="35">35</span> +<span id="36">36</span> +<span id="37">37</span> +<span id="38">38</span> +</pre><pre class='rust '> +<span class='doccomment'>//! Thread-safe read-only smart pointer.</span> + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>sync</span>::{ <span class='ident'>Arc</span>, <span class='ident'>RwLock</span>, <span class='ident'>RwLockReadGuard</span> }; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ops</span>::<span class='ident'>Deref</span>; + +<span class='doccomment'>/// Guards read-access into a read-only pointer.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ReadOnlyGuard</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>T</span>: <span class='lifetime'>'a</span><span class='op'>></span> { + <span class='ident'>guard</span>: <span class='ident'>RwLockReadGuard</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>T</span><span class='op'>></span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>T</span><span class='op'>></span> <span class='ident'>Deref</span> <span class='kw'>for</span> <span class='ident'>ReadOnlyGuard</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>T</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Target</span> <span class='op'>=</span> <span class='ident'>T</span>; + <span class='kw'>fn</span> <span class='ident'>deref</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>T</span> { <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>guard</span> } +} + +<span class='doccomment'>/// A thread-safe read-only smart pointer.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ReadOnly</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='ident'>ptr</span>: <span class='ident'>Arc</span><span class='op'><</span><span class='ident'>RwLock</span><span class='op'><</span><span class='ident'>T</span><span class='op'>>></span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> <span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>ReadOnly</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>ReadOnly</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='ident'>ReadOnly</span> { <span class='ident'>ptr</span>: <span class='self'>self</span>.<span class='ident'>ptr</span>.<span class='ident'>clone</span>() } + } +} + +<span class='doccomment'>/// Create a new read-only pointer.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>create</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span>(<span class='ident'>ptr</span>: <span class='ident'>Arc</span><span class='op'><</span><span class='ident'>RwLock</span><span class='op'><</span><span class='ident'>T</span><span class='op'>>></span>) <span class='op'>-></span> <span class='ident'>ReadOnly</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { <span class='ident'>ReadOnly</span> { <span class='ident'>ptr</span>: <span class='ident'>ptr</span> } } + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> <span class='ident'>ReadOnly</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='doccomment'>/// Gain read-access to the stored value.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// In case, the underlying data structure has been poisoned, it returns</span> + <span class='doccomment'>/// `None`.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>read</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>ReadOnlyGuard</span><span class='op'><</span><span class='ident'>T</span><span class='op'>>></span> { + <span class='self'>self</span>.<span class='ident'>ptr</span>.<span class='ident'>read</span>().<span class='ident'>ok</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>g</span><span class='op'>|</span> <span class='ident'>ReadOnlyGuard</span> { <span class='ident'>guard</span>: <span class='ident'>g</span> }) + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "carboxyl"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/carboxyl/signal.rs.html b/src/carboxyl/signal.rs.html new file mode 100644 index 0000000..659a0a7 --- /dev/null +++ b/src/carboxyl/signal.rs.html @@ -0,0 +1,1601 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/carboxyl-0.1.1/src/signal.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>signal.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +<span id="313">313</span> +<span id="314">314</span> +<span id="315">315</span> +<span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +<span id="326">326</span> +<span id="327">327</span> +<span id="328">328</span> +<span id="329">329</span> +<span id="330">330</span> +<span id="331">331</span> +<span id="332">332</span> +<span id="333">333</span> +<span id="334">334</span> +<span id="335">335</span> +<span id="336">336</span> +<span id="337">337</span> +<span id="338">338</span> +<span id="339">339</span> +<span id="340">340</span> +<span id="341">341</span> +<span id="342">342</span> +<span id="343">343</span> +<span id="344">344</span> +<span id="345">345</span> +<span id="346">346</span> +<span id="347">347</span> +<span id="348">348</span> +<span id="349">349</span> +<span id="350">350</span> +<span id="351">351</span> +<span id="352">352</span> +<span id="353">353</span> +<span id="354">354</span> +<span id="355">355</span> +<span id="356">356</span> +<span id="357">357</span> +<span id="358">358</span> +<span id="359">359</span> +<span id="360">360</span> +<span id="361">361</span> +<span id="362">362</span> +<span id="363">363</span> +<span id="364">364</span> +<span id="365">365</span> +<span id="366">366</span> +<span id="367">367</span> +<span id="368">368</span> +<span id="369">369</span> +<span id="370">370</span> +<span id="371">371</span> +<span id="372">372</span> +<span id="373">373</span> +<span id="374">374</span> +<span id="375">375</span> +<span id="376">376</span> +<span id="377">377</span> +<span id="378">378</span> +<span id="379">379</span> +<span id="380">380</span> +<span id="381">381</span> +<span id="382">382</span> +<span id="383">383</span> +<span id="384">384</span> +<span id="385">385</span> +<span id="386">386</span> +<span id="387">387</span> +<span id="388">388</span> +<span id="389">389</span> +<span id="390">390</span> +<span id="391">391</span> +<span id="392">392</span> +<span id="393">393</span> +<span id="394">394</span> +<span id="395">395</span> +<span id="396">396</span> +<span id="397">397</span> +<span id="398">398</span> +<span id="399">399</span> +<span id="400">400</span> +<span id="401">401</span> +<span id="402">402</span> +<span id="403">403</span> +<span id="404">404</span> +<span id="405">405</span> +<span id="406">406</span> +<span id="407">407</span> +<span id="408">408</span> +<span id="409">409</span> +<span id="410">410</span> +<span id="411">411</span> +<span id="412">412</span> +<span id="413">413</span> +<span id="414">414</span> +<span id="415">415</span> +<span id="416">416</span> +<span id="417">417</span> +<span id="418">418</span> +<span id="419">419</span> +<span id="420">420</span> +<span id="421">421</span> +<span id="422">422</span> +<span id="423">423</span> +<span id="424">424</span> +<span id="425">425</span> +<span id="426">426</span> +<span id="427">427</span> +<span id="428">428</span> +<span id="429">429</span> +<span id="430">430</span> +<span id="431">431</span> +<span id="432">432</span> +<span id="433">433</span> +<span id="434">434</span> +<span id="435">435</span> +<span id="436">436</span> +<span id="437">437</span> +<span id="438">438</span> +<span id="439">439</span> +<span id="440">440</span> +<span id="441">441</span> +<span id="442">442</span> +<span id="443">443</span> +<span id="444">444</span> +<span id="445">445</span> +<span id="446">446</span> +<span id="447">447</span> +<span id="448">448</span> +<span id="449">449</span> +<span id="450">450</span> +<span id="451">451</span> +<span id="452">452</span> +<span id="453">453</span> +<span id="454">454</span> +<span id="455">455</span> +<span id="456">456</span> +<span id="457">457</span> +<span id="458">458</span> +<span id="459">459</span> +<span id="460">460</span> +<span id="461">461</span> +<span id="462">462</span> +<span id="463">463</span> +<span id="464">464</span> +<span id="465">465</span> +<span id="466">466</span> +<span id="467">467</span> +<span id="468">468</span> +<span id="469">469</span> +<span id="470">470</span> +<span id="471">471</span> +<span id="472">472</span> +<span id="473">473</span> +<span id="474">474</span> +<span id="475">475</span> +<span id="476">476</span> +<span id="477">477</span> +<span id="478">478</span> +<span id="479">479</span> +<span id="480">480</span> +<span id="481">481</span> +<span id="482">482</span> +<span id="483">483</span> +<span id="484">484</span> +<span id="485">485</span> +<span id="486">486</span> +<span id="487">487</span> +<span id="488">488</span> +<span id="489">489</span> +<span id="490">490</span> +<span id="491">491</span> +<span id="492">492</span> +<span id="493">493</span> +<span id="494">494</span> +<span id="495">495</span> +<span id="496">496</span> +<span id="497">497</span> +<span id="498">498</span> +<span id="499">499</span> +<span id="500">500</span> +<span id="501">501</span> +<span id="502">502</span> +<span id="503">503</span> +<span id="504">504</span> +<span id="505">505</span> +<span id="506">506</span> +<span id="507">507</span> +<span id="508">508</span> +<span id="509">509</span> +<span id="510">510</span> +<span id="511">511</span> +<span id="512">512</span> +<span id="513">513</span> +<span id="514">514</span> +<span id="515">515</span> +<span id="516">516</span> +<span id="517">517</span> +<span id="518">518</span> +<span id="519">519</span> +<span id="520">520</span> +<span id="521">521</span> +<span id="522">522</span> +<span id="523">523</span> +<span id="524">524</span> +<span id="525">525</span> +<span id="526">526</span> +<span id="527">527</span> +<span id="528">528</span> +<span id="529">529</span> +<span id="530">530</span> +<span id="531">531</span> +<span id="532">532</span> +<span id="533">533</span> +<span id="534">534</span> +<span id="535">535</span> +<span id="536">536</span> +<span id="537">537</span> +<span id="538">538</span> +<span id="539">539</span> +<span id="540">540</span> +<span id="541">541</span> +<span id="542">542</span> +<span id="543">543</span> +<span id="544">544</span> +<span id="545">545</span> +<span id="546">546</span> +<span id="547">547</span> +<span id="548">548</span> +<span id="549">549</span> +<span id="550">550</span> +<span id="551">551</span> +<span id="552">552</span> +<span id="553">553</span> +<span id="554">554</span> +<span id="555">555</span> +<span id="556">556</span> +<span id="557">557</span> +<span id="558">558</span> +<span id="559">559</span> +<span id="560">560</span> +<span id="561">561</span> +<span id="562">562</span> +<span id="563">563</span> +<span id="564">564</span> +<span id="565">565</span> +<span id="566">566</span> +<span id="567">567</span> +<span id="568">568</span> +<span id="569">569</span> +<span id="570">570</span> +<span id="571">571</span> +<span id="572">572</span> +<span id="573">573</span> +<span id="574">574</span> +<span id="575">575</span> +<span id="576">576</span> +<span id="577">577</span> +<span id="578">578</span> +<span id="579">579</span> +<span id="580">580</span> +<span id="581">581</span> +<span id="582">582</span> +<span id="583">583</span> +<span id="584">584</span> +<span id="585">585</span> +<span id="586">586</span> +<span id="587">587</span> +<span id="588">588</span> +<span id="589">589</span> +<span id="590">590</span> +<span id="591">591</span> +<span id="592">592</span> +<span id="593">593</span> +<span id="594">594</span> +<span id="595">595</span> +<span id="596">596</span> +<span id="597">597</span> +<span id="598">598</span> +<span id="599">599</span> +<span id="600">600</span> +<span id="601">601</span> +<span id="602">602</span> +<span id="603">603</span> +<span id="604">604</span> +<span id="605">605</span> +<span id="606">606</span> +<span id="607">607</span> +<span id="608">608</span> +<span id="609">609</span> +<span id="610">610</span> +<span id="611">611</span> +<span id="612">612</span> +<span id="613">613</span> +<span id="614">614</span> +<span id="615">615</span> +<span id="616">616</span> +<span id="617">617</span> +<span id="618">618</span> +<span id="619">619</span> +<span id="620">620</span> +<span id="621">621</span> +<span id="622">622</span> +<span id="623">623</span> +<span id="624">624</span> +<span id="625">625</span> +<span id="626">626</span> +<span id="627">627</span> +<span id="628">628</span> +<span id="629">629</span> +<span id="630">630</span> +<span id="631">631</span> +<span id="632">632</span> +<span id="633">633</span> +<span id="634">634</span> +<span id="635">635</span> +<span id="636">636</span> +<span id="637">637</span> +<span id="638">638</span> +<span id="639">639</span> +<span id="640">640</span> +<span id="641">641</span> +<span id="642">642</span> +<span id="643">643</span> +<span id="644">644</span> +<span id="645">645</span> +<span id="646">646</span> +<span id="647">647</span> +<span id="648">648</span> +<span id="649">649</span> +<span id="650">650</span> +<span id="651">651</span> +<span id="652">652</span> +<span id="653">653</span> +<span id="654">654</span> +<span id="655">655</span> +<span id="656">656</span> +<span id="657">657</span> +<span id="658">658</span> +<span id="659">659</span> +<span id="660">660</span> +<span id="661">661</span> +<span id="662">662</span> +<span id="663">663</span> +<span id="664">664</span> +<span id="665">665</span> +<span id="666">666</span> +<span id="667">667</span> +<span id="668">668</span> +<span id="669">669</span> +<span id="670">670</span> +<span id="671">671</span> +<span id="672">672</span> +<span id="673">673</span> +<span id="674">674</span> +<span id="675">675</span> +<span id="676">676</span> +<span id="677">677</span> +<span id="678">678</span> +<span id="679">679</span> +<span id="680">680</span> +<span id="681">681</span> +<span id="682">682</span> +<span id="683">683</span> +<span id="684">684</span> +<span id="685">685</span> +<span id="686">686</span> +<span id="687">687</span> +<span id="688">688</span> +<span id="689">689</span> +<span id="690">690</span> +<span id="691">691</span> +<span id="692">692</span> +<span id="693">693</span> +<span id="694">694</span> +<span id="695">695</span> +<span id="696">696</span> +<span id="697">697</span> +<span id="698">698</span> +<span id="699">699</span> +<span id="700">700</span> +<span id="701">701</span> +<span id="702">702</span> +<span id="703">703</span> +<span id="704">704</span> +<span id="705">705</span> +<span id="706">706</span> +<span id="707">707</span> +<span id="708">708</span> +<span id="709">709</span> +<span id="710">710</span> +<span id="711">711</span> +<span id="712">712</span> +<span id="713">713</span> +<span id="714">714</span> +<span id="715">715</span> +<span id="716">716</span> +<span id="717">717</span> +<span id="718">718</span> +<span id="719">719</span> +<span id="720">720</span> +<span id="721">721</span> +<span id="722">722</span> +<span id="723">723</span> +<span id="724">724</span> +<span id="725">725</span> +<span id="726">726</span> +<span id="727">727</span> +<span id="728">728</span> +<span id="729">729</span> +<span id="730">730</span> +<span id="731">731</span> +<span id="732">732</span> +<span id="733">733</span> +<span id="734">734</span> +<span id="735">735</span> +<span id="736">736</span> +<span id="737">737</span> +<span id="738">738</span> +<span id="739">739</span> +<span id="740">740</span> +<span id="741">741</span> +<span id="742">742</span> +<span id="743">743</span> +<span id="744">744</span> +<span id="745">745</span> +<span id="746">746</span> +<span id="747">747</span> +<span id="748">748</span> +<span id="749">749</span> +<span id="750">750</span> +<span id="751">751</span> +<span id="752">752</span> +</pre><pre class='rust '> +<span class='doccomment'>//! Continuous time signals</span> + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>sync</span>::{ <span class='ident'>Arc</span>, <span class='ident'>Mutex</span>, <span class='ident'>RwLock</span> }; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ops</span>::<span class='ident'>Deref</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>fmt</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>use</span> <span class='ident'>quickcheck</span>::{ <span class='ident'>Arbitrary</span>, <span class='ident'>Gen</span> }; + +<span class='kw'>use</span> <span class='ident'>source</span>::{ <span class='ident'>Source</span>, <span class='ident'>with_weak</span>, <span class='ident'>CallbackError</span> }; +<span class='kw'>use</span> <span class='ident'>stream</span>::{ <span class='self'>self</span>, <span class='ident'>BoxClone</span>, <span class='ident'>Stream</span> }; +<span class='kw'>use</span> <span class='ident'>transaction</span>::{ <span class='ident'>commit</span>, <span class='ident'>end</span> }; +<span class='kw'>use</span> <span class='ident'>pending</span>::<span class='ident'>Pending</span>; +<span class='kw'>use</span> <span class='ident'>readonly</span>::{ <span class='self'>self</span>, <span class='ident'>ReadOnly</span> }; +<span class='kw'>use</span> <span class='ident'>lift</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>use</span> <span class='ident'>testing</span>::<span class='ident'>ArcFn</span>; + + +<span class='doccomment'>/// A functional signal. Caches its return value during a transaction.</span> +<span class='kw'>struct</span> <span class='ident'>FuncSignal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>func</span>: <span class='ident'>Box</span><span class='op'><</span><span class='ident'>Fn</span>() <span class='op'>-></span> <span class='ident'>A</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span>, + <span class='ident'>cache</span>: <span class='ident'>Arc</span><span class='op'><</span><span class='ident'>Mutex</span><span class='op'><</span><span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>A</span><span class='op'>>></span><span class='op'>></span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> <span class='ident'>FuncSignal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span><span class='op'><</span><span class='ident'>F</span>: <span class='ident'>Fn</span>() <span class='op'>-></span> <span class='ident'>A</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span>(<span class='ident'>f</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>FuncSignal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>FuncSignal</span> { + <span class='ident'>func</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>f</span>), + <span class='ident'>cache</span>: <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>Mutex</span>::<span class='ident'>new</span>(<span class='prelude-val'>None</span>)), + } + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span> <span class='ident'>FuncSignal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='doccomment'>/// Call the function or fetch the cached value if present.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>call</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>A</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>cached</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>cache</span>.<span class='ident'>lock</span>().<span class='ident'>unwrap</span>(); + <span class='kw'>match</span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='ident'>cached</span> { + <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>value</span>) <span class='op'>=></span> <span class='ident'>value</span>.<span class='ident'>clone</span>(), + <span class='ident'>cached</span> <span class='op'>=></span> { + <span class='comment'>// Register callback to reset cache at the end of the transaction</span> + <span class='kw'>let</span> <span class='ident'>cache</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>cache</span>.<span class='ident'>clone</span>(); + <span class='ident'>end</span>(<span class='kw'>move</span> <span class='op'>||</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>live</span> <span class='op'>=</span> <span class='ident'>cache</span>.<span class='ident'>lock</span>().<span class='ident'>unwrap</span>(); + <span class='op'>*</span><span class='ident'>live</span> <span class='op'>=</span> <span class='prelude-val'>None</span>; + }); + <span class='comment'>// Calculate & cache value</span> + <span class='kw'>let</span> <span class='ident'>value</span> <span class='op'>=</span> (<span class='self'>self</span>.<span class='ident'>func</span>)(); + <span class='op'>*</span><span class='ident'>cached</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>value</span>.<span class='ident'>clone</span>()); + <span class='ident'>value</span> + }, + } + } +} + + +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>SignalFn</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>Const</span>(<span class='ident'>A</span>), + <span class='ident'>Func</span>(<span class='ident'>FuncSignal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>), +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> <span class='ident'>SignalFn</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>from_fn</span><span class='op'><</span><span class='ident'>F</span>: <span class='ident'>Fn</span>() <span class='op'>-></span> <span class='ident'>A</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span>(<span class='ident'>f</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>SignalFn</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>SignalFn</span>::<span class='ident'>Func</span>(<span class='ident'>FuncSignal</span>::<span class='ident'>new</span>(<span class='ident'>f</span>)) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span> <span class='ident'>SignalFn</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>call</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>A</span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>SignalFn</span>::<span class='ident'>Const</span>(<span class='kw-2'>ref</span> <span class='ident'>a</span>) <span class='op'>=></span> <span class='ident'>a</span>.<span class='ident'>clone</span>(), + <span class='ident'>SignalFn</span>::<span class='ident'>Func</span>(<span class='kw-2'>ref</span> <span class='ident'>f</span>) <span class='op'>=></span> <span class='ident'>f</span>.<span class='ident'>call</span>(), + } + } +} + + +<span class='doccomment'>/// Helper function to register callback handlers related to signal construction.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>reg_signal</span><span class='op'><</span><span class='ident'>A</span>, <span class='ident'>B</span>, <span class='ident'>F</span><span class='op'>></span>(<span class='ident'>parent_source</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Source</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>, <span class='ident'>signal</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span>, <span class='ident'>handler</span>: <span class='ident'>F</span>) + <span class='kw'>where</span> <span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>B</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='ident'>A</span>) <span class='op'>-></span> <span class='ident'>SignalFn</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, +{ + <span class='kw'>let</span> <span class='ident'>weak_source</span> <span class='op'>=</span> <span class='ident'>signal</span>.<span class='ident'>source</span>.<span class='ident'>downgrade</span>(); + <span class='kw'>let</span> <span class='ident'>weak_current</span> <span class='op'>=</span> <span class='ident'>signal</span>.<span class='ident'>current</span>.<span class='ident'>downgrade</span>(); + <span class='ident'>parent_source</span>.<span class='ident'>register</span>(<span class='kw'>move</span> <span class='op'>|</span><span class='ident'>a</span><span class='op'>|</span> + <span class='ident'>weak_current</span>.<span class='ident'>upgrade</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>cur</span><span class='op'>|</span> <span class='ident'>end</span>( + <span class='kw'>move</span> <span class='op'>||</span> { <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>cur</span>.<span class='ident'>write</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>mut</span> <span class='ident'>cur</span><span class='op'>|</span> <span class='ident'>cur</span>.<span class='ident'>update</span>()); })) + .<span class='ident'>ok_or</span>(<span class='ident'>CallbackError</span>::<span class='ident'>Disappeared</span>) + .<span class='ident'>and</span>(<span class='ident'>with_weak</span>(<span class='kw-2'>&</span><span class='ident'>weak_current</span>, <span class='op'>|</span><span class='ident'>cur</span><span class='op'>|</span> <span class='ident'>cur</span>.<span class='ident'>queue</span>(<span class='ident'>handler</span>(<span class='ident'>a</span>)))) + .<span class='ident'>and</span>(<span class='ident'>with_weak</span>(<span class='kw-2'>&</span><span class='ident'>weak_source</span>, <span class='op'>|</span><span class='ident'>src</span><span class='op'>|</span> <span class='ident'>src</span>.<span class='ident'>send</span>(()))) + ); +} + + +<span class='doccomment'>/// External helper function to build a signal.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>signal_build</span><span class='op'><</span><span class='ident'>A</span>, <span class='ident'>K</span><span class='op'>></span>(<span class='ident'>func</span>: <span class='ident'>SignalFn</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>, <span class='ident'>keep_alive</span>: <span class='ident'>K</span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>K</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span> +{ + <span class='ident'>Signal</span>::<span class='ident'>build</span>(<span class='ident'>func</span>, <span class='ident'>keep_alive</span>) +} + +<span class='doccomment'>/// External accessor to current state of a signal.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>signal_current</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>(<span class='ident'>signal</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>Arc</span><span class='op'><</span><span class='ident'>RwLock</span><span class='op'><</span><span class='ident'>Pending</span><span class='op'><</span><span class='ident'>SignalFn</span><span class='op'><</span><span class='ident'>A</span><span class='op'>>></span><span class='op'>>></span> { + <span class='kw-2'>&</span><span class='ident'>signal</span>.<span class='ident'>current</span> +} + +<span class='doccomment'>/// External accessor to signal source.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>signal_source</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>(<span class='ident'>signal</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>Arc</span><span class='op'><</span><span class='ident'>RwLock</span><span class='op'><</span><span class='ident'>Source</span><span class='op'><</span>()<span class='op'>>></span><span class='op'>></span> { + <span class='kw-2'>&</span><span class='ident'>signal</span>.<span class='ident'>source</span> +} + +<span class='doccomment'>/// Sample the value of the signal without committing it as a transaction.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>sample_raw</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span>(<span class='ident'>signal</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>A</span> { + <span class='ident'>signal</span>.<span class='ident'>current</span>.<span class='ident'>read</span>().<span class='ident'>unwrap</span>().<span class='ident'>call</span>() +} + + +<span class='doccomment'>/// A continuous signal that changes over time.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Signals can be thought of as values that change over time. They have both a</span> +<span class='doccomment'>/// continuous and a discrete component. This means that their current value is</span> +<span class='doccomment'>/// defined by a function that can be called at any time. That function is only</span> +<span class='doccomment'>/// evaluated on-demand, when the signal's current value is sampled. (This is</span> +<span class='doccomment'>/// also called pull semantics in the literature on FRP.)</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// In addition, the current function used to sample a signal may change</span> +<span class='doccomment'>/// discretely in reaction to some event. For instance, it is possible to create</span> +<span class='doccomment'>/// a signal from an event stream, by holding the last event occurence as the</span> +<span class='doccomment'>/// current value of the stream.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Algebraic laws</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Signals come with some primitive methods to compose them with each other and</span> +<span class='doccomment'>/// with streams. Some of these primitives give the signals an algebraic</span> +<span class='doccomment'>/// structure.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ## Functor</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Signals form a functor under unary lifting. Thus, the following laws hold:</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// - Preservation of identity: `lift!(|x| x, &a) == a`,</span> +<span class='doccomment'>/// - Function composition: `lift!(|x| g(f(x)), &a) == lift!(g, &lift!(f, &a))`.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ## Applicative functor</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// By extension, using the notion of a signal of a function, signals also</span> +<span class='doccomment'>/// become an [applicative][ghc-applicative] using `Signal::new` as `pure` and</span> +<span class='doccomment'>/// `|sf, sa| lift!(|f, a| f(a), &sf, &sa)` as `<*>`.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// *TODO: Expand on this and replace the Haskell reference.*</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// [ghc-applicative]: https://downloads.haskell.org/~ghc/latest/docs/html/libraries/base/Control-Applicative.html</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>current</span>: <span class='ident'>Arc</span><span class='op'><</span><span class='ident'>RwLock</span><span class='op'><</span><span class='ident'>Pending</span><span class='op'><</span><span class='ident'>SignalFn</span><span class='op'><</span><span class='ident'>A</span><span class='op'>>></span><span class='op'>>></span>, + <span class='ident'>source</span>: <span class='ident'>Arc</span><span class='op'><</span><span class='ident'>RwLock</span><span class='op'><</span><span class='ident'>Source</span><span class='op'><</span>()<span class='op'>>></span><span class='op'>></span>, + <span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>dead_code</span>)]</span> + <span class='ident'>keep_alive</span>: <span class='ident'>Box</span><span class='op'><</span><span class='ident'>BoxClone</span><span class='op'>></span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> <span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>Signal</span> { + <span class='ident'>current</span>: <span class='self'>self</span>.<span class='ident'>current</span>.<span class='ident'>clone</span>(), + <span class='ident'>source</span>: <span class='self'>self</span>.<span class='ident'>source</span>.<span class='ident'>clone</span>(), + <span class='ident'>keep_alive</span>: <span class='self'>self</span>.<span class='ident'>keep_alive</span>.<span class='ident'>box_clone</span>(), + } + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>build</span><span class='op'><</span><span class='ident'>K</span><span class='op'>></span>(<span class='ident'>func</span>: <span class='ident'>SignalFn</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>, <span class='ident'>keep_alive</span>: <span class='ident'>K</span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>K</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span> + { + <span class='ident'>Signal</span> { + <span class='ident'>current</span>: <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>RwLock</span>::<span class='ident'>new</span>(<span class='ident'>Pending</span>::<span class='ident'>new</span>(<span class='ident'>func</span>))), + <span class='ident'>source</span>: <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>RwLock</span>::<span class='ident'>new</span>(<span class='ident'>Source</span>::<span class='ident'>new</span>())), + <span class='ident'>keep_alive</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>keep_alive</span>), + } + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='doccomment'>/// Create a constant signal.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>a</span>: <span class='ident'>A</span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>Signal</span>::<span class='ident'>build</span>(<span class='ident'>SignalFn</span>::<span class='ident'>Const</span>(<span class='ident'>a</span>), ()) + } + + <span class='doccomment'>/// Sample the current value of the signal.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>sample</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>A</span> { + <span class='ident'>commit</span>(<span class='op'>||</span> <span class='ident'>sample_raw</span>(<span class='self'>self</span>)) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='doccomment'>/// Create a signal with a cyclic definition.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The closure gets an undefined forward-declaration of a signal. It is</span> + <span class='doccomment'>/// supposed to return a self-referential definition of the same signal.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Sampling the forward-declared signal, before it is properly defined,</span> + <span class='doccomment'>/// will cause a run-time panic.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This pattern is useful to implement accumulators, counters and other</span> + <span class='doccomment'>/// loops that depend on the sampling behaviour of a signal before a</span> + <span class='doccomment'>/// transaction.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>cyclic</span><span class='op'><</span><span class='ident'>F</span><span class='op'>></span>(<span class='ident'>def</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>F</span>: <span class='ident'>FnOnce</span>(<span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> + { + <span class='ident'>commit</span>(<span class='op'>||</span> { + <span class='kw'>let</span> <span class='ident'>cycle</span> <span class='op'>=</span> <span class='ident'>SignalCycle</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>finished</span> <span class='op'>=</span> <span class='ident'>def</span>(<span class='kw-2'>&</span><span class='ident'>cycle</span>); + <span class='ident'>cycle</span>.<span class='ident'>define</span>(<span class='ident'>finished</span>) + }) + } + + <span class='doccomment'>/// Combine the signal with a stream in a snapshot.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// `snapshot` creates a new stream given a signal and a stream. Whenever</span> + <span class='doccomment'>/// the input stream fires an event, the output stream fires an event</span> + <span class='doccomment'>/// created from the signal's current value and that event using the</span> + <span class='doccomment'>/// supplied function.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>/// # use carboxyl::Sink;</span> + <span class='doccomment'>/// let sink1: Sink<i32> = Sink::new();</span> + <span class='doccomment'>/// let sink2: Sink<f64> = Sink::new();</span> + <span class='doccomment'>/// let mut events = sink1.stream().hold(1)</span> + <span class='doccomment'>/// .snapshot(&sink2.stream(), |a, b| (a, b))</span> + <span class='doccomment'>/// .events();</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// // Updating its signal does not cause the snapshot to fire</span> + <span class='doccomment'>/// sink1.send(4);</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// // However sending an event down the stream does</span> + <span class='doccomment'>/// sink2.send(3.0);</span> + <span class='doccomment'>/// assert_eq!(events.next(), Some((4, 3.0)));</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>snapshot</span><span class='op'><</span><span class='ident'>B</span>, <span class='ident'>C</span>, <span class='ident'>F</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>stream</span>: <span class='kw-2'>&</span><span class='ident'>Stream</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span>, <span class='ident'>f</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>C</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>B</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>C</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='ident'>A</span>, <span class='ident'>B</span>) <span class='op'>-></span> <span class='ident'>C</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + { + <span class='ident'>stream</span>::<span class='ident'>snapshot</span>(<span class='self'>self</span>, <span class='ident'>stream</span>, <span class='ident'>f</span>) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>>></span> { + <span class='doccomment'>/// Switch between signals.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This transforms a `Signal<Signal<A>>` into a `Signal<A>`. The nested</span> + <span class='doccomment'>/// signal can be thought of as a representation of a switch between different</span> + <span class='doccomment'>/// input signals, that allows one to change the structure of the dependency</span> + <span class='doccomment'>/// graph at run-time. `switch` provides a way to access the inner value of</span> + <span class='doccomment'>/// the currently active signal.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The following example demonstrates how to use this to switch between two</span> + <span class='doccomment'>/// input signals based on a `Button` event stream:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>/// # use carboxyl::Sink;</span> + <span class='doccomment'>/// // Button type</span> + <span class='doccomment'>/// #[derive(Clone, Show)]</span> + <span class='doccomment'>/// enum Button { A, B };</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// // The input sinks</span> + <span class='doccomment'>/// let sink_a = Sink::<i32>::new();</span> + <span class='doccomment'>/// let sink_b = Sink::<i32>::new();</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// // The button sink</span> + <span class='doccomment'>/// let sink_button = Sink::<Button>::new();</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// // Create the output</span> + <span class='doccomment'>/// let output = {</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// // Hold input sinks in a signal with some initials</span> + <span class='doccomment'>/// let channel_a = sink_a.stream().hold(1);</span> + <span class='doccomment'>/// let channel_b = sink_b.stream().hold(2);</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// // A trivial default channel used before any button event</span> + <span class='doccomment'>/// let default_channel = Sink::new().stream().hold(0);</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// // Map button to the channel signals, hold with the default channel as</span> + <span class='doccomment'>/// // initial value and switch between the signals</span> + <span class='doccomment'>/// sink_button</span> + <span class='doccomment'>/// .stream()</span> + <span class='doccomment'>/// .map(move |b| match b {</span> + <span class='doccomment'>/// Button::A => channel_a.clone(),</span> + <span class='doccomment'>/// Button::B => channel_b.clone(),</span> + <span class='doccomment'>/// })</span> + <span class='doccomment'>/// .hold(default_channel)</span> + <span class='doccomment'>/// .switch()</span> + <span class='doccomment'>/// };</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// // In the beginning, output will come from the default channel</span> + <span class='doccomment'>/// assert_eq!(output.sample(), 0);</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// // Let's switch to channel A</span> + <span class='doccomment'>/// sink_button.send(Button::A);</span> + <span class='doccomment'>/// assert_eq!(output.sample(), 1);</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// // And to channel B</span> + <span class='doccomment'>/// sink_button.send(Button::B);</span> + <span class='doccomment'>/// assert_eq!(output.sample(), 2);</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// // The channels can change, too, of course</span> + <span class='doccomment'>/// for k in 4..13 {</span> + <span class='doccomment'>/// sink_b.send(k);</span> + <span class='doccomment'>/// assert_eq!(output.sample(), k);</span> + <span class='doccomment'>/// }</span> + <span class='doccomment'>/// sink_button.send(Button::A);</span> + <span class='doccomment'>/// for k in 21..77 {</span> + <span class='doccomment'>/// sink_a.send(k);</span> + <span class='doccomment'>/// assert_eq!(output.sample(), k);</span> + <span class='doccomment'>/// }</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>switch</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>make_callback</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>(<span class='ident'>parent</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>>></span>) <span class='op'>-></span> <span class='ident'>SignalFn</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + { + <span class='comment'>// TODO: use information on inner value</span> + <span class='kw'>let</span> <span class='ident'>current_signal</span> <span class='op'>=</span> <span class='ident'>parent</span>.<span class='ident'>current</span>.<span class='ident'>clone</span>(); + <span class='ident'>SignalFn</span>::<span class='ident'>from_fn</span>(<span class='kw'>move</span> <span class='op'>||</span> + <span class='ident'>sample_raw</span>(<span class='kw-2'>&</span><span class='ident'>current_signal</span>.<span class='ident'>read</span>().<span class='ident'>unwrap</span>().<span class='ident'>call</span>()) + ) + } + <span class='ident'>commit</span>(<span class='op'>||</span> { + <span class='kw'>let</span> <span class='ident'>signal</span> <span class='op'>=</span> <span class='ident'>Signal</span>::<span class='ident'>build</span>(<span class='ident'>make_callback</span>(<span class='self'>self</span>), ()); + <span class='kw'>let</span> <span class='ident'>parent</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>clone</span>(); + <span class='ident'>reg_signal</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>source</span>.<span class='ident'>write</span>().<span class='ident'>unwrap</span>(), <span class='kw-2'>&</span><span class='ident'>signal</span>, + <span class='kw'>move</span> <span class='op'>|</span>_<span class='op'>|</span> <span class='ident'>make_callback</span>(<span class='kw-2'>&</span><span class='ident'>parent</span>)); + <span class='ident'>signal</span> + }) + } +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>, <span class='ident'>B</span><span class='op'>></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>ArcFn</span><span class='op'><</span><span class='ident'>A</span>, <span class='ident'>B</span><span class='op'>>></span> + <span class='kw'>where</span> <span class='ident'>A</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>B</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, +{ + <span class='doccomment'>/// Applicative functionality. Applies a signal of function to a signal of</span> + <span class='doccomment'>/// its argument.</span> + <span class='kw'>fn</span> <span class='ident'>apply</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>signal</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span> { + <span class='ident'>lift</span>::<span class='ident'>lift2</span>(<span class='op'>|</span><span class='ident'>f</span>, <span class='ident'>a</span><span class='op'>|</span> <span class='ident'>f</span>(<span class='ident'>a</span>), <span class='self'>self</span>, <span class='ident'>signal</span>) + } +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Arbitrary</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span> <span class='ident'>Arbitrary</span> <span class='kw'>for</span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>arbitrary</span><span class='op'><</span><span class='ident'>G</span>: <span class='ident'>Gen</span><span class='op'>></span>(<span class='ident'>g</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>G</span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>values</span> <span class='op'>=</span> <span class='ident'>Vec</span>::<span class='op'><</span><span class='ident'>A</span><span class='op'>></span>::<span class='ident'>arbitrary</span>(<span class='ident'>g</span>); + <span class='kw'>if</span> <span class='ident'>values</span>.<span class='ident'>is_empty</span>() { + <span class='ident'>Signal</span>::<span class='ident'>new</span>(<span class='ident'>Arbitrary</span>::<span class='ident'>arbitrary</span>(<span class='ident'>g</span>)) + } <span class='kw'>else</span> { + <span class='kw'>let</span> <span class='ident'>n</span> <span class='op'>=</span> <span class='ident'>Mutex</span>::<span class='ident'>new</span>(<span class='number'>0</span>); + <span class='ident'>lift</span>::<span class='ident'>lift0</span>(<span class='kw'>move</span> <span class='op'>||</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>n</span> <span class='op'>=</span> <span class='ident'>n</span>.<span class='ident'>lock</span>().<span class='ident'>unwrap</span>(); + <span class='op'>*</span><span class='ident'>n</span> <span class='op'>+=</span> <span class='number'>1</span>; + <span class='kw'>if</span> <span class='op'>*</span><span class='ident'>n</span> <span class='op'>>=</span> <span class='ident'>values</span>.<span class='ident'>len</span>() { <span class='op'>*</span><span class='ident'>n</span> <span class='op'>=</span> <span class='number'>0</span> } + <span class='ident'>values</span>[<span class='op'>*</span><span class='ident'>n</span>].<span class='ident'>clone</span>() + }) + } + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>fmt</span>::<span class='ident'>Debug</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span> <span class='ident'>fmt</span>::<span class='ident'>Debug</span> <span class='kw'>for</span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>fmt</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(), <span class='ident'>fmt</span>::<span class='ident'>Error</span><span class='op'>></span> { + <span class='ident'>commit</span>(<span class='op'>||</span> <span class='kw'>match</span> <span class='op'>*</span><span class='op'>*</span><span class='self'>self</span>.<span class='ident'>current</span>.<span class='ident'>read</span>().<span class='ident'>unwrap</span>() { + <span class='ident'>SignalFn</span>::<span class='ident'>Const</span>(<span class='kw-2'>ref</span> <span class='ident'>a</span>) <span class='op'>=></span> + <span class='ident'>fmt</span>.<span class='ident'>debug_struct</span>(<span class='string'>"Signal::const"</span>).<span class='ident'>field</span>(<span class='string'>"value"</span>, <span class='kw-2'>&</span><span class='ident'>a</span>).<span class='ident'>finish</span>(), + <span class='ident'>SignalFn</span>::<span class='ident'>Func</span>(<span class='kw-2'>ref</span> <span class='ident'>f</span>) <span class='op'>=></span> + <span class='ident'>fmt</span>.<span class='ident'>debug_struct</span>(<span class='string'>"Signal::fn"</span>).<span class='ident'>field</span>(<span class='string'>"current"</span>, <span class='kw-2'>&</span><span class='ident'>f</span>.<span class='ident'>call</span>()).<span class='ident'>finish</span>(), + }) + } +} + + +<span class='doccomment'>/// Forward declaration of a signal to create value loops.</span> +<span class='kw'>struct</span> <span class='ident'>SignalCycle</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>signal</span>: <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span> <span class='ident'>SignalCycle</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='doccomment'>/// Forward-declare a new signal.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>() <span class='op'>-></span> <span class='ident'>SignalCycle</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>const</span> <span class='ident'>ERR</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"sampled on forward-declaration of signal"</span>; + <span class='ident'>SignalCycle</span> { <span class='ident'>signal</span>: <span class='ident'>Signal</span>::<span class='ident'>build</span>(<span class='ident'>SignalFn</span>::<span class='ident'>from_fn</span>(<span class='op'>||</span> <span class='macro'>panic</span><span class='macro'>!</span>(<span class='ident'>ERR</span>)), ()) } + } + + <span class='doccomment'>/// Provide the signal with a definition.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>define</span>(<span class='self'>self</span>, <span class='ident'>definition</span>: <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='doccomment'>/// Generate a callback from the signal definition's current value.</span> + <span class='kw'>fn</span> <span class='ident'>make_callback</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>(<span class='ident'>current_def</span>: <span class='kw-2'>&</span><span class='ident'>Arc</span><span class='op'><</span><span class='ident'>RwLock</span><span class='op'><</span><span class='ident'>Pending</span><span class='op'><</span><span class='ident'>SignalFn</span><span class='op'><</span><span class='ident'>A</span><span class='op'>>></span><span class='op'>>></span>) <span class='op'>-></span> <span class='ident'>SignalFn</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span> + { + <span class='kw'>match</span> <span class='op'>*</span><span class='ident'>current_def</span>.<span class='ident'>read</span>().<span class='ident'>unwrap</span>().<span class='ident'>future</span>() { + <span class='ident'>SignalFn</span>::<span class='ident'>Const</span>(<span class='kw-2'>ref</span> <span class='ident'>a</span>) <span class='op'>=></span> <span class='ident'>SignalFn</span>::<span class='ident'>Const</span>(<span class='ident'>a</span>.<span class='ident'>clone</span>()), + <span class='ident'>SignalFn</span>::<span class='ident'>Func</span>(_) <span class='op'>=></span> <span class='ident'>SignalFn</span>::<span class='ident'>from_fn</span>({ + <span class='kw'>let</span> <span class='ident'>sig</span> <span class='op'>=</span> <span class='ident'>current_def</span>.<span class='ident'>downgrade</span>(); + <span class='kw'>move</span> <span class='op'>||</span> { + <span class='kw'>let</span> <span class='ident'>strong</span> <span class='op'>=</span> <span class='ident'>sig</span>.<span class='ident'>upgrade</span>().<span class='ident'>unwrap</span>(); + <span class='kw'>let</span> <span class='ident'>ret</span> <span class='op'>=</span> <span class='ident'>strong</span>.<span class='ident'>read</span>().<span class='ident'>unwrap</span>().<span class='ident'>call</span>(); + <span class='ident'>ret</span> + } + }), + } + } + <span class='ident'>commit</span>(<span class='kw'>move</span> <span class='op'>||</span> { + <span class='op'>*</span><span class='self'>self</span>.<span class='ident'>signal</span>.<span class='ident'>current</span>.<span class='ident'>write</span>().<span class='ident'>unwrap</span>() <span class='op'>=</span> <span class='ident'>Pending</span>::<span class='ident'>new</span>(<span class='ident'>make_callback</span>(<span class='kw-2'>&</span><span class='ident'>definition</span>.<span class='ident'>current</span>)); + <span class='kw'>let</span> <span class='ident'>weak_parent</span> <span class='op'>=</span> <span class='ident'>definition</span>.<span class='ident'>current</span>.<span class='ident'>downgrade</span>(); + <span class='ident'>reg_signal</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>definition</span>.<span class='ident'>source</span>.<span class='ident'>write</span>().<span class='ident'>unwrap</span>(), <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>signal</span>, + <span class='kw'>move</span> <span class='op'>|</span>_<span class='op'>|</span> <span class='ident'>make_callback</span>(<span class='kw-2'>&</span><span class='ident'>weak_parent</span>.<span class='ident'>upgrade</span>().<span class='ident'>unwrap</span>())); + <span class='ident'>Signal</span> { <span class='ident'>keep_alive</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>definition</span>), ..<span class='self'>self</span>.<span class='ident'>signal</span> } + }) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> <span class='ident'>Deref</span> <span class='kw'>for</span> <span class='ident'>SignalCycle</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Target</span> <span class='op'>=</span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>; + <span class='kw'>fn</span> <span class='ident'>deref</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>signal</span> } +} + + +<span class='doccomment'>/// Signal variant using inner mutability for efficient in-place updates.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This is the only kind of primitive that allows non-`Clone` types to be</span> +<span class='doccomment'>/// wrapped into functional reactive abstractions. The API is somewhat different</span> +<span class='doccomment'>/// from that of a regular signal to accommodate this.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// One cannot directly sample a `SignalMut` as this would require a clone.</span> +<span class='doccomment'>/// Instead it comes with a couple of adaptor methods that mimick a subset of</span> +<span class='doccomment'>/// the `Signal` API. However, all functions passed to these methods take the</span> +<span class='doccomment'>/// argument coming from the `SignalMut` by reference.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>SignalMut</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>inner</span>: <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>ReadOnly</span><span class='op'><</span><span class='ident'>A</span><span class='op'>>></span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span> <span class='ident'>SignalMut</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='doccomment'>/// Semantically the same as `Signal::snapshot`</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The key difference here is, that the combining function takes its first</span> + <span class='doccomment'>/// argument by reference, as it can't be moved out of the `SignalMut`.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// # Example</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>/// # use carboxyl::Sink;</span> + <span class='doccomment'>/// let sink1 = Sink::new();</span> + <span class='doccomment'>/// let sink2 = Sink::new();</span> + <span class='doccomment'>/// // Collect values in a mutable `Vec`</span> + <span class='doccomment'>/// let values = sink1.stream().scan_mut(vec![], |v, a| v.push(a));</span> + <span class='doccomment'>/// // Snapshot some value from it</span> + <span class='doccomment'>/// let mut index = values.snapshot(&sink2.stream(),</span> + <span class='doccomment'>/// |v, k| v.get(k).map(|x| *x)</span> + <span class='doccomment'>/// ).events();</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// sink1.send(4);</span> + <span class='doccomment'>/// sink1.send(5);</span> + <span class='doccomment'>/// sink2.send(0);</span> + <span class='doccomment'>/// assert_eq!(index.next(), Some(Some(4)));</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// sink2.send(1);</span> + <span class='doccomment'>/// assert_eq!(index.next(), Some(Some(5)));</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// sink2.send(2);</span> + <span class='doccomment'>/// assert_eq!(index.next(), Some(None));</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>snapshot</span><span class='op'><</span><span class='ident'>B</span>, <span class='ident'>C</span>, <span class='ident'>F</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>stream</span>: <span class='kw-2'>&</span><span class='ident'>Stream</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span>, <span class='ident'>f</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>C</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>B</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>C</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='kw-2'>&</span><span class='ident'>A</span>, <span class='ident'>B</span>) <span class='op'>-></span> <span class='ident'>C</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + { + <span class='self'>self</span>.<span class='ident'>inner</span>.<span class='ident'>snapshot</span>(<span class='ident'>stream</span>, <span class='kw'>move</span> <span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>b</span><span class='op'>|</span> <span class='ident'>f</span>(<span class='kw-2'>&</span><span class='ident'>a</span>.<span class='ident'>read</span>().<span class='ident'>unwrap</span>(), <span class='ident'>b</span>)) + } + + <span class='doccomment'>/// Similar to `lift2`. Combines a `SignalMut` with a `Signal` using a</span> + <span class='doccomment'>/// function. The function takes its first argument by reference.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>combine</span><span class='op'><</span><span class='ident'>B</span>, <span class='ident'>C</span>, <span class='ident'>F</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>signal</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span>, <span class='ident'>f</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>C</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>B</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>C</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='kw-2'>&</span><span class='ident'>A</span>, <span class='ident'>B</span>) <span class='op'>-></span> <span class='ident'>C</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + { + <span class='ident'>lift</span>::<span class='ident'>lift2</span>( + <span class='kw'>move</span> <span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>b</span><span class='op'>|</span> <span class='ident'>f</span>(<span class='kw-2'>&</span><span class='ident'>a</span>.<span class='ident'>read</span>().<span class='ident'>unwrap</span>(), <span class='ident'>b</span>), + <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>inner</span>, <span class='kw-2'>&</span><span class='ident'>signal</span> + ) + } + + <span class='doccomment'>/// Similar to `lift2`, but combines two `SignalMut` using a function. The</span> + <span class='doccomment'>/// supplied function takes both arguments by reference.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// # Example</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>/// # use carboxyl::Sink;</span> + <span class='doccomment'>/// let sink: Sink<i32> = Sink::new();</span> + <span class='doccomment'>/// let sum = sink.stream().scan_mut(0, |sum, a| *sum += a);</span> + <span class='doccomment'>/// let product = sink.stream().scan_mut(1, |prod, a| *prod *= a);</span> + <span class='doccomment'>/// let combo = sum.combine_mut(&product, |s, p| (*s, *p));</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// sink.send(1);</span> + <span class='doccomment'>/// assert_eq!(combo.sample(), (1, 1));</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// sink.send(3);</span> + <span class='doccomment'>/// assert_eq!(combo.sample(), (4, 3));</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// sink.send(5);</span> + <span class='doccomment'>/// assert_eq!(combo.sample(), (9, 15));</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>combine_mut</span><span class='op'><</span><span class='ident'>B</span>, <span class='ident'>C</span>, <span class='ident'>F</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>SignalMut</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span>, <span class='ident'>f</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>C</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>B</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>C</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='kw-2'>&</span><span class='ident'>A</span>, <span class='kw-2'>&</span><span class='ident'>B</span>) <span class='op'>-></span> <span class='ident'>C</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + { + <span class='ident'>lift</span>::<span class='ident'>lift2</span>( + <span class='kw'>move</span> <span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>b</span><span class='op'>|</span> <span class='ident'>f</span>(<span class='kw-2'>&</span><span class='ident'>a</span>.<span class='ident'>read</span>().<span class='ident'>unwrap</span>(), <span class='kw-2'>&</span><span class='ident'>b</span>.<span class='ident'>read</span>().<span class='ident'>unwrap</span>()), + <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>inner</span>, <span class='kw-2'>&</span><span class='ident'>other</span>.<span class='ident'>inner</span> + ) + } +} + + +<span class='doccomment'>/// Same as Stream::hold.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>hold</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>(<span class='ident'>initial</span>: <span class='ident'>A</span>, <span class='ident'>stream</span>: <span class='kw-2'>&</span><span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, +{ + <span class='ident'>commit</span>(<span class='op'>||</span> { + <span class='kw'>let</span> <span class='ident'>signal</span> <span class='op'>=</span> <span class='ident'>Signal</span>::<span class='ident'>build</span>(<span class='ident'>SignalFn</span>::<span class='ident'>Const</span>(<span class='ident'>initial</span>), <span class='ident'>stream</span>.<span class='ident'>clone</span>()); + <span class='ident'>reg_signal</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>stream</span>::<span class='ident'>source</span>(<span class='kw-2'>&</span><span class='ident'>stream</span>).<span class='ident'>write</span>().<span class='ident'>unwrap</span>(), <span class='kw-2'>&</span><span class='ident'>signal</span>, <span class='ident'>SignalFn</span>::<span class='ident'>Const</span>); + <span class='ident'>signal</span> + }) +} + + +<span class='doccomment'>/// Same as Stream::scan_mut.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>scan_mut</span><span class='op'><</span><span class='ident'>A</span>, <span class='ident'>B</span>, <span class='ident'>F</span><span class='op'>></span>(<span class='ident'>stream</span>: <span class='kw-2'>&</span><span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>, <span class='ident'>initial</span>: <span class='ident'>B</span>, <span class='ident'>f</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>SignalMut</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>B</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>B</span>, <span class='ident'>A</span>) <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, +{ + <span class='ident'>commit</span>(<span class='kw'>move</span> <span class='op'>||</span> { + <span class='kw'>let</span> <span class='ident'>state</span> <span class='op'>=</span> <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>RwLock</span>::<span class='ident'>new</span>(<span class='ident'>initial</span>)); + <span class='kw'>let</span> <span class='ident'>signal</span> <span class='op'>=</span> <span class='ident'>Signal</span>::<span class='ident'>build</span>(<span class='ident'>SignalFn</span>::<span class='ident'>Const</span>(<span class='ident'>readonly</span>::<span class='ident'>create</span>(<span class='ident'>state</span>.<span class='ident'>clone</span>())), <span class='ident'>stream</span>.<span class='ident'>clone</span>()); + <span class='ident'>reg_signal</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>stream</span>::<span class='ident'>source</span>(<span class='kw-2'>&</span><span class='ident'>stream</span>).<span class='ident'>write</span>().<span class='ident'>unwrap</span>(), <span class='kw-2'>&</span><span class='ident'>signal</span>, + <span class='kw'>move</span> <span class='op'>|</span><span class='ident'>a</span><span class='op'>|</span> { <span class='ident'>f</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>state</span>.<span class='ident'>write</span>().<span class='ident'>unwrap</span>(), <span class='ident'>a</span>); <span class='ident'>SignalFn</span>::<span class='ident'>Const</span>(<span class='ident'>readonly</span>::<span class='ident'>create</span>(<span class='ident'>state</span>.<span class='ident'>clone</span>())) }); + <span class='ident'>SignalMut</span> { <span class='ident'>inner</span>: <span class='ident'>signal</span> } + }) +} + + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>test</span> { + <span class='kw'>use</span> <span class='ident'>quickcheck</span>::<span class='ident'>quickcheck</span>; + + <span class='kw'>use</span> ::<span class='ident'>stream</span>::<span class='ident'>Sink</span>; + <span class='kw'>use</span> ::<span class='ident'>signal</span>::{ <span class='self'>self</span>, <span class='ident'>Signal</span>, <span class='ident'>SignalCycle</span> }; + <span class='kw'>use</span> ::<span class='ident'>lift</span>::<span class='ident'>lift1</span>; + <span class='kw'>use</span> ::<span class='ident'>testing</span>::{ <span class='ident'>ArcFn</span>, <span class='ident'>signal_eq</span>, <span class='ident'>id</span>, <span class='ident'>pure_fn</span>, <span class='ident'>partial_comp</span> }; + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>functor_identity</span>() { + <span class='kw'>fn</span> <span class='ident'>check</span>(<span class='ident'>signal</span>: <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>let</span> <span class='ident'>eq</span> <span class='op'>=</span> <span class='ident'>signal_eq</span>(<span class='kw-2'>&</span><span class='ident'>signal</span>, <span class='kw-2'>&</span><span class='ident'>lift1</span>(<span class='ident'>id</span>, <span class='kw-2'>&</span><span class='ident'>signal</span>)); + (<span class='number'>0</span>..<span class='number'>10</span>).<span class='ident'>all</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='ident'>eq</span>.<span class='ident'>sample</span>()) + } + <span class='ident'>quickcheck</span>(<span class='ident'>check</span> <span class='kw'>as</span> <span class='kw'>fn</span>(<span class='ident'>Signal</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>bool</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>functor_composition</span>() { + <span class='kw'>fn</span> <span class='ident'>check</span>(<span class='ident'>signal</span>: <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>fn</span> <span class='ident'>f</span>(<span class='ident'>n</span>: <span class='ident'>i32</span>) <span class='op'>-></span> <span class='ident'>i32</span> { <span class='number'>3</span> <span class='op'>*</span> <span class='ident'>n</span> } + <span class='kw'>fn</span> <span class='ident'>g</span>(<span class='ident'>n</span>: <span class='ident'>i32</span>) <span class='op'>-></span> <span class='ident'>i32</span> { <span class='ident'>n</span> <span class='op'>+</span> <span class='number'>2</span> } + <span class='kw'>let</span> <span class='ident'>eq</span> <span class='op'>=</span> <span class='ident'>signal_eq</span>( + <span class='kw-2'>&</span><span class='ident'>lift1</span>(<span class='op'>|</span><span class='ident'>n</span><span class='op'>|</span> <span class='ident'>f</span>(<span class='ident'>g</span>(<span class='ident'>n</span>)), <span class='kw-2'>&</span><span class='ident'>signal</span>), + <span class='kw-2'>&</span><span class='ident'>lift1</span>(<span class='ident'>f</span>, <span class='kw-2'>&</span><span class='ident'>lift1</span>(<span class='ident'>g</span>, <span class='kw-2'>&</span><span class='ident'>signal</span>)) + ); + (<span class='number'>0</span>..<span class='number'>10</span>).<span class='ident'>all</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='ident'>eq</span>.<span class='ident'>sample</span>()) + } + <span class='ident'>quickcheck</span>(<span class='ident'>check</span> <span class='kw'>as</span> <span class='kw'>fn</span>(<span class='ident'>Signal</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>bool</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>applicative_identity</span>() { + <span class='kw'>fn</span> <span class='ident'>check</span>(<span class='ident'>signal</span>: <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>let</span> <span class='ident'>eq</span> <span class='op'>=</span> <span class='ident'>signal_eq</span>(<span class='kw-2'>&</span><span class='ident'>pure_fn</span>(<span class='ident'>id</span>).<span class='ident'>apply</span>(<span class='kw-2'>&</span><span class='ident'>signal</span>), <span class='kw-2'>&</span><span class='ident'>signal</span>); + (<span class='number'>0</span>..<span class='number'>10</span>).<span class='ident'>all</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='ident'>eq</span>.<span class='ident'>sample</span>()) + } + <span class='ident'>quickcheck</span>(<span class='ident'>check</span> <span class='kw'>as</span> <span class='kw'>fn</span>(<span class='ident'>Signal</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>bool</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>applicative_composition</span>() { + <span class='kw'>fn</span> <span class='ident'>check</span>(<span class='ident'>signal</span>: <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>fn</span> <span class='ident'>f</span>(<span class='ident'>n</span>: <span class='ident'>i32</span>) <span class='op'>-></span> <span class='ident'>i32</span> { <span class='ident'>n</span> <span class='op'>*</span> <span class='number'>4</span> } + <span class='kw'>fn</span> <span class='ident'>g</span>(<span class='ident'>n</span>: <span class='ident'>i32</span>) <span class='op'>-></span> <span class='ident'>i32</span> { <span class='ident'>n</span> <span class='op'>-</span> <span class='number'>3</span> } + <span class='kw'>let</span> <span class='ident'>u</span> <span class='op'>=</span> <span class='ident'>pure_fn</span>(<span class='ident'>f</span>); + <span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='ident'>pure_fn</span>(<span class='ident'>g</span>); + <span class='kw'>let</span> <span class='ident'>eq</span> <span class='op'>=</span> <span class='ident'>signal_eq</span>( + <span class='kw-2'>&</span><span class='ident'>pure_fn</span>(<span class='ident'>partial_comp</span>).<span class='ident'>apply</span>(<span class='kw-2'>&</span><span class='ident'>u</span>).<span class='ident'>apply</span>(<span class='kw-2'>&</span><span class='ident'>v</span>).<span class='ident'>apply</span>(<span class='kw-2'>&</span><span class='ident'>signal</span>), + <span class='kw-2'>&</span><span class='ident'>u</span>.<span class='ident'>apply</span>(<span class='kw-2'>&</span><span class='ident'>v</span>.<span class='ident'>apply</span>(<span class='kw-2'>&</span><span class='ident'>signal</span>)) + ); + (<span class='number'>0</span>..<span class='number'>10</span>).<span class='ident'>all</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='ident'>eq</span>.<span class='ident'>sample</span>()) + } + <span class='ident'>quickcheck</span>(<span class='ident'>check</span> <span class='kw'>as</span> <span class='kw'>fn</span>(<span class='ident'>Signal</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>bool</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>applicative_homomorphism</span>() { + <span class='kw'>fn</span> <span class='ident'>check</span>(<span class='ident'>x</span>: <span class='ident'>i32</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>fn</span> <span class='ident'>f</span>(<span class='ident'>x</span>: <span class='ident'>i32</span>) <span class='op'>-></span> <span class='ident'>i32</span> { <span class='ident'>x</span> <span class='op'>*</span> (<span class='op'>-</span><span class='number'>5</span>) } + <span class='kw'>let</span> <span class='ident'>eq</span> <span class='op'>=</span> <span class='ident'>signal_eq</span>( + <span class='kw-2'>&</span><span class='ident'>pure_fn</span>(<span class='ident'>f</span>).<span class='ident'>apply</span>(<span class='kw-2'>&</span><span class='ident'>Signal</span>::<span class='ident'>new</span>(<span class='ident'>x</span>)), + <span class='kw-2'>&</span><span class='ident'>Signal</span>::<span class='ident'>new</span>(<span class='ident'>f</span>(<span class='ident'>x</span>)) + ); + (<span class='number'>0</span>..<span class='number'>10</span>).<span class='ident'>all</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='ident'>eq</span>.<span class='ident'>sample</span>()) + } + <span class='ident'>quickcheck</span>(<span class='ident'>check</span> <span class='kw'>as</span> <span class='kw'>fn</span>(<span class='ident'>i32</span>) <span class='op'>-></span> <span class='ident'>bool</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>applicative_interchange</span>() { + <span class='kw'>fn</span> <span class='ident'>check</span>(<span class='ident'>x</span>: <span class='ident'>i32</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>fn</span> <span class='ident'>f</span>(<span class='ident'>x</span>: <span class='ident'>i32</span>) <span class='op'>-></span> <span class='ident'>i32</span> { <span class='ident'>x</span> <span class='op'>*</span> <span class='number'>2</span> <span class='op'>-</span> <span class='number'>7</span> } + <span class='kw'>let</span> <span class='ident'>u</span> <span class='op'>=</span> <span class='ident'>pure_fn</span>(<span class='ident'>f</span>); + <span class='kw'>let</span> <span class='ident'>eq</span> <span class='op'>=</span> <span class='ident'>signal_eq</span>( + <span class='kw-2'>&</span><span class='ident'>u</span>.<span class='ident'>apply</span>(<span class='kw-2'>&</span><span class='ident'>Signal</span>::<span class='ident'>new</span>(<span class='ident'>x</span>)), + <span class='kw-2'>&</span><span class='ident'>pure_fn</span>(<span class='kw'>move</span> <span class='op'>|</span><span class='ident'>f</span>: <span class='ident'>ArcFn</span><span class='op'><</span><span class='ident'>i32</span>, <span class='ident'>i32</span><span class='op'>></span><span class='op'>|</span> <span class='ident'>f</span>(<span class='ident'>x</span>)).<span class='ident'>apply</span>(<span class='kw-2'>&</span><span class='ident'>u</span>) + ); + (<span class='number'>0</span>..<span class='number'>10</span>).<span class='ident'>all</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='ident'>eq</span>.<span class='ident'>sample</span>()) + } + <span class='ident'>quickcheck</span>(<span class='ident'>check</span> <span class='kw'>as</span> <span class='kw'>fn</span>(<span class='ident'>i32</span>) <span class='op'>-></span> <span class='ident'>bool</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>clone</span>() { + <span class='kw'>let</span> <span class='ident'>b</span> <span class='op'>=</span> <span class='ident'>Signal</span>::<span class='ident'>new</span>(<span class='number'>3</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>b</span>.<span class='ident'>clone</span>().<span class='ident'>sample</span>(), <span class='number'>3</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>hold</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>signal</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>hold</span>(<span class='number'>3</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>signal</span>.<span class='ident'>sample</span>(), <span class='number'>3</span>); + <span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='number'>4</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>signal</span>.<span class='ident'>sample</span>(), <span class='number'>4</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>hold_implicit_stream</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>signal</span> <span class='op'>=</span> <span class='ident'>signal</span>::<span class='ident'>hold</span>(<span class='number'>0</span>, <span class='kw-2'>&</span><span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>n</span><span class='op'>|</span> <span class='number'>2</span> <span class='op'>*</span> <span class='ident'>n</span>)); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>signal</span>.<span class='ident'>sample</span>(), <span class='number'>0</span>); + <span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='number'>4</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>signal</span>.<span class='ident'>sample</span>(), <span class='number'>8</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>snapshot</span>() { + <span class='kw'>let</span> <span class='ident'>sink1</span>: <span class='ident'>Sink</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>sink2</span>: <span class='ident'>Sink</span><span class='op'><</span><span class='ident'>f64</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>snap_events</span> <span class='op'>=</span> <span class='ident'>sink1</span>.<span class='ident'>stream</span>().<span class='ident'>hold</span>(<span class='number'>1</span>) + .<span class='ident'>snapshot</span>(<span class='kw-2'>&</span><span class='ident'>sink2</span>.<span class='ident'>stream</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> <span class='ident'>x</span> <span class='op'>+</span> <span class='number'>3.0</span>), <span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>b</span><span class='op'>|</span> (<span class='ident'>a</span>, <span class='ident'>b</span>)) + .<span class='ident'>events</span>(); + <span class='ident'>sink2</span>.<span class='ident'>send</span>(<span class='number'>4.0</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>snap_events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>((<span class='number'>1</span>, <span class='number'>7.0</span>))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>snapshot_2</span>() { + <span class='kw'>let</span> <span class='ident'>ev1</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>beh1</span> <span class='op'>=</span> <span class='ident'>ev1</span>.<span class='ident'>stream</span>().<span class='ident'>hold</span>(<span class='number'>5</span>); + <span class='kw'>let</span> <span class='ident'>ev2</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>snap</span> <span class='op'>=</span> <span class='ident'>beh1</span>.<span class='ident'>snapshot</span>(<span class='kw-2'>&</span><span class='ident'>ev2</span>.<span class='ident'>stream</span>(), <span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>b</span><span class='op'>|</span> (<span class='ident'>a</span>, <span class='ident'>b</span>)); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>events</span> <span class='op'>=</span> <span class='ident'>snap</span>.<span class='ident'>events</span>(); + <span class='ident'>ev2</span>.<span class='ident'>send</span>(<span class='number'>4</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>((<span class='number'>5</span>, <span class='number'>4</span>))); + <span class='ident'>ev1</span>.<span class='ident'>send</span>(<span class='op'>-</span><span class='number'>2</span>); + <span class='ident'>ev2</span>.<span class='ident'>send</span>(<span class='number'>6</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>((<span class='op'>-</span><span class='number'>2</span>, <span class='number'>6</span>))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>cyclic_snapshot_accum</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>stream</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>(); + <span class='kw'>let</span> <span class='ident'>accum</span> <span class='op'>=</span> <span class='ident'>SignalCycle</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>def</span> <span class='op'>=</span> <span class='ident'>accum</span>.<span class='ident'>snapshot</span>(<span class='kw-2'>&</span><span class='ident'>stream</span>, <span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>s</span><span class='op'>|</span> <span class='ident'>a</span> <span class='op'>+</span> <span class='ident'>s</span>).<span class='ident'>hold</span>(<span class='number'>0</span>); + <span class='kw'>let</span> <span class='ident'>accum</span> <span class='op'>=</span> <span class='ident'>accum</span>.<span class='ident'>define</span>(<span class='ident'>def</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>accum</span>.<span class='ident'>sample</span>(), <span class='number'>0</span>); + <span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='number'>3</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>accum</span>.<span class='ident'>sample</span>(), <span class='number'>3</span>); + <span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='number'>7</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>accum</span>.<span class='ident'>sample</span>(), <span class='number'>10</span>); + <span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='op'>-</span><span class='number'>21</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>accum</span>.<span class='ident'>sample</span>(), <span class='op'>-</span><span class='number'>11</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>snapshot_order_standard</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>signal</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>hold</span>(<span class='number'>0</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>events</span> <span class='op'>=</span> <span class='ident'>signal</span> + .<span class='ident'>snapshot</span>(<span class='kw-2'>&</span><span class='ident'>sink</span>.<span class='ident'>stream</span>(), <span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>b</span><span class='op'>|</span> (<span class='ident'>a</span>, <span class='ident'>b</span>)) + .<span class='ident'>events</span>(); + <span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='number'>1</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>((<span class='number'>0</span>, <span class='number'>1</span>))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>snapshot_lift_order_standard</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>signal</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>hold</span>(<span class='number'>0</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>events</span> <span class='op'>=</span> <span class='ident'>lift1</span>(<span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> <span class='ident'>x</span>, <span class='kw-2'>&</span><span class='ident'>signal</span>) + .<span class='ident'>snapshot</span>(<span class='kw-2'>&</span><span class='ident'>sink</span>.<span class='ident'>stream</span>(), <span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>b</span><span class='op'>|</span> (<span class='ident'>a</span>, <span class='ident'>b</span>)) + .<span class='ident'>events</span>(); + <span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='number'>1</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>((<span class='number'>0</span>, <span class='number'>1</span>))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>snapshot_order_alternative</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='comment'>// Invert the "natural" order of the registry by declaring the stream before</span> + <span class='comment'>// the signal, which are both used by the snapshot.</span> + <span class='kw'>let</span> <span class='ident'>first</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> <span class='ident'>x</span>); + <span class='kw'>let</span> <span class='ident'>signal</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>hold</span>(<span class='number'>0</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>events</span> <span class='op'>=</span> <span class='ident'>signal</span>.<span class='ident'>snapshot</span>(<span class='kw-2'>&</span><span class='ident'>first</span>, <span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>b</span><span class='op'>|</span> (<span class='ident'>a</span>, <span class='ident'>b</span>)).<span class='ident'>events</span>(); + <span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='number'>1</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>((<span class='number'>0</span>, <span class='number'>1</span>))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>cyclic_signal_intermediate</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>stream</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>snap</span> <span class='op'>=</span> <span class='prelude-val'>None</span>; + <span class='kw'>let</span> <span class='ident'>sum</span> <span class='op'>=</span> <span class='ident'>Signal</span>::<span class='ident'>cyclic</span>(<span class='op'>|</span><span class='ident'>a</span><span class='op'>|</span> { + <span class='kw'>let</span> <span class='ident'>my_snap</span> <span class='op'>=</span> <span class='ident'>a</span>.<span class='ident'>snapshot</span>(<span class='kw-2'>&</span><span class='ident'>stream</span>, <span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>e</span><span class='op'>|</span> <span class='ident'>e</span> <span class='op'>+</span> <span class='ident'>a</span>); + <span class='ident'>snap</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>my_snap</span>.<span class='ident'>clone</span>()); + <span class='ident'>my_snap</span>.<span class='ident'>hold</span>(<span class='number'>0</span>) + }); + <span class='kw'>let</span> <span class='ident'>snap</span> <span class='op'>=</span> <span class='ident'>snap</span>.<span class='ident'>unwrap</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>events</span> <span class='op'>=</span> <span class='ident'>snap</span>.<span class='ident'>events</span>(); + + <span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='number'>3</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>sum</span>.<span class='ident'>sample</span>(), <span class='number'>3</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>(<span class='number'>3</span>)); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "carboxyl"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/carboxyl/source.rs.html b/src/carboxyl/source.rs.html new file mode 100644 index 0000000..5aab27b --- /dev/null +++ b/src/carboxyl/source.rs.html @@ -0,0 +1,359 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/carboxyl-0.1.1/src/source.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>source.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +</pre><pre class='rust '> +<span class='doccomment'>//! Event sources and callbacks.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! This is a light-weight implementation of the observer pattern. Subjects are</span> +<span class='doccomment'>//! modelled as the `Source` type and observers as boxed closures.</span> + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>sync</span>::{ <span class='ident'>RwLock</span>, <span class='ident'>Weak</span> }; + +<span class='doccomment'>/// An error that can occur with a weakly referenced callback.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>, <span class='ident'>Clone</span>, <span class='ident'>Copy</span>, <span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>CallbackError</span> { + <span class='ident'>Disappeared</span>, + <span class='ident'>Poisoned</span>, +} + +<span class='doccomment'>/// Shorthand for common callback results.</span> +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>CallbackResult</span><span class='op'><</span><span class='ident'>T</span><span class='op'>=</span>()<span class='op'>></span> <span class='op'>=</span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>T</span>, <span class='ident'>CallbackError</span><span class='op'>></span>; + +<span class='doccomment'>/// A boxed callback.</span> +<span class='kw'>type</span> <span class='ident'>Callback</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>Box</span><span class='op'><</span><span class='ident'>FnMut</span>(<span class='ident'>A</span>) <span class='op'>-></span> <span class='ident'>CallbackResult</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span>; + + +<span class='doccomment'>/// Perform some callback on a weak reference to a mutex and handle errors</span> +<span class='doccomment'>/// gracefully.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>with_weak</span><span class='op'><</span><span class='ident'>T</span>, <span class='ident'>U</span>, <span class='ident'>F</span>: <span class='ident'>FnOnce</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>T</span>) <span class='op'>-></span> <span class='ident'>U</span><span class='op'>></span>(<span class='ident'>weak</span>: <span class='kw-2'>&</span><span class='ident'>Weak</span><span class='op'><</span><span class='ident'>RwLock</span><span class='op'><</span><span class='ident'>T</span><span class='op'>>></span>, <span class='ident'>f</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>CallbackResult</span><span class='op'><</span><span class='ident'>U</span><span class='op'>></span> { + <span class='ident'>weak</span>.<span class='ident'>upgrade</span>() + .<span class='ident'>ok_or</span>(<span class='ident'>CallbackError</span>::<span class='ident'>Disappeared</span>) + .<span class='ident'>and_then</span>(<span class='op'>|</span><span class='ident'>mutex</span><span class='op'>|</span> <span class='ident'>mutex</span>.<span class='ident'>write</span>() + .<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>mut</span> <span class='ident'>t</span><span class='op'>|</span> <span class='ident'>f</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>t</span>)) + .<span class='ident'>map_err</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='ident'>CallbackError</span>::<span class='ident'>Poisoned</span>) + ) +} + + +<span class='doccomment'>/// An event source.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Source</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>callbacks</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Callback</span><span class='op'><</span><span class='ident'>A</span><span class='op'>>></span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> <span class='ident'>Source</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='doccomment'>/// Create a new source.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>() <span class='op'>-></span> <span class='ident'>Source</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>Source</span> { <span class='ident'>callbacks</span>: <span class='macro'>vec</span><span class='macro'>!</span>[] } + } + + <span class='doccomment'>/// Register a callback. The callback will be a mutable closure that takes</span> + <span class='doccomment'>/// an event and must return a result. To unsubscribe from further events,</span> + <span class='doccomment'>/// the callback has to return an error.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>register</span><span class='op'><</span><span class='ident'>F</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>callback</span>: <span class='ident'>F</span>) + <span class='kw'>where</span> <span class='ident'>F</span>: <span class='ident'>FnMut</span>(<span class='ident'>A</span>) <span class='op'>-></span> <span class='ident'>CallbackResult</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span> + { + <span class='self'>self</span>.<span class='ident'>callbacks</span>.<span class='ident'>push</span>(<span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>callback</span>)); + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span> <span class='ident'>Source</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='doccomment'>/// Make the source send an event to all its observers.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>send</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>a</span>: <span class='ident'>A</span>) { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>mem</span>; + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>new_callbacks</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>(); + <span class='ident'>mem</span>::<span class='ident'>swap</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>new_callbacks</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>callbacks</span>); + <span class='self'>self</span>.<span class='ident'>callbacks</span> <span class='op'>=</span> <span class='ident'>new_callbacks</span> + .<span class='ident'>into_iter</span>() + .<span class='ident'>filter_map</span>(<span class='op'>|</span><span class='kw-2'>mut</span> <span class='ident'>callback</span><span class='op'>|</span> { + <span class='kw'>let</span> <span class='ident'>result</span> <span class='op'>=</span> <span class='ident'>callback</span>(<span class='ident'>a</span>.<span class='ident'>clone</span>()); + <span class='kw'>match</span> <span class='ident'>result</span> { + <span class='prelude-val'>Ok</span>(_) <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>callback</span>), + <span class='prelude-val'>Err</span>(_) <span class='op'>=></span> <span class='prelude-val'>None</span>, + } + }) + .<span class='ident'>collect</span>(); + } +} + + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>test</span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>sync</span>::{ <span class='ident'>Arc</span>, <span class='ident'>RwLock</span> }; + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>thread</span>; + <span class='kw'>use</span> <span class='ident'>super</span>::<span class='op'>*</span>; + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>with_weak_no_error</span>() { + <span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>RwLock</span>::<span class='ident'>new</span>(<span class='number'>3</span>)); + <span class='kw'>let</span> <span class='ident'>weak</span> <span class='op'>=</span> <span class='ident'>a</span>.<span class='ident'>downgrade</span>(); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>with_weak</span>(<span class='kw-2'>&</span><span class='ident'>weak</span>, <span class='op'>|</span><span class='ident'>a</span><span class='op'>|</span> { <span class='op'>*</span><span class='ident'>a</span> <span class='op'>=</span> <span class='number'>4</span>; }), <span class='prelude-val'>Ok</span>(())); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='op'>*</span><span class='ident'>a</span>.<span class='ident'>read</span>().<span class='ident'>unwrap</span>(), <span class='number'>4</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>with_weak_disappeared</span>() { + <span class='kw'>let</span> <span class='ident'>weak</span> <span class='op'>=</span> <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>RwLock</span>::<span class='ident'>new</span>(<span class='number'>3</span>)).<span class='ident'>downgrade</span>(); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>with_weak</span>(<span class='kw-2'>&</span><span class='ident'>weak</span>, <span class='op'>|</span>_<span class='op'>|</span> ()), <span class='prelude-val'>Err</span>(<span class='ident'>CallbackError</span>::<span class='ident'>Disappeared</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>with_weak_poisoned</span>() { + <span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>RwLock</span>::<span class='ident'>new</span>(<span class='number'>3</span>)); + <span class='kw'>let</span> <span class='ident'>a2</span> <span class='op'>=</span> <span class='ident'>a</span>.<span class='ident'>clone</span>(); + <span class='kw'>let</span> <span class='ident'>weak</span> <span class='op'>=</span> <span class='ident'>a</span>.<span class='ident'>downgrade</span>(); + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>thread</span>::<span class='ident'>spawn</span>(<span class='kw'>move</span> <span class='op'>||</span> { + <span class='kw'>let</span> <span class='ident'>_g</span> <span class='op'>=</span> <span class='ident'>a2</span>.<span class='ident'>write</span>().<span class='ident'>unwrap</span>(); + <span class='macro'>panic</span><span class='macro'>!</span>(); + }).<span class='ident'>join</span>(); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>with_weak</span>(<span class='kw-2'>&</span><span class='ident'>weak</span>, <span class='op'>|</span>_<span class='op'>|</span> ()), <span class='prelude-val'>Err</span>(<span class='ident'>CallbackError</span>::<span class='ident'>Poisoned</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>source_register_and_send</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>src</span> <span class='op'>=</span> <span class='ident'>Source</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>RwLock</span>::<span class='ident'>new</span>(<span class='number'>3</span>)); + { + <span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>a</span>.<span class='ident'>clone</span>(); + <span class='ident'>src</span>.<span class='ident'>register</span>(<span class='kw'>move</span> <span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> { + <span class='op'>*</span><span class='ident'>a</span>.<span class='ident'>write</span>().<span class='ident'>unwrap</span>() <span class='op'>=</span> <span class='ident'>x</span>; + <span class='prelude-val'>Ok</span>(()) + }); + } + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>src</span>.<span class='ident'>callbacks</span>.<span class='ident'>len</span>(), <span class='number'>1</span>); + <span class='ident'>src</span>.<span class='ident'>send</span>(<span class='number'>4</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='op'>*</span><span class='ident'>a</span>.<span class='ident'>read</span>().<span class='ident'>unwrap</span>(), <span class='number'>4</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>source_unregister</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>src</span> <span class='op'>=</span> <span class='ident'>Source</span>::<span class='ident'>new</span>(); + <span class='ident'>src</span>.<span class='ident'>register</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='prelude-val'>Err</span>(<span class='ident'>CallbackError</span>::<span class='ident'>Disappeared</span>)); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>src</span>.<span class='ident'>callbacks</span>.<span class='ident'>len</span>(), <span class='number'>1</span>); + <span class='ident'>src</span>.<span class='ident'>send</span>(()); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>src</span>.<span class='ident'>callbacks</span>.<span class='ident'>len</span>(), <span class='number'>0</span>); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "carboxyl"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/carboxyl/stream.rs.html b/src/carboxyl/stream.rs.html new file mode 100644 index 0000000..8290275 --- /dev/null +++ b/src/carboxyl/stream.rs.html @@ -0,0 +1,1645 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/carboxyl-0.1.1/src/stream.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>stream.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +<span id="313">313</span> +<span id="314">314</span> +<span id="315">315</span> +<span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +<span id="326">326</span> +<span id="327">327</span> +<span id="328">328</span> +<span id="329">329</span> +<span id="330">330</span> +<span id="331">331</span> +<span id="332">332</span> +<span id="333">333</span> +<span id="334">334</span> +<span id="335">335</span> +<span id="336">336</span> +<span id="337">337</span> +<span id="338">338</span> +<span id="339">339</span> +<span id="340">340</span> +<span id="341">341</span> +<span id="342">342</span> +<span id="343">343</span> +<span id="344">344</span> +<span id="345">345</span> +<span id="346">346</span> +<span id="347">347</span> +<span id="348">348</span> +<span id="349">349</span> +<span id="350">350</span> +<span id="351">351</span> +<span id="352">352</span> +<span id="353">353</span> +<span id="354">354</span> +<span id="355">355</span> +<span id="356">356</span> +<span id="357">357</span> +<span id="358">358</span> +<span id="359">359</span> +<span id="360">360</span> +<span id="361">361</span> +<span id="362">362</span> +<span id="363">363</span> +<span id="364">364</span> +<span id="365">365</span> +<span id="366">366</span> +<span id="367">367</span> +<span id="368">368</span> +<span id="369">369</span> +<span id="370">370</span> +<span id="371">371</span> +<span id="372">372</span> +<span id="373">373</span> +<span id="374">374</span> +<span id="375">375</span> +<span id="376">376</span> +<span id="377">377</span> +<span id="378">378</span> +<span id="379">379</span> +<span id="380">380</span> +<span id="381">381</span> +<span id="382">382</span> +<span id="383">383</span> +<span id="384">384</span> +<span id="385">385</span> +<span id="386">386</span> +<span id="387">387</span> +<span id="388">388</span> +<span id="389">389</span> +<span id="390">390</span> +<span id="391">391</span> +<span id="392">392</span> +<span id="393">393</span> +<span id="394">394</span> +<span id="395">395</span> +<span id="396">396</span> +<span id="397">397</span> +<span id="398">398</span> +<span id="399">399</span> +<span id="400">400</span> +<span id="401">401</span> +<span id="402">402</span> +<span id="403">403</span> +<span id="404">404</span> +<span id="405">405</span> +<span id="406">406</span> +<span id="407">407</span> +<span id="408">408</span> +<span id="409">409</span> +<span id="410">410</span> +<span id="411">411</span> +<span id="412">412</span> +<span id="413">413</span> +<span id="414">414</span> +<span id="415">415</span> +<span id="416">416</span> +<span id="417">417</span> +<span id="418">418</span> +<span id="419">419</span> +<span id="420">420</span> +<span id="421">421</span> +<span id="422">422</span> +<span id="423">423</span> +<span id="424">424</span> +<span id="425">425</span> +<span id="426">426</span> +<span id="427">427</span> +<span id="428">428</span> +<span id="429">429</span> +<span id="430">430</span> +<span id="431">431</span> +<span id="432">432</span> +<span id="433">433</span> +<span id="434">434</span> +<span id="435">435</span> +<span id="436">436</span> +<span id="437">437</span> +<span id="438">438</span> +<span id="439">439</span> +<span id="440">440</span> +<span id="441">441</span> +<span id="442">442</span> +<span id="443">443</span> +<span id="444">444</span> +<span id="445">445</span> +<span id="446">446</span> +<span id="447">447</span> +<span id="448">448</span> +<span id="449">449</span> +<span id="450">450</span> +<span id="451">451</span> +<span id="452">452</span> +<span id="453">453</span> +<span id="454">454</span> +<span id="455">455</span> +<span id="456">456</span> +<span id="457">457</span> +<span id="458">458</span> +<span id="459">459</span> +<span id="460">460</span> +<span id="461">461</span> +<span id="462">462</span> +<span id="463">463</span> +<span id="464">464</span> +<span id="465">465</span> +<span id="466">466</span> +<span id="467">467</span> +<span id="468">468</span> +<span id="469">469</span> +<span id="470">470</span> +<span id="471">471</span> +<span id="472">472</span> +<span id="473">473</span> +<span id="474">474</span> +<span id="475">475</span> +<span id="476">476</span> +<span id="477">477</span> +<span id="478">478</span> +<span id="479">479</span> +<span id="480">480</span> +<span id="481">481</span> +<span id="482">482</span> +<span id="483">483</span> +<span id="484">484</span> +<span id="485">485</span> +<span id="486">486</span> +<span id="487">487</span> +<span id="488">488</span> +<span id="489">489</span> +<span id="490">490</span> +<span id="491">491</span> +<span id="492">492</span> +<span id="493">493</span> +<span id="494">494</span> +<span id="495">495</span> +<span id="496">496</span> +<span id="497">497</span> +<span id="498">498</span> +<span id="499">499</span> +<span id="500">500</span> +<span id="501">501</span> +<span id="502">502</span> +<span id="503">503</span> +<span id="504">504</span> +<span id="505">505</span> +<span id="506">506</span> +<span id="507">507</span> +<span id="508">508</span> +<span id="509">509</span> +<span id="510">510</span> +<span id="511">511</span> +<span id="512">512</span> +<span id="513">513</span> +<span id="514">514</span> +<span id="515">515</span> +<span id="516">516</span> +<span id="517">517</span> +<span id="518">518</span> +<span id="519">519</span> +<span id="520">520</span> +<span id="521">521</span> +<span id="522">522</span> +<span id="523">523</span> +<span id="524">524</span> +<span id="525">525</span> +<span id="526">526</span> +<span id="527">527</span> +<span id="528">528</span> +<span id="529">529</span> +<span id="530">530</span> +<span id="531">531</span> +<span id="532">532</span> +<span id="533">533</span> +<span id="534">534</span> +<span id="535">535</span> +<span id="536">536</span> +<span id="537">537</span> +<span id="538">538</span> +<span id="539">539</span> +<span id="540">540</span> +<span id="541">541</span> +<span id="542">542</span> +<span id="543">543</span> +<span id="544">544</span> +<span id="545">545</span> +<span id="546">546</span> +<span id="547">547</span> +<span id="548">548</span> +<span id="549">549</span> +<span id="550">550</span> +<span id="551">551</span> +<span id="552">552</span> +<span id="553">553</span> +<span id="554">554</span> +<span id="555">555</span> +<span id="556">556</span> +<span id="557">557</span> +<span id="558">558</span> +<span id="559">559</span> +<span id="560">560</span> +<span id="561">561</span> +<span id="562">562</span> +<span id="563">563</span> +<span id="564">564</span> +<span id="565">565</span> +<span id="566">566</span> +<span id="567">567</span> +<span id="568">568</span> +<span id="569">569</span> +<span id="570">570</span> +<span id="571">571</span> +<span id="572">572</span> +<span id="573">573</span> +<span id="574">574</span> +<span id="575">575</span> +<span id="576">576</span> +<span id="577">577</span> +<span id="578">578</span> +<span id="579">579</span> +<span id="580">580</span> +<span id="581">581</span> +<span id="582">582</span> +<span id="583">583</span> +<span id="584">584</span> +<span id="585">585</span> +<span id="586">586</span> +<span id="587">587</span> +<span id="588">588</span> +<span id="589">589</span> +<span id="590">590</span> +<span id="591">591</span> +<span id="592">592</span> +<span id="593">593</span> +<span id="594">594</span> +<span id="595">595</span> +<span id="596">596</span> +<span id="597">597</span> +<span id="598">598</span> +<span id="599">599</span> +<span id="600">600</span> +<span id="601">601</span> +<span id="602">602</span> +<span id="603">603</span> +<span id="604">604</span> +<span id="605">605</span> +<span id="606">606</span> +<span id="607">607</span> +<span id="608">608</span> +<span id="609">609</span> +<span id="610">610</span> +<span id="611">611</span> +<span id="612">612</span> +<span id="613">613</span> +<span id="614">614</span> +<span id="615">615</span> +<span id="616">616</span> +<span id="617">617</span> +<span id="618">618</span> +<span id="619">619</span> +<span id="620">620</span> +<span id="621">621</span> +<span id="622">622</span> +<span id="623">623</span> +<span id="624">624</span> +<span id="625">625</span> +<span id="626">626</span> +<span id="627">627</span> +<span id="628">628</span> +<span id="629">629</span> +<span id="630">630</span> +<span id="631">631</span> +<span id="632">632</span> +<span id="633">633</span> +<span id="634">634</span> +<span id="635">635</span> +<span id="636">636</span> +<span id="637">637</span> +<span id="638">638</span> +<span id="639">639</span> +<span id="640">640</span> +<span id="641">641</span> +<span id="642">642</span> +<span id="643">643</span> +<span id="644">644</span> +<span id="645">645</span> +<span id="646">646</span> +<span id="647">647</span> +<span id="648">648</span> +<span id="649">649</span> +<span id="650">650</span> +<span id="651">651</span> +<span id="652">652</span> +<span id="653">653</span> +<span id="654">654</span> +<span id="655">655</span> +<span id="656">656</span> +<span id="657">657</span> +<span id="658">658</span> +<span id="659">659</span> +<span id="660">660</span> +<span id="661">661</span> +<span id="662">662</span> +<span id="663">663</span> +<span id="664">664</span> +<span id="665">665</span> +<span id="666">666</span> +<span id="667">667</span> +<span id="668">668</span> +<span id="669">669</span> +<span id="670">670</span> +<span id="671">671</span> +<span id="672">672</span> +<span id="673">673</span> +<span id="674">674</span> +<span id="675">675</span> +<span id="676">676</span> +<span id="677">677</span> +<span id="678">678</span> +<span id="679">679</span> +<span id="680">680</span> +<span id="681">681</span> +<span id="682">682</span> +<span id="683">683</span> +<span id="684">684</span> +<span id="685">685</span> +<span id="686">686</span> +<span id="687">687</span> +<span id="688">688</span> +<span id="689">689</span> +<span id="690">690</span> +<span id="691">691</span> +<span id="692">692</span> +<span id="693">693</span> +<span id="694">694</span> +<span id="695">695</span> +<span id="696">696</span> +<span id="697">697</span> +<span id="698">698</span> +<span id="699">699</span> +<span id="700">700</span> +<span id="701">701</span> +<span id="702">702</span> +<span id="703">703</span> +<span id="704">704</span> +<span id="705">705</span> +<span id="706">706</span> +<span id="707">707</span> +<span id="708">708</span> +<span id="709">709</span> +<span id="710">710</span> +<span id="711">711</span> +<span id="712">712</span> +<span id="713">713</span> +<span id="714">714</span> +<span id="715">715</span> +<span id="716">716</span> +<span id="717">717</span> +<span id="718">718</span> +<span id="719">719</span> +<span id="720">720</span> +<span id="721">721</span> +<span id="722">722</span> +<span id="723">723</span> +<span id="724">724</span> +<span id="725">725</span> +<span id="726">726</span> +<span id="727">727</span> +<span id="728">728</span> +<span id="729">729</span> +<span id="730">730</span> +<span id="731">731</span> +<span id="732">732</span> +<span id="733">733</span> +<span id="734">734</span> +<span id="735">735</span> +<span id="736">736</span> +<span id="737">737</span> +<span id="738">738</span> +<span id="739">739</span> +<span id="740">740</span> +<span id="741">741</span> +<span id="742">742</span> +<span id="743">743</span> +<span id="744">744</span> +<span id="745">745</span> +<span id="746">746</span> +<span id="747">747</span> +<span id="748">748</span> +<span id="749">749</span> +<span id="750">750</span> +<span id="751">751</span> +<span id="752">752</span> +<span id="753">753</span> +<span id="754">754</span> +<span id="755">755</span> +<span id="756">756</span> +<span id="757">757</span> +<span id="758">758</span> +<span id="759">759</span> +<span id="760">760</span> +<span id="761">761</span> +<span id="762">762</span> +<span id="763">763</span> +<span id="764">764</span> +<span id="765">765</span> +<span id="766">766</span> +<span id="767">767</span> +<span id="768">768</span> +<span id="769">769</span> +<span id="770">770</span> +<span id="771">771</span> +<span id="772">772</span> +<span id="773">773</span> +<span id="774">774</span> +</pre><pre class='rust '> +<span class='doccomment'>//! Streams of discrete events</span> + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>sync</span>::{ <span class='ident'>Arc</span>, <span class='ident'>RwLock</span>, <span class='ident'>Mutex</span>, <span class='ident'>Weak</span> }; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>sync</span>::<span class='ident'>mpsc</span>::{ <span class='ident'>Receiver</span>, <span class='ident'>channel</span> }; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>thread</span>; +<span class='kw'>use</span> <span class='ident'>source</span>::{ <span class='ident'>Source</span>, <span class='ident'>CallbackError</span>, <span class='ident'>CallbackResult</span>, <span class='ident'>with_weak</span> }; +<span class='kw'>use</span> <span class='ident'>signal</span>::{ <span class='self'>self</span>, <span class='ident'>Signal</span>, <span class='ident'>SignalMut</span>, <span class='ident'>sample_raw</span> }; +<span class='kw'>use</span> <span class='ident'>transaction</span>::{ <span class='ident'>commit</span>, <span class='ident'>later</span> }; + + +<span class='doccomment'>/// An event sink.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This primitive is a way of generating streams of events. One can send</span> +<span class='doccomment'>/// input values into a sink and generate a stream that fires all these inputs</span> +<span class='doccomment'>/// as events:</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ```</span> +<span class='doccomment'>/// # use carboxyl::Sink;</span> +<span class='doccomment'>/// // A new sink</span> +<span class='doccomment'>/// let sink = Sink::new();</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// // Make an iterator over a stream.</span> +<span class='doccomment'>/// let mut events = sink.stream().events();</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// // Send a value into the sink</span> +<span class='doccomment'>/// sink.send(5);</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// // The stream</span> +<span class='doccomment'>/// assert_eq!(events.next(), Some(5));</span> +<span class='doccomment'>/// ```</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// You can also feed a sink with an iterator:</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ```</span> +<span class='doccomment'>/// # use carboxyl::Sink;</span> +<span class='doccomment'>/// # let sink = Sink::new();</span> +<span class='doccomment'>/// # let mut events = sink.stream().events();</span> +<span class='doccomment'>/// sink.feed(20..40);</span> +<span class='doccomment'>/// assert_eq!(events.take(4).collect::<Vec<_>>(), vec![20, 21, 22, 23]);</span> +<span class='doccomment'>/// ```</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Asynchronous calls</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// It is possible to send events into the sink asynchronously using the methods</span> +<span class='doccomment'>/// `send_async` and `feed_async`. Note though, that this will void some</span> +<span class='doccomment'>/// guarantees on the order of events. In the following example, it is unclear,</span> +<span class='doccomment'>/// which event is the first in the stream:</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ```</span> +<span class='doccomment'>/// # use carboxyl::Sink;</span> +<span class='doccomment'>/// let sink = Sink::new();</span> +<span class='doccomment'>/// let mut events = sink.stream().events();</span> +<span class='doccomment'>/// sink.send_async(13);</span> +<span class='doccomment'>/// sink.send_async(22);</span> +<span class='doccomment'>/// let first = events.next().unwrap();</span> +<span class='doccomment'>/// assert!(first == 13 || first == 22);</span> +<span class='doccomment'>/// ```</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// `feed_async` provides a workaround, as it preserves the order of events from</span> +<span class='doccomment'>/// the iterator. However, any event sent into the sink after a call to it, may</span> +<span class='doccomment'>/// come at any point between the iterator events.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Sink</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>source</span>: <span class='ident'>Arc</span><span class='op'><</span><span class='ident'>RwLock</span><span class='op'><</span><span class='ident'>Source</span><span class='op'><</span><span class='ident'>A</span><span class='op'>>></span><span class='op'>></span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> <span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>Sink</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Sink</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>Sink</span> { <span class='ident'>source</span>: <span class='self'>self</span>.<span class='ident'>source</span>.<span class='ident'>clone</span>() } + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span><span class='op'>></span> <span class='ident'>Sink</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='doccomment'>/// Create a new sink.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>() <span class='op'>-></span> <span class='ident'>Sink</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>Sink</span> { <span class='ident'>source</span>: <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>RwLock</span>::<span class='ident'>new</span>(<span class='ident'>Source</span>::<span class='ident'>new</span>())) } + } + + <span class='doccomment'>/// Generate a stream that fires all events sent into the sink.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>stream</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>Stream</span> { <span class='ident'>source</span>: <span class='self'>self</span>.<span class='ident'>source</span>.<span class='ident'>clone</span>(), <span class='ident'>keep_alive</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(()), } + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span> <span class='ident'>Sink</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='doccomment'>/// Asynchronous send.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Same as `send`, but it spawns a new thread to process the updates to</span> + <span class='doccomment'>/// dependent streams and signals.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>send_async</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>a</span>: <span class='ident'>A</span>) { + <span class='kw'>let</span> <span class='ident'>clone</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>clone</span>(); + <span class='ident'>thread</span>::<span class='ident'>spawn</span>(<span class='kw'>move</span> <span class='op'>||</span> <span class='ident'>clone</span>.<span class='ident'>send</span>(<span class='ident'>a</span>)); + } + + <span class='doccomment'>/// Feed values from an iterator into the sink.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This method feeds events into the sink from an iterator.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>feed</span><span class='op'><</span><span class='ident'>I</span>: <span class='ident'>IntoIterator</span><span class='op'><</span><span class='ident'>Item</span><span class='op'>=</span><span class='ident'>A</span><span class='op'>>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>iterator</span>: <span class='ident'>I</span>) { + <span class='kw'>for</span> <span class='ident'>event</span> <span class='kw'>in</span> <span class='ident'>iterator</span> { + <span class='self'>self</span>.<span class='ident'>send</span>(<span class='ident'>event</span>); + } + } + + <span class='doccomment'>/// Asynchronous feed.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This is the same as `feed`, but it does not block, since it spawns the</span> + <span class='doccomment'>/// feeding as a new task. This is useful, if the provided iterator is large</span> + <span class='doccomment'>/// or even infinite (e.g. an I/O event loop).</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>feed_async</span><span class='op'><</span><span class='ident'>I</span>: <span class='ident'>IntoIterator</span><span class='op'><</span><span class='ident'>Item</span><span class='op'>=</span><span class='ident'>A</span><span class='op'>></span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>iterator</span>: <span class='ident'>I</span>) { + <span class='kw'>let</span> <span class='ident'>clone</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>clone</span>(); + <span class='ident'>thread</span>::<span class='ident'>spawn</span>(<span class='kw'>move</span> <span class='op'>||</span> <span class='ident'>clone</span>.<span class='ident'>feed</span>(<span class='ident'>iterator</span>)); + } + + <span class='doccomment'>/// Send a value into the sink.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// When a value is sent into the sink, an event is fired in all dependent</span> + <span class='doccomment'>/// streams.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>send</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>a</span>: <span class='ident'>A</span>) { + <span class='ident'>commit</span>(<span class='op'>||</span> <span class='self'>self</span>.<span class='ident'>source</span>.<span class='ident'>write</span>().<span class='ident'>unwrap</span>().<span class='ident'>send</span>(<span class='ident'>a</span>)) + } +} + + +<span class='doccomment'>/// Trait to wrap cloning of boxed values in a object-safe manner</span> +<span class='kw'>pub</span> <span class='kw'>trait</span> <span class='ident'>BoxClone</span>: <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Send</span> { + <span class='doccomment'>/// Clone the object as a boxed trait object</span> + <span class='kw'>fn</span> <span class='ident'>box_clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Box</span><span class='op'><</span><span class='ident'>BoxClone</span><span class='op'>></span>; +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span> <span class='ident'>BoxClone</span> <span class='kw'>for</span> <span class='ident'>T</span> { + <span class='kw'>fn</span> <span class='ident'>box_clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Box</span><span class='op'><</span><span class='ident'>BoxClone</span><span class='op'>></span> { + <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='self'>self</span>.<span class='ident'>clone</span>()) + } +} + + +<span class='doccomment'>/// Access a stream's source.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This is not defined as a method, so that it can be public to other modules</span> +<span class='doccomment'>/// in this crate while being private outside the crate.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>source</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>(<span class='ident'>stream</span>: <span class='kw-2'>&</span><span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>Arc</span><span class='op'><</span><span class='ident'>RwLock</span><span class='op'><</span><span class='ident'>Source</span><span class='op'><</span><span class='ident'>A</span><span class='op'>>></span><span class='op'>></span> { + <span class='kw-2'>&</span><span class='ident'>stream</span>.<span class='ident'>source</span> +} + + +<span class='doccomment'>/// A stream of events.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Conceptually a stream can be thought of as a series of discrete events that</span> +<span class='doccomment'>/// occur at specific times. They are ordered by a transaction system. This</span> +<span class='doccomment'>/// means that firings of disjoint events can not interfere with each other. The</span> +<span class='doccomment'>/// consequences of one event are atomically reflected in dependent quantities.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Streams provide a number of primitive operations. These can be used to</span> +<span class='doccomment'>/// compose streams and combine them with signals. For instance, streams can be</span> +<span class='doccomment'>/// mapped over with a function, merged with another stream of the same type or</span> +<span class='doccomment'>/// filtered by some predicate.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Algebraic laws</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Furthermore, streams satisfy certain algebraic properties that are useful to</span> +<span class='doccomment'>/// reason about them.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ## Monoid</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// For once, streams of the same type form a **monoid** under merging. The</span> +<span class='doccomment'>/// neutral element in this context is `Stream::never()`. So the following laws</span> +<span class='doccomment'>/// always hold for streams `a`, `b` and `c` of the same type:</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// - Left identity: `Stream::never().merge(&a) == a`,</span> +<span class='doccomment'>/// - Right identity: `a.merge(&Stream::never()) == a`,</span> +<span class='doccomment'>/// - Associativity: `a.merge(&b).merge(&c) == a.merge(&b.merge(&c))`.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// *Note that equality in this context is not actually implemented as such,</span> +<span class='doccomment'>/// since comparing two (potentially infinite) streams is a prohibitive</span> +<span class='doccomment'>/// operation. Instead, the expressions above can be used interchangably and</span> +<span class='doccomment'>/// behave identically.*</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ## Functor</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Under the mapping operation streams also become a functor. A functor is a</span> +<span class='doccomment'>/// generic type like `Stream` with some mapping operation that takes a function</span> +<span class='doccomment'>/// `Fn(A) -> B` to map a `Stream<A>` to a `Stream<B>`. Algebraically it</span> +<span class='doccomment'>/// satisfies the following laws:</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// - The identity function is preserved: `a.map(|x| x) == a`,</span> +<span class='doccomment'>/// - Function composition is respected: `a.map(f).map(g) == a.map(|x| g(f(x)))`.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>source</span>: <span class='ident'>Arc</span><span class='op'><</span><span class='ident'>RwLock</span><span class='op'><</span><span class='ident'>Source</span><span class='op'><</span><span class='ident'>A</span><span class='op'>>></span><span class='op'>></span>, + <span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>dead_code</span>)]</span> + <span class='ident'>keep_alive</span>: <span class='ident'>Box</span><span class='op'><</span><span class='ident'>BoxClone</span><span class='op'>></span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> <span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>Stream</span> { + <span class='ident'>source</span>: <span class='self'>self</span>.<span class='ident'>source</span>.<span class='ident'>clone</span>(), + <span class='ident'>keep_alive</span>: <span class='self'>self</span>.<span class='ident'>keep_alive</span>.<span class='ident'>box_clone</span>(), + } + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='doccomment'>/// Create a stream that never fires. This can be useful in certain</span> + <span class='doccomment'>/// situations, where a stream is logically required, but no events are</span> + <span class='doccomment'>/// expected.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>never</span>() <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>Stream</span> { + <span class='ident'>source</span>: <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>RwLock</span>::<span class='ident'>new</span>(<span class='ident'>Source</span>::<span class='ident'>new</span>())), + <span class='ident'>keep_alive</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(()) + } + } + + <span class='doccomment'>/// Map the stream to another stream using a function.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// `map` applies a function to every event fired in this stream to create a</span> + <span class='doccomment'>/// new stream of type `B`.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>/// # use carboxyl::Sink;</span> + <span class='doccomment'>/// let sink: Sink<i32> = Sink::new();</span> + <span class='doccomment'>/// let mut events = sink.stream().map(|x| x + 4).events();</span> + <span class='doccomment'>/// sink.send(3);</span> + <span class='doccomment'>/// assert_eq!(events.next(), Some(7));</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>map</span><span class='op'><</span><span class='ident'>B</span>, <span class='ident'>F</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>B</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='ident'>A</span>) <span class='op'>-></span> <span class='ident'>B</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + { + <span class='ident'>commit</span>(<span class='op'>||</span> { + <span class='kw'>let</span> <span class='ident'>src</span> <span class='op'>=</span> <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>RwLock</span>::<span class='ident'>new</span>(<span class='ident'>Source</span>::<span class='ident'>new</span>())); + <span class='kw'>let</span> <span class='ident'>weak</span> <span class='op'>=</span> <span class='ident'>src</span>.<span class='ident'>downgrade</span>(); + <span class='self'>self</span>.<span class='ident'>source</span>.<span class='ident'>write</span>().<span class='ident'>unwrap</span>() + .<span class='ident'>register</span>(<span class='kw'>move</span> <span class='op'>|</span><span class='ident'>a</span><span class='op'>|</span> <span class='ident'>with_weak</span>(<span class='kw-2'>&</span><span class='ident'>weak</span>, <span class='op'>|</span><span class='ident'>src</span><span class='op'>|</span> <span class='ident'>src</span>.<span class='ident'>send</span>(<span class='ident'>f</span>(<span class='ident'>a</span>)))); + <span class='ident'>Stream</span> { + <span class='ident'>source</span>: <span class='ident'>src</span>, + <span class='ident'>keep_alive</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='self'>self</span>.<span class='ident'>clone</span>()), + } + }) + } + + <span class='doccomment'>/// Filter a stream according to a predicate.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// `filter` creates a new stream that only fires those events from the</span> + <span class='doccomment'>/// original stream that satisfy the predicate.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>/// # use carboxyl::Sink;</span> + <span class='doccomment'>/// let sink: Sink<i32> = Sink::new();</span> + <span class='doccomment'>/// let mut events = sink.stream()</span> + <span class='doccomment'>/// .filter(|&x| (x >= 4) && (x <= 10))</span> + <span class='doccomment'>/// .events();</span> + <span class='doccomment'>/// sink.send(2); // won't arrive</span> + <span class='doccomment'>/// sink.send(5); // will arrive</span> + <span class='doccomment'>/// assert_eq!(events.next(), Some(5));</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>filter</span><span class='op'><</span><span class='ident'>F</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='kw-2'>&</span><span class='ident'>A</span>) <span class='op'>-></span> <span class='ident'>bool</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + { + <span class='self'>self</span>.<span class='ident'>filter_map</span>(<span class='kw'>move</span> <span class='op'>|</span><span class='ident'>a</span><span class='op'>|</span> <span class='kw'>if</span> <span class='ident'>f</span>(<span class='kw-2'>&</span><span class='ident'>a</span>) { <span class='prelude-val'>Some</span>(<span class='ident'>a</span>) } <span class='kw'>else</span> { <span class='prelude-val'>None</span> }) + } + + <span class='doccomment'>/// Both filter and map a stream.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This is equivalent to `.map(f).filter_some()`.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>/// # use carboxyl::Sink;</span> + <span class='doccomment'>/// let sink = Sink::new();</span> + <span class='doccomment'>/// let mut events = sink.stream()</span> + <span class='doccomment'>/// .filter_map(|i| if i > 3 { Some(i + 2) } else { None })</span> + <span class='doccomment'>/// .events();</span> + <span class='doccomment'>/// sink.send(2);</span> + <span class='doccomment'>/// sink.send(4);</span> + <span class='doccomment'>/// assert_eq!(events.next(), Some(6));</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>filter_map</span><span class='op'><</span><span class='ident'>B</span>, <span class='ident'>F</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>B</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='ident'>A</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + { + <span class='self'>self</span>.<span class='ident'>map</span>(<span class='ident'>f</span>).<span class='ident'>filter_some</span>() + } + + <span class='doccomment'>/// Merge with another stream.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// `merge` takes two streams and creates a new stream that fires events</span> + <span class='doccomment'>/// from both input streams.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>/// # use carboxyl::Sink;</span> + <span class='doccomment'>/// let sink_1 = Sink::<i32>::new();</span> + <span class='doccomment'>/// let sink_2 = Sink::<i32>::new();</span> + <span class='doccomment'>/// let mut events = sink_1.stream().merge(&sink_2.stream()).events();</span> + <span class='doccomment'>/// sink_1.send(2);</span> + <span class='doccomment'>/// assert_eq!(events.next(), Some(2));</span> + <span class='doccomment'>/// sink_2.send(4);</span> + <span class='doccomment'>/// assert_eq!(events.next(), Some(4));</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>merge</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>commit</span>(<span class='op'>||</span> { + <span class='kw'>let</span> <span class='ident'>src</span> <span class='op'>=</span> <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>RwLock</span>::<span class='ident'>new</span>(<span class='ident'>Source</span>::<span class='ident'>new</span>())); + <span class='kw'>for</span> <span class='ident'>parent</span> <span class='kw'>in</span> [<span class='self'>self</span>, <span class='ident'>other</span>].<span class='ident'>iter</span>() { + <span class='kw'>let</span> <span class='ident'>weak</span> <span class='op'>=</span> <span class='ident'>src</span>.<span class='ident'>downgrade</span>(); + <span class='ident'>parent</span>.<span class='ident'>source</span>.<span class='ident'>write</span>().<span class='ident'>unwrap</span>() + .<span class='ident'>register</span>(<span class='kw'>move</span> <span class='op'>|</span><span class='ident'>a</span><span class='op'>|</span> <span class='ident'>with_weak</span>(<span class='kw-2'>&</span><span class='ident'>weak</span>, <span class='op'>|</span><span class='ident'>src</span><span class='op'>|</span> <span class='ident'>src</span>.<span class='ident'>send</span>(<span class='ident'>a</span>))); + } + <span class='ident'>Stream</span> { + <span class='ident'>source</span>: <span class='ident'>src</span>, + <span class='ident'>keep_alive</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>((<span class='self'>self</span>.<span class='ident'>clone</span>(), <span class='ident'>other</span>.<span class='ident'>clone</span>())), + } + }) + } + + <span class='doccomment'>/// Coalesce multiple event firings within the same transaction into a</span> + <span class='doccomment'>/// single event.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The function should ideally commute, as the order of events within a</span> + <span class='doccomment'>/// transaction is not well-defined.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>coalesce</span><span class='op'><</span><span class='ident'>F</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='ident'>A</span>, <span class='ident'>A</span>) <span class='op'>-></span> <span class='ident'>A</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + { + <span class='ident'>commit</span>(<span class='op'>||</span> { + <span class='kw'>let</span> <span class='ident'>src</span> <span class='op'>=</span> <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>RwLock</span>::<span class='ident'>new</span>(<span class='ident'>Source</span>::<span class='ident'>new</span>())); + <span class='kw'>let</span> <span class='ident'>weak</span> <span class='op'>=</span> <span class='ident'>src</span>.<span class='ident'>downgrade</span>(); + <span class='self'>self</span>.<span class='ident'>source</span>.<span class='ident'>write</span>().<span class='ident'>unwrap</span>().<span class='ident'>register</span>({ + <span class='kw'>let</span> <span class='ident'>mutex</span> <span class='op'>=</span> <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>Mutex</span>::<span class='ident'>new</span>(<span class='prelude-val'>None</span>)); + <span class='kw'>move</span> <span class='op'>|</span><span class='ident'>a</span><span class='op'>|</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>inner</span> <span class='op'>=</span> <span class='ident'>mutex</span>.<span class='ident'>lock</span>().<span class='ident'>unwrap</span>(); + <span class='op'>*</span><span class='ident'>inner</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='kw'>match</span> <span class='ident'>inner</span>.<span class='ident'>take</span>() { + <span class='prelude-val'>Some</span>(<span class='ident'>b</span>) <span class='op'>=></span> <span class='ident'>f</span>(<span class='ident'>a</span>, <span class='ident'>b</span>), + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='ident'>a</span>, + }); + <span class='comment'>// Send the updated value later</span> + <span class='ident'>later</span>({ + <span class='kw'>let</span> <span class='ident'>mutex</span> <span class='op'>=</span> <span class='ident'>mutex</span>.<span class='ident'>clone</span>(); + <span class='kw'>let</span> <span class='ident'>weak</span> <span class='op'>=</span> <span class='ident'>weak</span>.<span class='ident'>clone</span>(); + <span class='kw'>move</span> <span class='op'>||</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>inner</span> <span class='op'>=</span> <span class='ident'>mutex</span>.<span class='ident'>lock</span>().<span class='ident'>unwrap</span>(); + <span class='comment'>// Take it out and map, so that it does not happen twice</span> + <span class='ident'>inner</span>.<span class='ident'>take</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>value</span><span class='op'>|</span> + <span class='ident'>with_weak</span>(<span class='kw-2'>&</span><span class='ident'>weak</span>, <span class='op'>|</span><span class='ident'>src</span><span class='op'>|</span> <span class='ident'>src</span>.<span class='ident'>send</span>(<span class='ident'>value</span>)) + ); + } + }); + <span class='prelude-val'>Ok</span>(()) + } + }); + <span class='ident'>Stream</span> { <span class='ident'>source</span>: <span class='ident'>src</span>, <span class='ident'>keep_alive</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='self'>self</span>.<span class='ident'>clone</span>()) } + }) + } + + <span class='doccomment'>/// Hold an event in a signal.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The resulting signal `hold`s the value of the last event fired by the</span> + <span class='doccomment'>/// stream.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>/// # use carboxyl::Sink;</span> + <span class='doccomment'>/// let sink = Sink::new();</span> + <span class='doccomment'>/// let signal = sink.stream().hold(0);</span> + <span class='doccomment'>/// assert_eq!(signal.sample(), 0);</span> + <span class='doccomment'>/// sink.send(2);</span> + <span class='doccomment'>/// assert_eq!(signal.sample(), 2);</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>hold</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>initial</span>: <span class='ident'>A</span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>signal</span>::<span class='ident'>hold</span>(<span class='ident'>initial</span>, <span class='self'>self</span>) + } + + <span class='doccomment'>/// A blocking iterator over the stream.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>events</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Events</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { <span class='ident'>Events</span>::<span class='ident'>new</span>(<span class='self'>self</span>) } + + <span class='doccomment'>/// Scan a stream and accumulate its event firings in a signal.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Starting at some initial value, each new event changes the value of the</span> + <span class='doccomment'>/// resulting signal as prescribed by the supplied function.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>/// # use carboxyl::Sink;</span> + <span class='doccomment'>/// let sink = Sink::new();</span> + <span class='doccomment'>/// let sum = sink.stream().scan(0, |a, b| a + b);</span> + <span class='doccomment'>/// assert_eq!(sum.sample(), 0);</span> + <span class='doccomment'>/// sink.send(2);</span> + <span class='doccomment'>/// assert_eq!(sum.sample(), 2);</span> + <span class='doccomment'>/// sink.send(4);</span> + <span class='doccomment'>/// assert_eq!(sum.sample(), 6);</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>scan</span><span class='op'><</span><span class='ident'>B</span>, <span class='ident'>F</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>initial</span>: <span class='ident'>B</span>, <span class='ident'>f</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>Signal</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>B</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='ident'>B</span>, <span class='ident'>A</span>) <span class='op'>-></span> <span class='ident'>B</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + { + <span class='ident'>Signal</span>::<span class='ident'>cyclic</span>(<span class='op'>|</span><span class='ident'>scan</span><span class='op'>|</span> <span class='ident'>scan</span>.<span class='ident'>snapshot</span>(<span class='self'>self</span>, <span class='ident'>f</span>).<span class='ident'>hold</span>(<span class='ident'>initial</span>)) + } + + <span class='doccomment'>/// Scan a stream and accumulate its event firings in some mutable state.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Semantically this is equivalent to `scan`. However, it allows one to use</span> + <span class='doccomment'>/// a non-Clone type as an accumulator and update it with efficient in-place</span> + <span class='doccomment'>/// operations.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The resulting `SignalMut` does have a slightly different API from a</span> + <span class='doccomment'>/// regular `Signal` as it does not allow clones.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// # Example</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>/// # use carboxyl::{ Sink, Signal };</span> + <span class='doccomment'>/// let sink: Sink<i32> = Sink::new();</span> + <span class='doccomment'>/// let sum = sink.stream()</span> + <span class='doccomment'>/// .scan_mut(0, |sum, a| *sum += a)</span> + <span class='doccomment'>/// .combine(&Signal::new(()), |sum, ()| *sum);</span> + <span class='doccomment'>/// assert_eq!(sum.sample(), 0);</span> + <span class='doccomment'>/// sink.send(2);</span> + <span class='doccomment'>/// assert_eq!(sum.sample(), 2);</span> + <span class='doccomment'>/// sink.send(4);</span> + <span class='doccomment'>/// assert_eq!(sum.sample(), 6);</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>scan_mut</span><span class='op'><</span><span class='ident'>B</span>, <span class='ident'>F</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>initial</span>: <span class='ident'>B</span>, <span class='ident'>f</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>SignalMut</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>B</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>B</span>, <span class='ident'>A</span>) <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + { + <span class='ident'>signal</span>::<span class='ident'>scan_mut</span>(<span class='self'>self</span>, <span class='ident'>initial</span>, <span class='ident'>f</span>) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span> <span class='ident'>Stream</span><span class='op'><</span><span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>A</span><span class='op'>>></span> { + <span class='doccomment'>/// Filter a stream of options.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// `filter_some` creates a new stream that only fires the unwrapped</span> + <span class='doccomment'>/// `Some(…)` events from the original stream omitting any `None` events.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>/// # use carboxyl::Sink;</span> + <span class='doccomment'>/// let sink = Sink::new();</span> + <span class='doccomment'>/// let mut events = sink.stream().filter_some().events();</span> + <span class='doccomment'>/// sink.send(None); // won't arrive</span> + <span class='doccomment'>/// sink.send(Some(5)); // will arrive</span> + <span class='doccomment'>/// assert_eq!(events.next(), Some(5));</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>filter_some</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>commit</span>(<span class='op'>||</span> { + <span class='kw'>let</span> <span class='ident'>src</span> <span class='op'>=</span> <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>RwLock</span>::<span class='ident'>new</span>(<span class='ident'>Source</span>::<span class='ident'>new</span>())); + <span class='kw'>let</span> <span class='ident'>weak</span> <span class='op'>=</span> <span class='ident'>src</span>.<span class='ident'>downgrade</span>(); + <span class='self'>self</span>.<span class='ident'>source</span>.<span class='ident'>write</span>().<span class='ident'>unwrap</span>() + .<span class='ident'>register</span>(<span class='kw'>move</span> <span class='op'>|</span><span class='ident'>a</span><span class='op'>|</span> <span class='ident'>a</span>.<span class='ident'>map_or</span>( + <span class='prelude-val'>Ok</span>(()), + <span class='op'>|</span><span class='ident'>a</span><span class='op'>|</span> <span class='ident'>with_weak</span>(<span class='kw-2'>&</span><span class='ident'>weak</span>, <span class='op'>|</span><span class='ident'>src</span><span class='op'>|</span> <span class='ident'>src</span>.<span class='ident'>send</span>(<span class='ident'>a</span>)) + )); + <span class='ident'>Stream</span> { + <span class='ident'>source</span>: <span class='ident'>src</span>, + <span class='ident'>keep_alive</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='self'>self</span>.<span class='ident'>clone</span>()) + } + }) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>>></span> { + <span class='doccomment'>/// Switch between streams.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This takes a stream of streams and maps it to a new stream, which fires</span> + <span class='doccomment'>/// all events from the most recent stream fired into it.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// # Example</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>/// # use carboxyl::{ Sink, Stream };</span> + <span class='doccomment'>/// // Create sinks</span> + <span class='doccomment'>/// let stream_sink: Sink<Stream<i32>> = Sink::new();</span> + <span class='doccomment'>/// let sink1: Sink<i32> = Sink::new();</span> + <span class='doccomment'>/// let sink2: Sink<i32> = Sink::new();</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// // Switch and listen</span> + <span class='doccomment'>/// let switched = stream_sink.stream().switch();</span> + <span class='doccomment'>/// let mut events = switched.events();</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// // Should not receive events from either sink</span> + <span class='doccomment'>/// sink1.send(1); sink2.send(2);</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// // Now switch to sink 2</span> + <span class='doccomment'>/// stream_sink.send(sink2.stream());</span> + <span class='doccomment'>/// sink1.send(3); sink2.send(4);</span> + <span class='doccomment'>/// assert_eq!(events.next(), Some(4));</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// // And then to sink 1</span> + <span class='doccomment'>/// stream_sink.send(sink1.stream());</span> + <span class='doccomment'>/// sink1.send(5); sink2.send(6);</span> + <span class='doccomment'>/// assert_eq!(events.next(), Some(5));</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>switch</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>rewire_callbacks</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>(<span class='ident'>new_stream</span>: <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>, <span class='ident'>source</span>: <span class='ident'>Weak</span><span class='op'><</span><span class='ident'>RwLock</span><span class='op'><</span><span class='ident'>Source</span><span class='op'><</span><span class='ident'>A</span><span class='op'>>></span><span class='op'>></span>, + <span class='ident'>terminate</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Arc</span><span class='op'><</span>()<span class='op'>></span>) + <span class='op'>-></span> <span class='ident'>CallbackResult</span> + <span class='kw'>where</span> <span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='ident'>Clone</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + { + <span class='op'>*</span><span class='ident'>terminate</span> <span class='op'>=</span> <span class='ident'>Arc</span>::<span class='ident'>new</span>(()); + <span class='kw'>let</span> <span class='ident'>weak</span> <span class='op'>=</span> <span class='ident'>terminate</span>.<span class='ident'>downgrade</span>(); + <span class='ident'>new_stream</span>.<span class='ident'>source</span>.<span class='ident'>write</span>().<span class='ident'>unwrap</span>().<span class='ident'>register</span>(<span class='kw'>move</span> <span class='op'>|</span><span class='ident'>a</span><span class='op'>|</span> + <span class='ident'>weak</span>.<span class='ident'>upgrade</span>() + .<span class='ident'>ok_or</span>(<span class='ident'>CallbackError</span>::<span class='ident'>Disappeared</span>) + .<span class='ident'>and_then</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='ident'>with_weak</span>(<span class='kw-2'>&</span><span class='ident'>source</span>, <span class='op'>|</span><span class='ident'>src</span><span class='op'>|</span> <span class='ident'>src</span>.<span class='ident'>send</span>(<span class='ident'>a</span>))) + ); + <span class='prelude-val'>Ok</span>(()) + } + <span class='ident'>commit</span>(<span class='op'>||</span> { + <span class='kw'>let</span> <span class='ident'>src</span> <span class='op'>=</span> <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>RwLock</span>::<span class='ident'>new</span>(<span class='ident'>Source</span>::<span class='ident'>new</span>())); + <span class='kw'>let</span> <span class='ident'>weak</span> <span class='op'>=</span> <span class='ident'>src</span>.<span class='ident'>downgrade</span>(); + <span class='self'>self</span>.<span class='ident'>source</span>.<span class='ident'>write</span>().<span class='ident'>unwrap</span>().<span class='ident'>register</span>({ + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>terminate</span> <span class='op'>=</span> <span class='ident'>Arc</span>::<span class='ident'>new</span>(()); + <span class='kw'>move</span> <span class='op'>|</span><span class='ident'>stream</span><span class='op'>|</span> <span class='ident'>rewire_callbacks</span>(<span class='ident'>stream</span>, <span class='ident'>weak</span>.<span class='ident'>clone</span>(), <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>terminate</span>) + }); + <span class='ident'>Stream</span> { + <span class='ident'>source</span>: <span class='ident'>src</span>, + <span class='ident'>keep_alive</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='self'>self</span>.<span class='ident'>clone</span>()), + } + }) + } +} + + +<span class='doccomment'>/// Make a snapshot of a signal, whenever a stream fires an event.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>snapshot</span><span class='op'><</span><span class='ident'>A</span>, <span class='ident'>B</span>, <span class='ident'>C</span>, <span class='ident'>F</span><span class='op'>></span>(<span class='ident'>signal</span>: <span class='kw-2'>&</span><span class='ident'>Signal</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>, <span class='ident'>stream</span>: <span class='kw-2'>&</span><span class='ident'>Stream</span><span class='op'><</span><span class='ident'>B</span><span class='op'>></span>, <span class='ident'>f</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>C</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>A</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>B</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>C</span>: <span class='ident'>Clone</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, + <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='ident'>A</span>, <span class='ident'>B</span>) <span class='op'>-></span> <span class='ident'>C</span> <span class='op'>+</span> <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span>, +{ + <span class='ident'>commit</span>(<span class='op'>||</span> { + <span class='kw'>let</span> <span class='ident'>src</span> <span class='op'>=</span> <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>RwLock</span>::<span class='ident'>new</span>(<span class='ident'>Source</span>::<span class='ident'>new</span>())); + <span class='kw'>let</span> <span class='ident'>weak</span> <span class='op'>=</span> <span class='ident'>src</span>.<span class='ident'>downgrade</span>(); + <span class='ident'>stream</span>.<span class='ident'>source</span>.<span class='ident'>write</span>().<span class='ident'>unwrap</span>().<span class='ident'>register</span>({ + <span class='kw'>let</span> <span class='ident'>signal</span> <span class='op'>=</span> <span class='ident'>signal</span>.<span class='ident'>clone</span>(); + <span class='kw'>move</span> <span class='op'>|</span><span class='ident'>b</span><span class='op'>|</span> <span class='ident'>with_weak</span>(<span class='kw-2'>&</span><span class='ident'>weak</span>, <span class='op'>|</span><span class='ident'>src</span><span class='op'>|</span> <span class='ident'>src</span>.<span class='ident'>send</span>(<span class='ident'>f</span>(<span class='ident'>sample_raw</span>(<span class='kw-2'>&</span><span class='ident'>signal</span>), <span class='ident'>b</span>))) + }); + <span class='ident'>Stream</span> { + <span class='ident'>source</span>: <span class='ident'>src</span>, + <span class='ident'>keep_alive</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>((<span class='ident'>stream</span>.<span class='ident'>clone</span>(), <span class='ident'>signal</span>.<span class='ident'>clone</span>())), + } + }) +} + + +<span class='doccomment'>/// A blocking iterator over events in a stream.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Events</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>receiver</span>: <span class='ident'>Receiver</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>, + <span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>dead_code</span>)]</span> + <span class='ident'>keep_alive</span>: <span class='ident'>Box</span><span class='op'><</span><span class='ident'>BoxClone</span><span class='op'>></span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span> <span class='ident'>Events</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='doccomment'>/// Create a new events iterator.</span> + <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>stream</span>: <span class='kw-2'>&</span><span class='ident'>Stream</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>Events</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>commit</span>(<span class='op'>||</span> { + <span class='kw'>let</span> (<span class='ident'>tx</span>, <span class='ident'>rx</span>) <span class='op'>=</span> <span class='ident'>channel</span>(); + <span class='kw'>let</span> <span class='ident'>tx</span> <span class='op'>=</span> <span class='ident'>Mutex</span>::<span class='ident'>new</span>(<span class='ident'>tx</span>); + <span class='ident'>stream</span>.<span class='ident'>source</span>.<span class='ident'>write</span>().<span class='ident'>unwrap</span>().<span class='ident'>register</span>( + <span class='kw'>move</span> <span class='op'>|</span><span class='ident'>a</span><span class='op'>|</span> <span class='ident'>tx</span>.<span class='ident'>lock</span>().<span class='ident'>unwrap</span>().<span class='ident'>send</span>(<span class='ident'>a</span>).<span class='ident'>map_err</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='ident'>CallbackError</span>::<span class='ident'>Disappeared</span>) + ); + <span class='ident'>Events</span> { + <span class='ident'>receiver</span>: <span class='ident'>rx</span>, + <span class='ident'>keep_alive</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>stream</span>.<span class='ident'>clone</span>()), + } + }) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Send</span> <span class='op'>+</span> <span class='ident'>Sync</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span> <span class='ident'>Iterator</span> <span class='kw'>for</span> <span class='ident'>Events</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Item</span> <span class='op'>=</span> <span class='ident'>A</span>; + <span class='kw'>fn</span> <span class='ident'>next</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { <span class='self'>self</span>.<span class='ident'>receiver</span>.<span class='ident'>recv</span>().<span class='ident'>ok</span>() } +} + + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>test</span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>thread</span>; + <span class='kw'>use</span> <span class='ident'>quickcheck</span>::<span class='ident'>quickcheck</span>; + + <span class='kw'>use</span> <span class='ident'>testing</span>::{ <span class='ident'>id</span>, <span class='ident'>stream_eq</span> }; + <span class='kw'>use</span> <span class='ident'>super</span>::<span class='op'>*</span>; + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>sink</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>events</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>events</span>(); + <span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='number'>1</span>); + <span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='number'>2</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>(<span class='number'>1</span>)); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>(<span class='number'>2</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>map</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>triple</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> <span class='number'>3</span> <span class='op'>*</span> <span class='ident'>x</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>events</span> <span class='op'>=</span> <span class='ident'>triple</span>.<span class='ident'>events</span>(); + <span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='number'>1</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>(<span class='number'>3</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>filter_some</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>small</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>filter_some</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>events</span> <span class='op'>=</span> <span class='ident'>small</span>.<span class='ident'>events</span>(); + <span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='prelude-val'>None</span>); + <span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='prelude-val'>Some</span>(<span class='number'>9</span>)); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>(<span class='number'>9</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>chain_1</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span>: <span class='ident'>Sink</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>chain</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>() + .<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> <span class='ident'>x</span> <span class='op'>/</span> <span class='number'>2</span>) + .<span class='ident'>filter</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>x</span><span class='op'>|</span> <span class='ident'>x</span> <span class='op'><</span> <span class='number'>3</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>events</span> <span class='op'>=</span> <span class='ident'>chain</span>.<span class='ident'>events</span>(); + <span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='number'>7</span>); + <span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='number'>4</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>(<span class='number'>2</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>merge</span>() { + <span class='kw'>let</span> <span class='ident'>sink1</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>sink2</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>events</span> <span class='op'>=</span> <span class='ident'>sink1</span>.<span class='ident'>stream</span>().<span class='ident'>merge</span>(<span class='kw-2'>&</span><span class='ident'>sink2</span>.<span class='ident'>stream</span>()).<span class='ident'>events</span>(); + <span class='ident'>sink1</span>.<span class='ident'>send</span>(<span class='number'>12</span>); + <span class='ident'>sink2</span>.<span class='ident'>send</span>(<span class='number'>9</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>(<span class='number'>12</span>)); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>(<span class='number'>9</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>chain_2</span>() { + <span class='kw'>let</span> <span class='ident'>sink1</span>: <span class='ident'>Sink</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>sink2</span>: <span class='ident'>Sink</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>events</span> <span class='op'>=</span> <span class='ident'>sink1</span>.<span class='ident'>stream</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> <span class='ident'>x</span> <span class='op'>+</span> <span class='number'>4</span>) + .<span class='ident'>merge</span>( + <span class='kw-2'>&</span><span class='ident'>sink2</span>.<span class='ident'>stream</span>() + .<span class='ident'>filter_map</span>(<span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> <span class='kw'>if</span> <span class='ident'>x</span> <span class='op'><</span> <span class='number'>4</span> { <span class='prelude-val'>Some</span>(<span class='ident'>x</span>) } <span class='kw'>else</span> { <span class='prelude-val'>None</span> }) + .<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> <span class='ident'>x</span> <span class='op'>*</span> <span class='number'>5</span>)) + .<span class='ident'>events</span>(); + <span class='ident'>sink1</span>.<span class='ident'>send</span>(<span class='number'>12</span>); + <span class='ident'>sink2</span>.<span class='ident'>send</span>(<span class='number'>3</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>(<span class='number'>16</span>)); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>(<span class='number'>15</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>move_closure</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>x</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>map</span>(<span class='kw'>move</span> <span class='op'>|</span><span class='ident'>y</span><span class='op'>|</span> <span class='ident'>y</span> <span class='op'>+</span> <span class='ident'>x</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>scan_race_condition</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='comment'>// Feed the sink in the background</span> + <span class='ident'>sink</span>.<span class='ident'>feed_async</span>(<span class='number'>0</span>..<span class='number'>100000</span>); + <span class='comment'>// Try it multiple times to increase failure probability, when a data</span> + <span class='comment'>// race can potentially happen.</span> + <span class='kw'>for</span> _ <span class='kw'>in</span> <span class='number'>0</span>..<span class='number'>10</span> { + <span class='kw'>let</span> <span class='ident'>_sum</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>scan</span>(<span class='number'>0</span>, <span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>b</span><span class='op'>|</span> <span class='ident'>a</span> <span class='op'>+</span> <span class='ident'>b</span>); + } + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>sink_send_async</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>events</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>events</span>(); + <span class='ident'>sink</span>.<span class='ident'>send_async</span>(<span class='number'>1</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>(<span class='number'>1</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>sink_feed</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>events</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>events</span>(); + <span class='ident'>sink</span>.<span class='ident'>feed</span>(<span class='number'>0</span>..<span class='number'>10</span>); + <span class='kw'>for</span> (<span class='ident'>n</span>, <span class='ident'>m</span>) <span class='kw'>in</span> <span class='ident'>events</span>.<span class='ident'>take</span>(<span class='number'>10</span>).<span class='ident'>enumerate</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>n</span> <span class='kw'>as</span> <span class='ident'>i32</span>, <span class='ident'>m</span>); + } + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>sink_feed_async</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>events</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>().<span class='ident'>events</span>(); + <span class='ident'>sink</span>.<span class='ident'>feed_async</span>(<span class='number'>0</span>..<span class='number'>10</span>); + <span class='kw'>for</span> (<span class='ident'>n</span>, <span class='ident'>m</span>) <span class='kw'>in</span> <span class='ident'>events</span>.<span class='ident'>take</span>(<span class='number'>10</span>).<span class='ident'>enumerate</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>n</span> <span class='kw'>as</span> <span class='ident'>i32</span>, <span class='ident'>m</span>); + } + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>coalesce</span>() { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>stream</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>() + .<span class='ident'>merge</span>(<span class='kw-2'>&</span><span class='ident'>sink</span>.<span class='ident'>stream</span>()) + .<span class='ident'>coalesce</span>(<span class='op'>|</span><span class='ident'>a</span>, <span class='ident'>b</span><span class='op'>|</span> <span class='ident'>a</span> <span class='op'>+</span> <span class='ident'>b</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>events</span> <span class='op'>=</span> <span class='ident'>stream</span>.<span class='ident'>events</span>(); + + <span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='number'>1</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>events</span>.<span class='ident'>next</span>(), <span class='prelude-val'>Some</span>(<span class='number'>2</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>monoid_left_identity</span>() { + <span class='kw'>fn</span> <span class='ident'>check</span>(<span class='ident'>input</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>bool</span>, <span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>(); + <span class='kw'>let</span> <span class='ident'>eq</span> <span class='op'>=</span> <span class='ident'>stream_eq</span>(<span class='kw-2'>&</span><span class='ident'>Stream</span>::<span class='ident'>never</span>().<span class='ident'>merge</span>(<span class='kw-2'>&</span><span class='ident'>a</span>), <span class='kw-2'>&</span><span class='ident'>a</span>); + <span class='ident'>sink</span>.<span class='ident'>feed</span>(<span class='ident'>input</span>.<span class='ident'>into_iter</span>()); + <span class='ident'>eq</span>.<span class='ident'>sample</span>() + } + <span class='ident'>quickcheck</span>(<span class='ident'>check</span> <span class='kw'>as</span> <span class='kw'>fn</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>bool</span>, <span class='ident'>String</span><span class='op'>></span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>monoid_right_identity</span>() { + <span class='kw'>fn</span> <span class='ident'>check</span>(<span class='ident'>input</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>bool</span>, <span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>(); + <span class='kw'>let</span> <span class='ident'>eq</span> <span class='op'>=</span> <span class='ident'>stream_eq</span>(<span class='kw-2'>&</span><span class='ident'>a</span>.<span class='ident'>merge</span>(<span class='kw-2'>&</span><span class='ident'>Stream</span>::<span class='ident'>never</span>()), <span class='kw-2'>&</span><span class='ident'>a</span>); + <span class='ident'>sink</span>.<span class='ident'>feed</span>(<span class='ident'>input</span>.<span class='ident'>into_iter</span>()); + <span class='ident'>eq</span>.<span class='ident'>sample</span>() + } + <span class='ident'>quickcheck</span>(<span class='ident'>check</span> <span class='kw'>as</span> <span class='kw'>fn</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>bool</span>, <span class='ident'>String</span><span class='op'>></span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>monoid_associative</span>() { + <span class='kw'>fn</span> <span class='ident'>check</span>(<span class='ident'>input_a</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>, <span class='ident'>input_b</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>, <span class='ident'>input_c</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>bool</span>, <span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>sink_a</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>sink_b</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>sink_c</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>sink_a</span>.<span class='ident'>stream</span>(); + <span class='kw'>let</span> <span class='ident'>b</span> <span class='op'>=</span> <span class='ident'>sink_b</span>.<span class='ident'>stream</span>(); + <span class='kw'>let</span> <span class='ident'>c</span> <span class='op'>=</span> <span class='ident'>sink_c</span>.<span class='ident'>stream</span>(); + <span class='kw'>let</span> <span class='ident'>eq</span> <span class='op'>=</span> <span class='ident'>stream_eq</span>(<span class='kw-2'>&</span><span class='ident'>a</span>.<span class='ident'>merge</span>(<span class='kw-2'>&</span><span class='ident'>b</span>.<span class='ident'>merge</span>(<span class='kw-2'>&</span><span class='ident'>c</span>)), <span class='kw-2'>&</span><span class='ident'>a</span>.<span class='ident'>merge</span>(<span class='kw-2'>&</span><span class='ident'>b</span>).<span class='ident'>merge</span>(<span class='kw-2'>&</span><span class='ident'>c</span>)); + <span class='comment'>/* feed in parallel */</span> { + <span class='kw'>let</span> <span class='ident'>_g1</span> <span class='op'>=</span> <span class='ident'>thread</span>::<span class='ident'>scoped</span>(<span class='op'>||</span> <span class='ident'>sink_a</span>.<span class='ident'>feed</span>(<span class='ident'>input_a</span>.<span class='ident'>into_iter</span>())); + <span class='kw'>let</span> <span class='ident'>_g2</span> <span class='op'>=</span> <span class='ident'>thread</span>::<span class='ident'>scoped</span>(<span class='op'>||</span> <span class='ident'>sink_b</span>.<span class='ident'>feed</span>(<span class='ident'>input_b</span>.<span class='ident'>into_iter</span>())); + <span class='kw'>let</span> <span class='ident'>_g3</span> <span class='op'>=</span> <span class='ident'>thread</span>::<span class='ident'>scoped</span>(<span class='op'>||</span> <span class='ident'>sink_c</span>.<span class='ident'>feed</span>(<span class='ident'>input_c</span>.<span class='ident'>into_iter</span>())); + } + <span class='ident'>eq</span>.<span class='ident'>sample</span>() + } + <span class='ident'>quickcheck</span>(<span class='ident'>check</span> <span class='kw'>as</span> <span class='kw'>fn</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>bool</span>, <span class='ident'>String</span><span class='op'>></span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>functor_identity</span>() { + <span class='kw'>fn</span> <span class='ident'>check</span>(<span class='ident'>input</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>bool</span>, <span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>(); + <span class='kw'>let</span> <span class='ident'>eq</span> <span class='op'>=</span> <span class='ident'>stream_eq</span>(<span class='kw-2'>&</span><span class='ident'>a</span>.<span class='ident'>map</span>(<span class='ident'>id</span>), <span class='kw-2'>&</span><span class='ident'>a</span>); + <span class='ident'>sink</span>.<span class='ident'>feed</span>(<span class='ident'>input</span>.<span class='ident'>into_iter</span>()); + <span class='ident'>eq</span>.<span class='ident'>sample</span>() + } + <span class='ident'>quickcheck</span>(<span class='ident'>check</span> <span class='kw'>as</span> <span class='kw'>fn</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>bool</span>, <span class='ident'>String</span><span class='op'>></span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>functor_composition</span>() { + <span class='kw'>fn</span> <span class='ident'>check</span>(<span class='ident'>input</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>bool</span>, <span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>f</span>(<span class='ident'>n</span>: <span class='ident'>i32</span>) <span class='op'>-></span> <span class='ident'>i64</span> { (<span class='ident'>n</span> <span class='op'>+</span> <span class='number'>3</span>) <span class='kw'>as</span> <span class='ident'>i64</span> } + <span class='kw'>fn</span> <span class='ident'>g</span>(<span class='ident'>n</span>: <span class='ident'>i64</span>) <span class='op'>-></span> <span class='ident'>f64</span> { <span class='ident'>n</span> <span class='kw'>as</span> <span class='ident'>f64</span> <span class='op'>/</span> <span class='number'>2.5</span> } + + <span class='kw'>let</span> <span class='ident'>sink</span> <span class='op'>=</span> <span class='ident'>Sink</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>sink</span>.<span class='ident'>stream</span>(); + <span class='kw'>let</span> <span class='ident'>eq</span> <span class='op'>=</span> <span class='ident'>stream_eq</span>(<span class='kw-2'>&</span><span class='ident'>a</span>.<span class='ident'>map</span>(<span class='ident'>f</span>).<span class='ident'>map</span>(<span class='ident'>g</span>), <span class='kw-2'>&</span><span class='ident'>a</span>.<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>n</span><span class='op'>|</span> <span class='ident'>g</span>(<span class='ident'>f</span>(<span class='ident'>n</span>)))); + <span class='ident'>sink</span>.<span class='ident'>feed</span>(<span class='ident'>input</span>.<span class='ident'>into_iter</span>()); + <span class='ident'>eq</span>.<span class='ident'>sample</span>() + } + <span class='ident'>quickcheck</span>(<span class='ident'>check</span> <span class='kw'>as</span> <span class='kw'>fn</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>bool</span>, <span class='ident'>String</span><span class='op'>></span>); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "carboxyl"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/carboxyl/transaction.rs.html b/src/carboxyl/transaction.rs.html new file mode 100644 index 0000000..e9cc7b6 --- /dev/null +++ b/src/carboxyl/transaction.rs.html @@ -0,0 +1,459 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/carboxyl-0.1.1/src/transaction.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>transaction.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +</pre><pre class='rust '> +<span class='doccomment'>//! A trivial global lock transaction system.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! At the moment, this is really just a global static mutex, that needs to be</span> +<span class='doccomment'>//! locked, to ensure the atomicity of a transaction.</span> + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>sync</span>::<span class='ident'>Mutex</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>cell</span>::<span class='ident'>RefCell</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>boxed</span>::<span class='ident'>FnBox</span>; + + +<span class='doccomment'>/// The global transaction lock.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// TODO: revert this to use a static mutex, as soon as that is stabilized in</span> +<span class='doccomment'>/// the standard library.</span> +<span class='macro'>lazy_static</span><span class='macro'>!</span> { + <span class='kw'>static</span> <span class='kw-2'>ref</span> <span class='ident'>TRANSACTION_MUTEX</span>: <span class='ident'>Mutex</span><span class='op'><</span>()<span class='op'>></span> <span class='op'>=</span> <span class='ident'>Mutex</span>::<span class='ident'>new</span>(()); +} + +<span class='doccomment'>/// Registry for callbacks to be executed at the end of a transaction.</span> +<span class='macro'>thread_local</span><span class='macro'>!</span>( + <span class='kw'>static</span> <span class='ident'>CURRENT_TRANSACTION</span>: <span class='ident'>RefCell</span><span class='op'><</span><span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Transaction</span><span class='op'>>></span> <span class='op'>=</span> + <span class='ident'>RefCell</span>::<span class='ident'>new</span>(<span class='prelude-val'>None</span>) +); + + +<span class='doccomment'>/// A callback.</span> +<span class='kw'>type</span> <span class='ident'>Callback</span> <span class='op'>=</span> <span class='ident'>Box</span><span class='op'><</span><span class='ident'>FnBox</span>() <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span>; + + +<span class='doccomment'>/// A transaction.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Transaction</span> { + <span class='ident'>intermediate</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Callback</span><span class='op'>></span>, + <span class='ident'>finalizers</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Callback</span><span class='op'>></span>, +} + +<span class='kw'>impl</span> <span class='ident'>Transaction</span> { + <span class='doccomment'>/// Create a new transaction</span> + <span class='kw'>fn</span> <span class='ident'>new</span>() <span class='op'>-></span> <span class='ident'>Transaction</span> { + <span class='ident'>Transaction</span> { + <span class='ident'>intermediate</span>: <span class='macro'>vec</span><span class='macro'>!</span>[], + <span class='ident'>finalizers</span>: <span class='macro'>vec</span><span class='macro'>!</span>[], + } + } + + <span class='doccomment'>/// Add a callback that will be called, when the transaction is done</span> + <span class='doccomment'>/// except for finalizers.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>later</span><span class='op'><</span><span class='ident'>F</span>: <span class='ident'>FnOnce</span>() <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>callback</span>: <span class='ident'>F</span>) { + <span class='self'>self</span>.<span class='ident'>intermediate</span>.<span class='ident'>push</span>(<span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>callback</span>)); + } + + <span class='doccomment'>/// Add a finalizing callback. This should not have far reaching</span> + <span class='doccomment'>/// side-effects, and in particular not commit by itself. Typical operations</span> + <span class='doccomment'>/// for a finalizer are executing queued state updates.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>end</span><span class='op'><</span><span class='ident'>F</span>: <span class='ident'>FnOnce</span>() <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>callback</span>: <span class='ident'>F</span>) { + <span class='self'>self</span>.<span class='ident'>finalizers</span>.<span class='ident'>push</span>(<span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>callback</span>)); + } + + <span class='doccomment'>/// Advance transactions by moving out intermediate stage callbacks.</span> + <span class='kw'>fn</span> <span class='ident'>advance</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Callback</span><span class='op'>></span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>mem</span>; + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>intermediate</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[]; + <span class='ident'>mem</span>::<span class='ident'>swap</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>intermediate</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>intermediate</span>); + <span class='ident'>intermediate</span> + } + + <span class='doccomment'>/// Finalize the transaction</span> + <span class='kw'>fn</span> <span class='ident'>finalize</span>(<span class='self'>self</span>) { + <span class='kw'>for</span> <span class='ident'>finalizer</span> <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>finalizers</span> { + <span class='ident'>finalizer</span>.<span class='ident'>call_box</span>(()); + } + } +} + + +<span class='doccomment'>/// Commit a transaction.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// If the thread is not running any transactions currently, the global lock is</span> +<span class='doccomment'>/// acquired. Otherwise a new transaction begins, since given the interface of</span> +<span class='doccomment'>/// this module it is safely assumed that the lock is already held.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>commit</span><span class='op'><</span><span class='ident'>A</span>, <span class='ident'>F</span>: <span class='ident'>FnOnce</span>() <span class='op'>-></span> <span class='ident'>A</span><span class='op'>></span>(<span class='ident'>body</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>A</span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>mem</span>; + <span class='comment'>// Begin a new transaction</span> + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>prev</span> <span class='op'>=</span> <span class='ident'>CURRENT_TRANSACTION</span>.<span class='ident'>with</span>(<span class='op'>|</span><span class='ident'>current</span><span class='op'>|</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>prev</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>Transaction</span>::<span class='ident'>new</span>()); + <span class='ident'>mem</span>::<span class='ident'>swap</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>prev</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>current</span>.<span class='ident'>borrow_mut</span>()); + <span class='ident'>prev</span> + }); + <span class='comment'>// Acquire global lock if necessary</span> + <span class='kw'>let</span> <span class='ident'>_lock</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>prev</span> { + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>TRANSACTION_MUTEX</span>.<span class='ident'>lock</span>().<span class='ident'>ok</span>() + .<span class='ident'>expect</span>(<span class='string'>"global transaction mutex poisoned"</span>) + ), + <span class='prelude-val'>Some</span>(_) <span class='op'>=></span> <span class='prelude-val'>None</span>, + }; + <span class='comment'>// Perform the main body of the transaction</span> + <span class='kw'>let</span> <span class='ident'>result</span> <span class='op'>=</span> <span class='ident'>body</span>(); + <span class='comment'>// Advance the transaction as long as necessary</span> + <span class='kw'>loop</span> { + <span class='kw'>let</span> <span class='ident'>callbacks</span> <span class='op'>=</span> <span class='ident'>with_current</span>(<span class='ident'>Transaction</span>::<span class='ident'>advance</span>); + <span class='kw'>if</span> <span class='ident'>callbacks</span>.<span class='ident'>is_empty</span>() { <span class='kw'>break</span> } + <span class='kw'>for</span> <span class='ident'>callback</span> <span class='kw'>in</span> <span class='ident'>callbacks</span> { + <span class='ident'>callback</span>.<span class='ident'>call_box</span>(()); + } + } + <span class='comment'>// Call all finalizers and drop the transaction</span> + <span class='ident'>CURRENT_TRANSACTION</span>.<span class='ident'>with</span>(<span class='op'>|</span><span class='ident'>current</span><span class='op'>|</span> + <span class='ident'>mem</span>::<span class='ident'>swap</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>prev</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>current</span>.<span class='ident'>borrow_mut</span>()) + ); + <span class='ident'>prev</span>.<span class='ident'>unwrap</span>().<span class='ident'>finalize</span>(); + <span class='comment'>// Return</span> + <span class='ident'>result</span> +} + + +<span class='doccomment'>/// Register a callback during a transaction.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>with_current</span><span class='op'><</span><span class='ident'>A</span>, <span class='ident'>F</span>: <span class='ident'>FnOnce</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Transaction</span>) <span class='op'>-></span> <span class='ident'>A</span><span class='op'>></span>(<span class='ident'>action</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='ident'>A</span> { + <span class='ident'>CURRENT_TRANSACTION</span>.<span class='ident'>with</span>(<span class='op'>|</span><span class='ident'>current</span><span class='op'>|</span> + <span class='kw'>match</span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='ident'>current</span>.<span class='ident'>borrow_mut</span>() { + <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>trans</span>) <span class='op'>=></span> <span class='ident'>action</span>(<span class='ident'>trans</span>), + _ <span class='op'>=></span> <span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>"there is no active transaction to register a callback"</span>), + } + ) +} + +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>later</span><span class='op'><</span><span class='ident'>F</span>: <span class='ident'>FnOnce</span>() <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span>(<span class='ident'>action</span>: <span class='ident'>F</span>) { + <span class='ident'>with_current</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span>.<span class='ident'>later</span>(<span class='ident'>action</span>)) +} + +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>end</span><span class='op'><</span><span class='ident'>F</span>: <span class='ident'>FnOnce</span>() <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span>(<span class='ident'>action</span>: <span class='ident'>F</span>) { + <span class='ident'>with_current</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span>.<span class='ident'>end</span>(<span class='ident'>action</span>)) +} + + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>test</span> { + <span class='kw'>use</span> <span class='ident'>super</span>::<span class='op'>*</span>; + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>commit_single</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='ident'>commit</span>(<span class='op'>||</span> <span class='ident'>v</span> <span class='op'>+=</span> <span class='number'>5</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, <span class='number'>8</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>commit_nested</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='ident'>commit</span>(<span class='op'>||</span> { + <span class='ident'>commit</span>(<span class='op'>||</span> <span class='ident'>v</span> <span class='op'>*=</span> <span class='number'>2</span>); + <span class='ident'>v</span> <span class='op'>+=</span> <span class='number'>4</span>; + }); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>v</span>, <span class='number'>10</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>commits_parallel</span>() { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>sync</span>::{<span class='ident'>Arc</span>, <span class='ident'>Mutex</span>}; + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>thread</span>; + + <span class='comment'>// Set up a ref-counted value</span> + <span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>Mutex</span>::<span class='ident'>new</span>(<span class='number'>3</span>)); + <span class='comment'>// Spawn a couple of scoped threads performing atomic operations on it</span> + <span class='kw'>let</span> <span class='ident'>guards</span>: <span class='ident'>Vec</span><span class='op'><</span>_<span class='op'>></span> <span class='op'>=</span> (<span class='number'>0</span>..<span class='number'>3</span>) + .<span class='ident'>map</span>(<span class='op'>|</span>_<span class='op'>|</span> { + <span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>clone</span>(); + <span class='ident'>thread</span>::<span class='ident'>spawn</span>(<span class='kw'>move</span> <span class='op'>||</span> <span class='ident'>commit</span>(<span class='kw'>move</span> <span class='op'>||</span> { + <span class='comment'>// Acquire locks independently, s.t. commit atomicity does</span> + <span class='comment'>// not rely on the local locks here</span> + <span class='op'>*</span><span class='ident'>v</span>.<span class='ident'>lock</span>().<span class='ident'>unwrap</span>() <span class='op'>*=</span> <span class='number'>2</span>; + <span class='comment'>// …and sleep for a bit</span> + <span class='ident'>thread</span>::<span class='ident'>sleep_ms</span>(<span class='number'>1</span>); + <span class='op'>*</span><span class='ident'>v</span>.<span class='ident'>lock</span>().<span class='ident'>unwrap</span>() <span class='op'>-=</span> <span class='number'>1</span>; + })) + }) + .<span class='ident'>collect</span>(); + <span class='comment'>// Rejoin with all guards</span> + <span class='kw'>for</span> <span class='ident'>guard</span> <span class='kw'>in</span> <span class='ident'>guards</span> { <span class='ident'>guard</span>.<span class='ident'>join</span>().<span class='ident'>ok</span>().<span class='ident'>expect</span>(<span class='string'>"thread failed"</span>); } + <span class='comment'>// Check result</span> + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>v</span>.<span class='ident'>lock</span>().<span class='ident'>unwrap</span>(), <span class='kw-2'>&</span><span class='number'>17</span>); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "carboxyl"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/gcc/lib.rs.html b/src/gcc/lib.rs.html new file mode 100644 index 0000000..40271e9 --- /dev/null +++ b/src/gcc/lib.rs.html @@ -0,0 +1,1093 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/gcc-0.3.8/src/lib.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>lib.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +<span id="313">313</span> +<span id="314">314</span> +<span id="315">315</span> +<span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +<span id="326">326</span> +<span id="327">327</span> +<span id="328">328</span> +<span id="329">329</span> +<span id="330">330</span> +<span id="331">331</span> +<span id="332">332</span> +<span id="333">333</span> +<span id="334">334</span> +<span id="335">335</span> +<span id="336">336</span> +<span id="337">337</span> +<span id="338">338</span> +<span id="339">339</span> +<span id="340">340</span> +<span id="341">341</span> +<span id="342">342</span> +<span id="343">343</span> +<span id="344">344</span> +<span id="345">345</span> +<span id="346">346</span> +<span id="347">347</span> +<span id="348">348</span> +<span id="349">349</span> +<span id="350">350</span> +<span id="351">351</span> +<span id="352">352</span> +<span id="353">353</span> +<span id="354">354</span> +<span id="355">355</span> +<span id="356">356</span> +<span id="357">357</span> +<span id="358">358</span> +<span id="359">359</span> +<span id="360">360</span> +<span id="361">361</span> +<span id="362">362</span> +<span id="363">363</span> +<span id="364">364</span> +<span id="365">365</span> +<span id="366">366</span> +<span id="367">367</span> +<span id="368">368</span> +<span id="369">369</span> +<span id="370">370</span> +<span id="371">371</span> +<span id="372">372</span> +<span id="373">373</span> +<span id="374">374</span> +<span id="375">375</span> +<span id="376">376</span> +<span id="377">377</span> +<span id="378">378</span> +<span id="379">379</span> +<span id="380">380</span> +<span id="381">381</span> +<span id="382">382</span> +<span id="383">383</span> +<span id="384">384</span> +<span id="385">385</span> +<span id="386">386</span> +<span id="387">387</span> +<span id="388">388</span> +<span id="389">389</span> +<span id="390">390</span> +<span id="391">391</span> +<span id="392">392</span> +<span id="393">393</span> +<span id="394">394</span> +<span id="395">395</span> +<span id="396">396</span> +<span id="397">397</span> +<span id="398">398</span> +<span id="399">399</span> +<span id="400">400</span> +<span id="401">401</span> +<span id="402">402</span> +<span id="403">403</span> +<span id="404">404</span> +<span id="405">405</span> +<span id="406">406</span> +<span id="407">407</span> +<span id="408">408</span> +<span id="409">409</span> +<span id="410">410</span> +<span id="411">411</span> +<span id="412">412</span> +<span id="413">413</span> +<span id="414">414</span> +<span id="415">415</span> +<span id="416">416</span> +<span id="417">417</span> +<span id="418">418</span> +<span id="419">419</span> +<span id="420">420</span> +<span id="421">421</span> +<span id="422">422</span> +<span id="423">423</span> +<span id="424">424</span> +<span id="425">425</span> +<span id="426">426</span> +<span id="427">427</span> +<span id="428">428</span> +<span id="429">429</span> +<span id="430">430</span> +<span id="431">431</span> +<span id="432">432</span> +<span id="433">433</span> +<span id="434">434</span> +<span id="435">435</span> +<span id="436">436</span> +<span id="437">437</span> +<span id="438">438</span> +<span id="439">439</span> +<span id="440">440</span> +<span id="441">441</span> +<span id="442">442</span> +<span id="443">443</span> +<span id="444">444</span> +<span id="445">445</span> +<span id="446">446</span> +<span id="447">447</span> +<span id="448">448</span> +<span id="449">449</span> +<span id="450">450</span> +<span id="451">451</span> +<span id="452">452</span> +<span id="453">453</span> +<span id="454">454</span> +<span id="455">455</span> +<span id="456">456</span> +<span id="457">457</span> +<span id="458">458</span> +<span id="459">459</span> +<span id="460">460</span> +<span id="461">461</span> +<span id="462">462</span> +<span id="463">463</span> +<span id="464">464</span> +<span id="465">465</span> +<span id="466">466</span> +<span id="467">467</span> +<span id="468">468</span> +<span id="469">469</span> +<span id="470">470</span> +<span id="471">471</span> +<span id="472">472</span> +<span id="473">473</span> +<span id="474">474</span> +<span id="475">475</span> +<span id="476">476</span> +<span id="477">477</span> +<span id="478">478</span> +<span id="479">479</span> +<span id="480">480</span> +<span id="481">481</span> +<span id="482">482</span> +<span id="483">483</span> +<span id="484">484</span> +<span id="485">485</span> +<span id="486">486</span> +<span id="487">487</span> +<span id="488">488</span> +<span id="489">489</span> +<span id="490">490</span> +<span id="491">491</span> +<span id="492">492</span> +<span id="493">493</span> +<span id="494">494</span> +<span id="495">495</span> +<span id="496">496</span> +<span id="497">497</span> +<span id="498">498</span> +</pre><pre class='rust '> +<span class='doccomment'>//! A library for build scripts to compile custom C code</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! This library is intended to be used as a `build-dependencies` entry in</span> +<span class='doccomment'>//! `Cargo.toml`:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```toml</span> +<span class='doccomment'>//! [build-dependencies]</span> +<span class='doccomment'>//! gcc = "0.2"</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! The purpose of this crate is to provide the utility functions necessary to</span> +<span class='doccomment'>//! compile C code into a static archive which is then linked into a Rust crate.</span> +<span class='doccomment'>//! The top-level `compile_library` function serves as a convenience and more</span> +<span class='doccomment'>//! advanced configuration is available through the `Config` builder.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! This crate will automatically detect situations such as cross compilation or</span> +<span class='doccomment'>//! other environment variables set by Cargo and will build code appropriately.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # Examples</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Use the default configuration:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```no_run</span> +<span class='doccomment'>//! extern crate gcc;</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! fn main() {</span> +<span class='doccomment'>//! gcc::compile_library("libfoo.a", &["src/foo.c"]);</span> +<span class='doccomment'>//! }</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Use more advanced configuration:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```no_run</span> +<span class='doccomment'>//! extern crate gcc;</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! fn main() {</span> +<span class='doccomment'>//! gcc::Config::new()</span> +<span class='doccomment'>//! .file("src/foo.c")</span> +<span class='doccomment'>//! .define("FOO", Some("bar"))</span> +<span class='doccomment'>//! .include("src")</span> +<span class='doccomment'>//! .compile("libfoo.a");</span> +<span class='doccomment'>//! }</span> +<span class='doccomment'>//! ```</span> + +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>doc</span>(<span class='ident'>html_root_url</span> <span class='op'>=</span> <span class='string'>"http://alexcrichton.com/gcc-rs"</span>)]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>cfg_attr</span>(<span class='ident'>test</span>, <span class='ident'>deny</span>(<span class='ident'>warnings</span>))]</span> + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>env</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ffi</span>::<span class='ident'>OsString</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>fs</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>path</span>::{<span class='ident'>PathBuf</span>, <span class='ident'>Path</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>process</span>::{<span class='ident'>Command</span>, <span class='ident'>Stdio</span>}; + +<span class='doccomment'>/// Extra configuration to pass to gcc.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Config</span> { + <span class='ident'>include_directories</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>PathBuf</span><span class='op'>></span>, + <span class='ident'>definitions</span>: <span class='ident'>Vec</span><span class='op'><</span>(<span class='ident'>String</span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span>)<span class='op'>></span>, + <span class='ident'>objects</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>PathBuf</span><span class='op'>></span>, + <span class='ident'>flags</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span>, + <span class='ident'>files</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>PathBuf</span><span class='op'>></span>, + <span class='ident'>cpp</span>: <span class='ident'>bool</span>, + <span class='ident'>cpp_link_stdlib</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span>, + <span class='ident'>cpp_set_stdlib</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span>, +} + +<span class='doccomment'>/// Returns the default C++ standard library for the current target: `libc++`</span> +<span class='doccomment'>/// for OS X and `libstdc++` for anything else.</span> +<span class='kw'>fn</span> <span class='ident'>target_default_cpp_stdlib</span>() <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>target</span> <span class='op'>=</span> <span class='ident'>getenv_unwrap</span>(<span class='string'>"TARGET"</span>); + <span class='kw'>if</span> <span class='ident'>target</span>.<span class='ident'>contains</span>(<span class='string'>"msvc"</span>) { + <span class='prelude-val'>None</span> + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>target</span>.<span class='ident'>contains</span>(<span class='string'>"darwin"</span>) { + <span class='prelude-val'>Some</span>(<span class='string'>"c++"</span>) + } <span class='kw'>else</span> { + <span class='prelude-val'>Some</span>(<span class='string'>"stdc++"</span>) + } +} + +<span class='kw'>fn</span> <span class='ident'>getenv</span>(<span class='ident'>v</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>env</span>::<span class='ident'>var</span>(<span class='ident'>v</span>).<span class='ident'>ok</span>(); + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"{} = {:?}"</span>, <span class='ident'>v</span>, <span class='ident'>r</span>); + <span class='ident'>r</span> +} + +<span class='kw'>fn</span> <span class='ident'>getenv_unwrap</span>(<span class='ident'>v</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>match</span> <span class='ident'>getenv</span>(<span class='ident'>v</span>) { + <span class='prelude-val'>Some</span>(<span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>s</span>, + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='ident'>fail</span>(<span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"environment variable `{}` not defined"</span>, <span class='ident'>v</span>)), + } +} + +<span class='doccomment'>/// Compile a library from the given set of input C files.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This will simply compile all files into object files and then assemble them</span> +<span class='doccomment'>/// into the output. This will read the standard environment variables to detect</span> +<span class='doccomment'>/// cross compilations and such.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This function will also print all metadata on standard output for Cargo.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Example</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ```no_run</span> +<span class='doccomment'>/// gcc::compile_library("libfoo.a", &["foo.c", "bar.c"]);</span> +<span class='doccomment'>/// ```</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>compile_library</span>(<span class='ident'>output</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>files</span>: <span class='kw-2'>&</span>[<span class='kw-2'>&</span><span class='ident'>str</span>]) { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>c</span> <span class='op'>=</span> <span class='ident'>Config</span>::<span class='ident'>new</span>(); + <span class='kw'>for</span> <span class='ident'>f</span> <span class='kw'>in</span> <span class='ident'>files</span>.<span class='ident'>iter</span>() { + <span class='ident'>c</span>.<span class='ident'>file</span>(<span class='op'>*</span><span class='ident'>f</span>); + } + <span class='ident'>c</span>.<span class='ident'>compile</span>(<span class='ident'>output</span>) +} + +<span class='kw'>impl</span> <span class='ident'>Config</span> { + <span class='doccomment'>/// Construct a new instance of a blank set of configuration.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This builder is finished with the `compile` function.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>() <span class='op'>-></span> <span class='ident'>Config</span> { + <span class='ident'>Config</span> { + <span class='ident'>include_directories</span>: <span class='ident'>Vec</span>::<span class='ident'>new</span>(), + <span class='ident'>definitions</span>: <span class='ident'>Vec</span>::<span class='ident'>new</span>(), + <span class='ident'>objects</span>: <span class='ident'>Vec</span>::<span class='ident'>new</span>(), + <span class='ident'>flags</span>: <span class='ident'>Vec</span>::<span class='ident'>new</span>(), + <span class='ident'>files</span>: <span class='ident'>Vec</span>::<span class='ident'>new</span>(), + <span class='ident'>cpp</span>: <span class='boolval'>false</span>, + <span class='ident'>cpp_link_stdlib</span>: <span class='ident'>target_default_cpp_stdlib</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>s</span><span class='op'>|</span> <span class='ident'>s</span>.<span class='ident'>into</span>()), + <span class='ident'>cpp_set_stdlib</span>: <span class='prelude-val'>None</span>, + } + } + + <span class='doccomment'>/// Add a directory to the `-I` or include path for headers</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>include</span><span class='op'><</span><span class='ident'>P</span>: <span class='ident'>AsRef</span><span class='op'><</span><span class='ident'>Path</span><span class='op'>>></span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>dir</span>: <span class='ident'>P</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Config</span> { + <span class='self'>self</span>.<span class='ident'>include_directories</span>.<span class='ident'>push</span>(<span class='ident'>dir</span>.<span class='ident'>as_ref</span>().<span class='ident'>to_path_buf</span>()); + <span class='self'>self</span> + } + + <span class='doccomment'>/// Specify a `-D` variable with an optional value.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>define</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>var</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>val</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='ident'>str</span><span class='op'>></span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Config</span> { + <span class='self'>self</span>.<span class='ident'>definitions</span>.<span class='ident'>push</span>((<span class='ident'>var</span>.<span class='ident'>to_string</span>(), <span class='ident'>val</span>.<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>s</span><span class='op'>|</span> <span class='ident'>s</span>.<span class='ident'>to_string</span>()))); + <span class='self'>self</span> + } + + <span class='doccomment'>/// Add an arbitrary object file to link in</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>object</span><span class='op'><</span><span class='ident'>P</span>: <span class='ident'>AsRef</span><span class='op'><</span><span class='ident'>Path</span><span class='op'>>></span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>obj</span>: <span class='ident'>P</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Config</span> { + <span class='self'>self</span>.<span class='ident'>objects</span>.<span class='ident'>push</span>(<span class='ident'>obj</span>.<span class='ident'>as_ref</span>().<span class='ident'>to_path_buf</span>()); + <span class='self'>self</span> + } + + <span class='doccomment'>/// Add an arbitrary flag to the invocation of the compiler</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>flag</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>flag</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Config</span> { + <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>push</span>(<span class='ident'>flag</span>.<span class='ident'>to_string</span>()); + <span class='self'>self</span> + } + + <span class='doccomment'>/// Add a file which will be compiled</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>file</span><span class='op'><</span><span class='ident'>P</span>: <span class='ident'>AsRef</span><span class='op'><</span><span class='ident'>Path</span><span class='op'>>></span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>p</span>: <span class='ident'>P</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Config</span> { + <span class='self'>self</span>.<span class='ident'>files</span>.<span class='ident'>push</span>(<span class='ident'>p</span>.<span class='ident'>as_ref</span>().<span class='ident'>to_path_buf</span>()); + <span class='self'>self</span> + } + + <span class='doccomment'>/// Set C++ support.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The other `cpp_*` options will only become active if this is set to</span> + <span class='doccomment'>/// `true`.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>cpp</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>cpp</span>: <span class='ident'>bool</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Config</span> { + <span class='self'>self</span>.<span class='ident'>cpp</span> <span class='op'>=</span> <span class='ident'>cpp</span>; + <span class='self'>self</span> + } + + <span class='doccomment'>/// Set the standard library to link against when compiling with C++</span> + <span class='doccomment'>/// support.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The default value of this property depends on the current target: On</span> + <span class='doccomment'>/// OS X `Some("c++")` is used, when compiling for a Visual Studio based</span> + <span class='doccomment'>/// target `None` is used and for other targets `Some("stdc++")` is used.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// A value of `None` indicates that no automatic linking should happen,</span> + <span class='doccomment'>/// otherwise cargo will link against the specified library.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The given library name must not contain the `lib` prefix.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>cpp_link_stdlib</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>cpp_link_stdlib</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='ident'>str</span><span class='op'>></span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Config</span> { + <span class='self'>self</span>.<span class='ident'>cpp_link_stdlib</span> <span class='op'>=</span> <span class='ident'>cpp_link_stdlib</span>.<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>s</span><span class='op'>|</span> <span class='ident'>s</span>.<span class='ident'>into</span>()); + <span class='self'>self</span> + } + + <span class='doccomment'>/// Force the C++ compiler to use the specified standard library.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Setting this option will automatically set `cpp_link_stdlib` to the same</span> + <span class='doccomment'>/// value.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The default value of this option is always `None`.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This option has no effect when compiling for a Visual Studio based</span> + <span class='doccomment'>/// target.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This option sets the `-stdlib` flag, which is only supported by some</span> + <span class='doccomment'>/// compilers (clang, icc) but not by others (gcc). The library will not</span> + <span class='doccomment'>/// detect which compiler is used, as such it is the responsibility of the</span> + <span class='doccomment'>/// caller to ensure that this option is only used in conjuction with a</span> + <span class='doccomment'>/// compiler which supports the `-stdlib` flag.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// A value of `None` indicates that no specific C++ standard library should</span> + <span class='doccomment'>/// be used, otherwise `-stdlib` is added to the compile invocation.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The given library name must not contain the `lib` prefix.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>cpp_set_stdlib</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>cpp_set_stdlib</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='ident'>str</span><span class='op'>></span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Config</span> { + <span class='self'>self</span>.<span class='ident'>cpp_set_stdlib</span> <span class='op'>=</span> <span class='ident'>cpp_set_stdlib</span>.<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>s</span><span class='op'>|</span> <span class='ident'>s</span>.<span class='ident'>into</span>()); + + <span class='self'>self</span>.<span class='ident'>cpp_link_stdlib</span>(<span class='ident'>cpp_set_stdlib</span>); + + <span class='self'>self</span> + } + + <span class='doccomment'>/// Run the compiler, generating the file `output`</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The name `output` must begin with `lib` and end with `.a`</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>compile</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>output</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) { + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>output</span>.<span class='ident'>starts_with</span>(<span class='string'>"lib"</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>output</span>.<span class='ident'>ends_with</span>(<span class='string'>".a"</span>)); + <span class='kw'>let</span> <span class='ident'>lib_name</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='ident'>output</span>[<span class='number'>3</span>..<span class='ident'>output</span>.<span class='ident'>len</span>() <span class='op'>-</span> <span class='number'>2</span>]; + + <span class='kw'>let</span> <span class='ident'>target</span> <span class='op'>=</span> <span class='ident'>getenv_unwrap</span>(<span class='string'>"TARGET"</span>); + <span class='kw'>let</span> <span class='ident'>src</span> <span class='op'>=</span> <span class='ident'>PathBuf</span>::<span class='ident'>from</span>(<span class='ident'>getenv_unwrap</span>(<span class='string'>"CARGO_MANIFEST_DIR"</span>)); + <span class='kw'>let</span> <span class='ident'>dst</span> <span class='op'>=</span> <span class='ident'>PathBuf</span>::<span class='ident'>from</span>(<span class='ident'>getenv_unwrap</span>(<span class='string'>"OUT_DIR"</span>)); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>objects</span> <span class='op'>=</span> <span class='ident'>Vec</span>::<span class='ident'>new</span>(); + <span class='kw'>for</span> <span class='ident'>file</span> <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>files</span>.<span class='ident'>iter</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>cmd</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>compile_cmd</span>(<span class='kw-2'>&</span><span class='ident'>target</span>); + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='ident'>src</span>.<span class='ident'>join</span>(<span class='ident'>file</span>)); + + <span class='kw'>let</span> <span class='ident'>obj</span> <span class='op'>=</span> <span class='ident'>dst</span>.<span class='ident'>join</span>(<span class='ident'>file</span>).<span class='ident'>with_extension</span>(<span class='string'>"o"</span>); + <span class='ident'>fs</span>::<span class='ident'>create_dir_all</span>(<span class='kw-2'>&</span><span class='ident'>obj</span>.<span class='ident'>parent</span>().<span class='ident'>unwrap</span>()).<span class='ident'>unwrap</span>(); + <span class='kw'>if</span> <span class='ident'>target</span>.<span class='ident'>contains</span>(<span class='string'>"msvc"</span>) { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>OsString</span>::<span class='ident'>from</span>(<span class='string'>"/Fo:"</span>); + <span class='ident'>s</span>.<span class='ident'>push</span>(<span class='kw-2'>&</span><span class='ident'>obj</span>); + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='ident'>s</span>); + } <span class='kw'>else</span> { + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='string'>"-o"</span>).<span class='ident'>arg</span>(<span class='kw-2'>&</span><span class='ident'>obj</span>); + } + <span class='ident'>run</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>cmd</span>, <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>compiler</span>(<span class='kw-2'>&</span><span class='ident'>target</span>)); + <span class='ident'>objects</span>.<span class='ident'>push</span>(<span class='ident'>obj</span>); + } + + <span class='kw'>if</span> <span class='ident'>target</span>.<span class='ident'>contains</span>(<span class='string'>"msvc"</span>) { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>out</span> <span class='op'>=</span> <span class='ident'>OsString</span>::<span class='ident'>from</span>(<span class='string'>"/OUT:"</span>); + <span class='ident'>out</span>.<span class='ident'>push</span>(<span class='ident'>dst</span>.<span class='ident'>join</span>(<span class='ident'>output</span>)); + <span class='ident'>run</span>(<span class='ident'>Command</span>::<span class='ident'>new</span>(<span class='string'>"lib"</span>).<span class='ident'>arg</span>(<span class='ident'>out</span>).<span class='ident'>args</span>(<span class='kw-2'>&</span><span class='ident'>objects</span>).<span class='ident'>args</span>(<span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>objects</span>), + <span class='string'>"lib"</span>); + + <span class='comment'>// The Rust compiler will look for libfoo.a and foo.lib, but the</span> + <span class='comment'>// MSVC linker will also be passed foo.lib, so be sure that both</span> + <span class='comment'>// exist for now.</span> + <span class='kw'>let</span> <span class='ident'>lib_dst</span> <span class='op'>=</span> <span class='ident'>dst</span>.<span class='ident'>join</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}.lib"</span>, <span class='ident'>lib_name</span>)); + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>fs</span>::<span class='ident'>remove_file</span>(<span class='kw-2'>&</span><span class='ident'>lib_dst</span>); + <span class='ident'>fs</span>::<span class='ident'>hard_link</span>(<span class='ident'>dst</span>.<span class='ident'>join</span>(<span class='ident'>output</span>), <span class='ident'>lib_dst</span>).<span class='ident'>unwrap</span>(); + } <span class='kw'>else</span> { + <span class='ident'>run</span>(<span class='ident'>Command</span>::<span class='ident'>new</span>(<span class='kw-2'>&</span><span class='ident'>ar</span>(<span class='kw-2'>&</span><span class='ident'>target</span>)).<span class='ident'>arg</span>(<span class='string'>"crus"</span>) + .<span class='ident'>arg</span>(<span class='kw-2'>&</span><span class='ident'>dst</span>.<span class='ident'>join</span>(<span class='ident'>output</span>)) + .<span class='ident'>args</span>(<span class='kw-2'>&</span><span class='ident'>objects</span>) + .<span class='ident'>args</span>(<span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>objects</span>), + <span class='kw-2'>&</span><span class='ident'>ar</span>(<span class='kw-2'>&</span><span class='ident'>target</span>)); + } + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"cargo:rustc-link-search=native={}"</span>, <span class='ident'>dst</span>.<span class='ident'>display</span>()); + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"cargo:rustc-link-lib=static={}"</span>, + <span class='kw-2'>&</span><span class='ident'>output</span>[<span class='number'>3</span>..<span class='ident'>output</span>.<span class='ident'>len</span>() <span class='op'>-</span> <span class='number'>2</span>]); + + <span class='comment'>// Add specific C++ libraries, if enabled.</span> + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>cpp</span> { + <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>stdlib</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>cpp_link_stdlib</span> { + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"cargo:rustc-link-lib={}"</span>, <span class='ident'>stdlib</span>); + } + } + } + + <span class='kw'>fn</span> <span class='ident'>compiler</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>target</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>cpp</span> { + <span class='ident'>gxx</span>(<span class='ident'>target</span>) + } <span class='kw'>else</span> { + <span class='ident'>gcc</span>(<span class='ident'>target</span>) + } + } + + <span class='kw'>fn</span> <span class='ident'>compile_flags</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>cpp</span> { + <span class='ident'>cxxflags</span>() + } <span class='kw'>else</span> { + <span class='ident'>cflags</span>() + } + } + + <span class='kw'>fn</span> <span class='ident'>compile_cmd</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>target</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Command</span> { + <span class='kw'>let</span> <span class='ident'>opt_level</span> <span class='op'>=</span> <span class='ident'>getenv_unwrap</span>(<span class='string'>"OPT_LEVEL"</span>); + <span class='kw'>let</span> <span class='ident'>profile</span> <span class='op'>=</span> <span class='ident'>getenv_unwrap</span>(<span class='string'>"PROFILE"</span>); + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"{} {}"</span>, <span class='ident'>profile</span>, <span class='ident'>opt_level</span>); + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>cmd</span> <span class='op'>=</span> <span class='ident'>Command</span>::<span class='ident'>new</span>(<span class='self'>self</span>.<span class='ident'>compiler</span>(<span class='kw-2'>&</span><span class='ident'>target</span>)); + + <span class='kw'>if</span> <span class='ident'>target</span>.<span class='ident'>contains</span>(<span class='string'>"msvc"</span>) { + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='string'>"/c"</span>); + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='string'>"/MD"</span>); <span class='comment'>// link against msvcrt.dll for now</span> + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"/O{}"</span>, <span class='ident'>opt_level</span>)); + } <span class='kw'>else</span> { + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"-O{}"</span>, <span class='ident'>opt_level</span>)); + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='string'>"-c"</span>); + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='string'>"-ffunction-sections"</span>).<span class='ident'>arg</span>(<span class='string'>"-fdata-sections"</span>); + } + <span class='ident'>cmd</span>.<span class='ident'>args</span>(<span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>compile_flags</span>()); + + <span class='kw'>if</span> <span class='ident'>target</span>.<span class='ident'>contains</span>(<span class='string'>"-ios"</span>) { + <span class='ident'>cmd</span>.<span class='ident'>args</span>(<span class='kw-2'>&</span><span class='ident'>ios_flags</span>(<span class='kw-2'>&</span><span class='ident'>target</span>)); + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>target</span>.<span class='ident'>contains</span>(<span class='string'>"msvc"</span>) { + <span class='kw'>if</span> <span class='ident'>target</span>.<span class='ident'>contains</span>(<span class='string'>"windows"</span>) { + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='string'>"-mwin32"</span>); + } + + <span class='kw'>if</span> <span class='ident'>target</span>.<span class='ident'>contains</span>(<span class='string'>"i686"</span>) { + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='string'>"-m32"</span>); + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>target</span>.<span class='ident'>contains</span>(<span class='string'>"x86_64"</span>) { + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='string'>"-m64"</span>); + } + + <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>target</span>.<span class='ident'>contains</span>(<span class='string'>"i686"</span>) { + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='string'>"-fPIC"</span>); + } + } + + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>cpp</span> <span class='op'>&&</span> <span class='op'>!</span><span class='ident'>target</span>.<span class='ident'>contains</span>(<span class='string'>"msvc"</span>) { + <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>stdlib</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>cpp_set_stdlib</span> { + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"-stdlib=lib{}"</span>, <span class='ident'>stdlib</span>)); + } + } + + <span class='kw'>for</span> <span class='ident'>directory</span> <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>include_directories</span>.<span class='ident'>iter</span>() { + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='kw'>if</span> <span class='ident'>target</span>.<span class='ident'>contains</span>(<span class='string'>"msvc"</span>) {<span class='string'>"/I"</span>} <span class='kw'>else</span> {<span class='string'>"-I"</span>}); + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='ident'>directory</span>); + } + + <span class='kw'>for</span> <span class='ident'>flag</span> <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>iter</span>() { + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='ident'>flag</span>); + } + + <span class='kw'>for</span> <span class='kw-2'>&</span>(<span class='kw-2'>ref</span> <span class='ident'>key</span>, <span class='kw-2'>ref</span> <span class='ident'>value</span>) <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>definitions</span>.<span class='ident'>iter</span>() { + <span class='kw'>let</span> <span class='ident'>lead</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='ident'>target</span>.<span class='ident'>contains</span>(<span class='string'>"msvc"</span>) {<span class='string'>"/"</span>} <span class='kw'>else</span> {<span class='string'>"-"</span>}; + <span class='kw'>if</span> <span class='kw'>let</span> <span class='kw-2'>&</span><span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>value</span>) <span class='op'>=</span> <span class='ident'>value</span> { + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}D{}={}"</span>, <span class='ident'>lead</span>, <span class='ident'>key</span>, <span class='ident'>value</span>)); + } <span class='kw'>else</span> { + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}D{}"</span>, <span class='ident'>lead</span>, <span class='ident'>key</span>)); + } + } + <span class='kw'>return</span> <span class='ident'>cmd</span>; + } +} + +<span class='kw'>fn</span> <span class='ident'>run</span>(<span class='ident'>cmd</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Command</span>, <span class='ident'>program</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) { + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"running: {:?}"</span>, <span class='ident'>cmd</span>); + <span class='kw'>let</span> <span class='ident'>status</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>cmd</span>.<span class='ident'>status</span>() { + <span class='prelude-val'>Ok</span>(<span class='ident'>status</span>) <span class='op'>=></span> <span class='ident'>status</span>, + <span class='prelude-val'>Err</span>(<span class='kw-2'>ref</span> <span class='ident'>e</span>) <span class='kw'>if</span> <span class='ident'>e</span>.<span class='ident'>kind</span>() <span class='op'>==</span> <span class='ident'>io</span>::<span class='ident'>ErrorKind</span>::<span class='ident'>NotFound</span> <span class='op'>=></span> { + <span class='kw'>let</span> <span class='ident'>extra</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='macro'>cfg</span><span class='macro'>!</span>(<span class='ident'>windows</span>) { + <span class='string'>" (see https://github.com/alexcrichton/gcc-rs#windows-notes \ + for help)"</span> + } <span class='kw'>else</span> { + <span class='string'>""</span> + }; + <span class='ident'>fail</span>(<span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"failed to execute command: {}\nIs `{}` \ + not installed?{}"</span>, <span class='ident'>e</span>, <span class='ident'>program</span>, <span class='ident'>extra</span>)); + } + <span class='prelude-val'>Err</span>(<span class='ident'>e</span>) <span class='op'>=></span> <span class='ident'>fail</span>(<span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"failed to execute command: {}"</span>, <span class='ident'>e</span>)), + }; + <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>status</span>.<span class='ident'>success</span>() { + <span class='ident'>fail</span>(<span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"command did not execute successfully, got: {}"</span>, <span class='ident'>status</span>)); + } +} + +<span class='kw'>fn</span> <span class='ident'>get_var</span>(<span class='ident'>var_base</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>String</span>, <span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>target</span> <span class='op'>=</span> <span class='ident'>getenv_unwrap</span>(<span class='string'>"TARGET"</span>); + <span class='kw'>let</span> <span class='ident'>host</span> <span class='op'>=</span> <span class='ident'>getenv_unwrap</span>(<span class='string'>"HOST"</span>); + <span class='kw'>let</span> <span class='ident'>kind</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='ident'>host</span> <span class='op'>==</span> <span class='ident'>target</span> {<span class='string'>"HOST"</span>} <span class='kw'>else</span> {<span class='string'>"TARGET"</span>}; + <span class='kw'>let</span> <span class='ident'>target_u</span> <span class='op'>=</span> <span class='ident'>target</span>.<span class='ident'>replace</span>(<span class='string'>"-"</span>, <span class='string'>"_"</span>); + <span class='kw'>let</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='ident'>getenv</span>(<span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}_{}"</span>, <span class='ident'>var_base</span>, <span class='ident'>target</span>)) + .<span class='ident'>or_else</span>(<span class='op'>||</span> <span class='ident'>getenv</span>(<span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}_{}"</span>, <span class='ident'>var_base</span>, <span class='ident'>target_u</span>))) + .<span class='ident'>or_else</span>(<span class='op'>||</span> <span class='ident'>getenv</span>(<span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}_{}"</span>, <span class='ident'>kind</span>, <span class='ident'>var_base</span>))) + .<span class='ident'>or_else</span>(<span class='op'>||</span> <span class='ident'>getenv</span>(<span class='ident'>var_base</span>)); + + <span class='kw'>match</span> <span class='ident'>res</span> { + <span class='prelude-val'>Some</span>(<span class='ident'>res</span>) <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='ident'>res</span>), + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='prelude-val'>Err</span>(<span class='string'>"Could not get environment variable"</span>.<span class='ident'>to_string</span>()), + } +} + +<span class='kw'>fn</span> <span class='ident'>gcc</span>(<span class='ident'>target</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>let</span> <span class='ident'>is_android</span> <span class='op'>=</span> <span class='ident'>target</span>.<span class='ident'>find</span>(<span class='string'>"android"</span>).<span class='ident'>is_some</span>(); + + <span class='ident'>get_var</span>(<span class='string'>"CC"</span>).<span class='ident'>unwrap_or</span>(<span class='kw'>if</span> <span class='macro'>cfg</span><span class='macro'>!</span>(<span class='ident'>windows</span>) { + <span class='kw'>if</span> <span class='ident'>target</span>.<span class='ident'>contains</span>(<span class='string'>"msvc"</span>) { + <span class='string'>"cl"</span>.<span class='ident'>to_string</span>() + } <span class='kw'>else</span> { + <span class='string'>"gcc"</span>.<span class='ident'>to_string</span>() + } + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>is_android</span> { + <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}-gcc"</span>, <span class='ident'>target</span>) + } <span class='kw'>else</span> { + <span class='string'>"cc"</span>.<span class='ident'>to_string</span>() + }) +} + +<span class='kw'>fn</span> <span class='ident'>gxx</span>(<span class='ident'>target</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>let</span> <span class='ident'>is_android</span> <span class='op'>=</span> <span class='ident'>target</span>.<span class='ident'>find</span>(<span class='string'>"android"</span>).<span class='ident'>is_some</span>(); + + <span class='ident'>get_var</span>(<span class='string'>"CXX"</span>).<span class='ident'>unwrap_or</span>(<span class='kw'>if</span> <span class='macro'>cfg</span><span class='macro'>!</span>(<span class='ident'>windows</span>) { + <span class='kw'>if</span> <span class='ident'>target</span>.<span class='ident'>contains</span>(<span class='string'>"msvc"</span>) { + <span class='string'>"cl"</span>.<span class='ident'>to_string</span>() + } <span class='kw'>else</span> { + <span class='string'>"g++"</span>.<span class='ident'>to_string</span>() + } + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>is_android</span> { + <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}-g++"</span>, <span class='ident'>target</span>) + } <span class='kw'>else</span> { + <span class='string'>"c++"</span>.<span class='ident'>to_string</span>() + }) +} + +<span class='kw'>fn</span> <span class='ident'>ar</span>(<span class='ident'>target</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>let</span> <span class='ident'>is_android</span> <span class='op'>=</span> <span class='ident'>target</span>.<span class='ident'>find</span>(<span class='string'>"android"</span>).<span class='ident'>is_some</span>(); + + <span class='ident'>get_var</span>(<span class='string'>"AR"</span>).<span class='ident'>unwrap_or</span>(<span class='kw'>if</span> <span class='ident'>is_android</span> { + <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}-ar"</span>, <span class='ident'>target</span>) + } <span class='kw'>else</span> { + <span class='string'>"ar"</span>.<span class='ident'>to_string</span>() + }) +} + +<span class='kw'>fn</span> <span class='ident'>envflags</span>(<span class='ident'>name</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='ident'>get_var</span>(<span class='ident'>name</span>).<span class='ident'>unwrap_or</span>(<span class='ident'>String</span>::<span class='ident'>new</span>()) + .<span class='ident'>split</span>(<span class='op'>|</span><span class='ident'>c</span>: <span class='ident'>char</span><span class='op'>|</span> <span class='ident'>c</span>.<span class='ident'>is_whitespace</span>()).<span class='ident'>filter</span>(<span class='op'>|</span><span class='ident'>s</span><span class='op'>|</span> <span class='op'>!</span><span class='ident'>s</span>.<span class='ident'>is_empty</span>()) + .<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>s</span><span class='op'>|</span> <span class='ident'>s</span>.<span class='ident'>to_string</span>()) + .<span class='ident'>collect</span>() +} + +<span class='kw'>fn</span> <span class='ident'>cflags</span>() <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='ident'>envflags</span>(<span class='string'>"CFLAGS"</span>) +} + +<span class='kw'>fn</span> <span class='ident'>cxxflags</span>() <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='ident'>envflags</span>(<span class='string'>"CXXFLAGS"</span>) +} + +<span class='kw'>fn</span> <span class='ident'>ios_flags</span>(<span class='ident'>target</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>enum</span> <span class='ident'>ArchSpec</span> { + <span class='ident'>Device</span>(<span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>), + <span class='ident'>Simulator</span>(<span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>), + } + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='ident'>Vec</span>::<span class='ident'>new</span>(); + + <span class='kw'>let</span> <span class='ident'>arch</span> <span class='op'>=</span> <span class='ident'>target</span>.<span class='ident'>split</span>(<span class='string'>'-'</span>).<span class='ident'>nth</span>(<span class='number'>0</span>).<span class='ident'>expect</span>(<span class='string'>"expected target in format `arch-vendor-os`"</span>); + <span class='kw'>let</span> <span class='ident'>arch</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>arch</span> { + <span class='string'>"arm"</span> <span class='op'>|</span> <span class='string'>"armv7"</span> <span class='op'>|</span> <span class='string'>"thumbv7"</span> <span class='op'>=></span> <span class='ident'>ArchSpec</span>::<span class='ident'>Device</span>(<span class='string'>"armv7"</span>), + <span class='string'>"armv7s"</span> <span class='op'>|</span> <span class='string'>"thumbv7s"</span> <span class='op'>=></span> <span class='ident'>ArchSpec</span>::<span class='ident'>Device</span>(<span class='string'>"armv7s"</span>), + <span class='string'>"arm64"</span> <span class='op'>|</span> <span class='string'>"aarch64"</span> <span class='op'>=></span> <span class='ident'>ArchSpec</span>::<span class='ident'>Device</span>(<span class='string'>"arm64"</span>), + <span class='string'>"i386"</span> <span class='op'>|</span> <span class='string'>"i686"</span> <span class='op'>=></span> <span class='ident'>ArchSpec</span>::<span class='ident'>Simulator</span>(<span class='string'>"-m32"</span>), + <span class='string'>"x86_64"</span> <span class='op'>=></span> <span class='ident'>ArchSpec</span>::<span class='ident'>Simulator</span>(<span class='string'>"-m64"</span>), + _ <span class='op'>=></span> <span class='macro'>unreachable</span><span class='macro'>!</span>(<span class='string'>"Unknown arch for iOS target"</span>) + }; + + <span class='kw'>let</span> <span class='ident'>sdk</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>arch</span> { + <span class='ident'>ArchSpec</span>::<span class='ident'>Device</span>(<span class='ident'>arch</span>) <span class='op'>=></span> { + <span class='ident'>res</span>.<span class='ident'>push</span>(<span class='string'>"-arch"</span>.<span class='ident'>to_string</span>()); + <span class='ident'>res</span>.<span class='ident'>push</span>(<span class='ident'>arch</span>.<span class='ident'>to_string</span>()); + <span class='string'>"iphoneos"</span> + }, + <span class='ident'>ArchSpec</span>::<span class='ident'>Simulator</span>(<span class='ident'>arch</span>) <span class='op'>=></span> { + <span class='ident'>res</span>.<span class='ident'>push</span>(<span class='ident'>arch</span>.<span class='ident'>to_string</span>()); + <span class='string'>"iphonesimulator"</span> + } + }; + + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Detecting iOS SDK path for {}"</span>, <span class='ident'>sdk</span>); + <span class='kw'>let</span> <span class='ident'>sdk_path</span> <span class='op'>=</span> <span class='ident'>Command</span>::<span class='ident'>new</span>(<span class='string'>"xcrun"</span>) + .<span class='ident'>arg</span>(<span class='string'>"--show-sdk-path"</span>) + .<span class='ident'>arg</span>(<span class='string'>"--sdk"</span>) + .<span class='ident'>arg</span>(<span class='ident'>sdk</span>) + .<span class='ident'>stderr</span>(<span class='ident'>Stdio</span>::<span class='ident'>inherit</span>()) + .<span class='ident'>output</span>() + .<span class='ident'>unwrap</span>() + .<span class='ident'>stdout</span>; + + <span class='kw'>let</span> <span class='ident'>sdk_path</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from_utf8</span>(<span class='ident'>sdk_path</span>).<span class='ident'>unwrap</span>(); + + <span class='ident'>res</span>.<span class='ident'>push</span>(<span class='string'>"-isysroot"</span>.<span class='ident'>to_string</span>()); + <span class='ident'>res</span>.<span class='ident'>push</span>(<span class='ident'>sdk_path</span>.<span class='ident'>trim</span>().<span class='ident'>to_string</span>()); + + <span class='ident'>res</span> +} + +<span class='kw'>fn</span> <span class='ident'>fail</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='op'>!</span> { + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"\n\n{}\n\n"</span>, <span class='ident'>s</span>); + <span class='macro'>panic</span><span class='macro'>!</span>() +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "gcc"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/irsc/callback.rs.html b/src/irsc/callback.rs.html new file mode 100644 index 0000000..ed767cf --- /dev/null +++ b/src/irsc/callback.rs.html @@ -0,0 +1,127 @@ +<!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="Source to the Rust file `src/callback.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>callback.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10">10</span> +<span id="11">11</span> +<span id="12">12</span> +<span id="13">13</span> +<span id="14">14</span> +<span id="15">15</span> +</pre><pre class='rust '> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Callback</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Sized</span><span class='op'>></span> { + <span class='ident'>items</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='kw'>fn</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>A</span>)<span class='op'>></span> +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>A</span>: <span class='ident'>Sized</span><span class='op'>></span> <span class='ident'>Callback</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>() <span class='op'>-></span> <span class='ident'>Callback</span><span class='op'><</span><span class='ident'>A</span><span class='op'>></span> { + <span class='ident'>Callback</span> { <span class='ident'>items</span>: <span class='ident'>Vec</span>::<span class='ident'>new</span>() } + } + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>register</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw'>fn</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>A</span>)) { + <span class='self'>self</span>.<span class='ident'>items</span>.<span class='ident'>push</span>(<span class='ident'>f</span>) + } + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fire</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>v</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>A</span>) { + <span class='kw'>for</span> _ <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>items</span>.<span class='ident'>iter</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span>(<span class='ident'>v</span>)) {} + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "irsc"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/irsc/client.rs.html b/src/irsc/client.rs.html new file mode 100644 index 0000000..4b8adc5 --- /dev/null +++ b/src/irsc/client.rs.html @@ -0,0 +1,657 @@ +<!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="Source to the Rust file `src/client.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>client.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>::{ + <span class='self'>self</span>, + <span class='ident'>Write</span>, + <span class='ident'>Read</span>, + <span class='ident'>BufRead</span>, + <span class='ident'>BufReader</span>, +}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>net</span>::<span class='ident'>TcpStream</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>borrow</span>::<span class='ident'>Cow</span>::{ <span class='self'>self</span>, <span class='ident'>Borrowed</span>, <span class='ident'>Owned</span> }; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>sync</span>::{ <span class='ident'>Arc</span>, <span class='ident'>RwLock</span> }; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>mem</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>cell</span>::<span class='ident'>UnsafeCell</span>; + +<span class='kw'>use</span> <span class='ident'>carboxyl</span>::{ <span class='ident'>Stream</span>, <span class='ident'>Sink</span> }; + +<span class='kw'>use</span> <span class='ident'>message</span>::<span class='ident'>Message</span>; +<span class='kw'>use</span> <span class='ident'>command</span>::<span class='ident'>Command</span>; +<span class='kw'>use</span> <span class='ident'>command</span>::<span class='ident'>Command</span>::<span class='op'>*</span>; +<span class='kw'>use</span> <span class='ident'>reply</span>::<span class='ident'>Reply</span>; +<span class='kw'>use</span> <span class='ident'>event</span>::<span class='ident'>Event</span>; +<span class='kw'>use</span> ::{ <span class='ident'>DEBUG</span>, <span class='prelude-ty'>Result</span>, <span class='ident'>IrscError</span> }; + +<span class='kw'>use</span> <span class='ident'>openssl</span>::<span class='ident'>ssl</span>::{ <span class='ident'>Ssl</span>, <span class='ident'>SslContext</span>, <span class='ident'>SslMethod</span>, <span class='ident'>SslStream</span> }; + +<span class='doccomment'>/// Yes, I don't like the name either, but it's private, so...</span> +<span class='kw'>enum</span> <span class='ident'>StreamKind</span> { + <span class='ident'>Plain</span>(<span class='ident'>TcpStream</span>), + <span class='ident'>Ssl</span>(<span class='ident'>SslStream</span><span class='op'><</span><span class='ident'>TcpStream</span><span class='op'>></span>) +} + +<span class='kw'>impl</span> <span class='ident'>Write</span> <span class='kw'>for</span> <span class='ident'>StreamKind</span> { + <span class='kw'>fn</span> <span class='ident'>write</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>buf</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>StreamKind</span>::<span class='ident'>Plain</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>s</span>.<span class='ident'>write</span>(<span class='ident'>buf</span>), + <span class='ident'>StreamKind</span>::<span class='ident'>Ssl</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>s</span>.<span class='ident'>write</span>(<span class='ident'>buf</span>) + } + } + + <span class='kw'>fn</span> <span class='ident'>flush</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>StreamKind</span>::<span class='ident'>Plain</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>s</span>.<span class='ident'>flush</span>(), + <span class='ident'>StreamKind</span>::<span class='ident'>Ssl</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>s</span>.<span class='ident'>flush</span>() + } + } +} + +<span class='kw'>impl</span> <span class='ident'>Read</span> <span class='kw'>for</span> <span class='ident'>StreamKind</span> { + <span class='kw'>fn</span> <span class='ident'>read</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>buf</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> [<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>StreamKind</span>::<span class='ident'>Plain</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>s</span>.<span class='ident'>read</span>(<span class='ident'>buf</span>), + <span class='ident'>StreamKind</span>::<span class='ident'>Ssl</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>s</span>.<span class='ident'>read</span>(<span class='ident'>buf</span>) + } + } +} + +<span class='kw'>pub</span> <span class='kw'>trait</span> <span class='ident'>Client</span> { + <span class='kw'>fn</span> <span class='ident'>send_message</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>msg</span>: <span class='ident'>Message</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span>; + <span class='kw'>fn</span> <span class='ident'>join</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>channel</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>password</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='ident'>str</span><span class='op'>></span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>send_message</span>(<span class='ident'>JOIN</span>(<span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>channel</span>.<span class='ident'>into</span>()], <span class='ident'>password</span>.<span class='ident'>iter</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>p</span><span class='op'>|</span> <span class='ident'>p</span>.<span class='ident'>into</span>()).<span class='ident'>collect</span>()).<span class='ident'>to_message</span>()) + } + + <span class='kw'>fn</span> <span class='ident'>msg</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>to</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>message</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>send_message</span>(<span class='ident'>PRIVMSG</span>(<span class='ident'>to</span>.<span class='ident'>into</span>(), <span class='ident'>message</span>.<span class='ident'>into</span>()).<span class='ident'>to_message</span>()) + } + + <span class='kw'>fn</span> <span class='ident'>msg_many</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>to</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>message</span>: <span class='kw-2'>&</span>[<span class='kw-2'>&</span><span class='ident'>str</span>]) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='kw'>for</span> <span class='ident'>m</span> <span class='kw'>in</span> <span class='ident'>message</span> { + <span class='self'>self</span>.<span class='ident'>msg</span>(<span class='ident'>to</span>, <span class='ident'>m</span>); + } + <span class='prelude-ty'>Result</span>(<span class='prelude-val'>Ok</span>(())) + } + + <span class='kw'>fn</span> <span class='ident'>msg_word_wrap</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>to</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>message</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>limit</span>: <span class='ident'>u16</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>line</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>new</span>(); + <span class='kw'>for</span> <span class='ident'>word</span> <span class='kw'>in</span> <span class='ident'>message</span>.<span class='ident'>split_whitespace</span>() { + <span class='kw'>if</span> <span class='ident'>line</span>.<span class='ident'>len</span>() <span class='op'>+</span> <span class='ident'>word</span>.<span class='ident'>len</span>() <span class='op'><</span> <span class='ident'>limit</span> <span class='kw'>as</span> <span class='ident'>usize</span> { + <span class='ident'>line</span>.<span class='ident'>push_str</span>(<span class='string'>" "</span>); + <span class='ident'>line</span>.<span class='ident'>push_str</span>(<span class='ident'>word</span>); + } <span class='kw'>else</span> { + <span class='macro'>debug</span><span class='macro'>!</span>(<span class='string'>"Sending {}"</span>, <span class='ident'>line</span>); + <span class='self'>self</span>.<span class='ident'>msg</span>(<span class='ident'>to</span>, <span class='kw-2'>&</span><span class='ident'>line</span>); + <span class='ident'>line</span>.<span class='ident'>clear</span>(); + } + } + <span class='self'>self</span>.<span class='ident'>msg</span>(<span class='ident'>to</span>, <span class='kw-2'>&</span><span class='ident'>line</span>) + } + + <span class='kw'>fn</span> <span class='ident'>register</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>nick</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>user</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>desc</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>pass</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='ident'>str</span><span class='op'>></span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='prelude-ty'>Result</span>(<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>pass</span>) <span class='op'>=</span> <span class='ident'>pass</span> { + <span class='self'>self</span>.<span class='ident'>send_message</span>(<span class='ident'>PASS</span>(<span class='ident'>pass</span>.<span class='ident'>into</span>()).<span class='ident'>to_message</span>()).<span class='ident'>inner</span>() + } <span class='kw'>else</span> { <span class='prelude-val'>Ok</span>(()) } + .<span class='ident'>and_then</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='self'>self</span>.<span class='ident'>send_message</span>(<span class='ident'>NICK</span>(<span class='ident'>nick</span>.<span class='ident'>into</span>()).<span class='ident'>to_message</span>()).<span class='ident'>inner</span>()) + .<span class='ident'>and_then</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='self'>self</span>.<span class='ident'>send_message</span>(<span class='ident'>USER</span>(<span class='ident'>user</span>.<span class='ident'>into</span>(), <span class='ident'>Borrowed</span>(<span class='string'>"0"</span>), <span class='ident'>Borrowed</span>(<span class='string'>"*"</span>), <span class='ident'>desc</span>.<span class='ident'>into</span>()).<span class='ident'>to_message</span>()).<span class='ident'>inner</span>()) + ) + } + +} + +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>OwnedClient</span> { + <span class='ident'>stream</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>StreamKind</span><span class='op'>></span>, + <span class='ident'>sink</span>: <span class='ident'>Sink</span><span class='op'><</span><span class='ident'>Message</span><span class='op'>></span> +} + +<span class='kw'>impl</span> <span class='ident'>OwnedClient</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>() <span class='op'>-></span> <span class='ident'>OwnedClient</span> { + <span class='ident'>OwnedClient</span> { + <span class='ident'>stream</span>: <span class='prelude-val'>None</span>, + <span class='ident'>sink</span>: <span class='ident'>Sink</span>::<span class='ident'>new</span>() + } + } + + <span class='kw'>fn</span> <span class='ident'>handle_event</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>msg</span>: <span class='kw-2'>&</span><span class='ident'>Message</span>) { + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>Command</span>::<span class='ident'>from_message</span>(<span class='ident'>msg</span>) { + <span class='prelude-val'>Some</span>(<span class='ident'>PING</span>(<span class='ident'>s1</span>, <span class='ident'>s2</span>)) <span class='op'>=></span> <span class='self'>self</span>.<span class='ident'>send</span>(<span class='ident'>PONG</span>(<span class='ident'>s1</span>, <span class='ident'>s2</span>)), + _ <span class='op'>=></span> <span class='prelude-ty'>Result</span>(<span class='prelude-val'>Ok</span>(())) + }; + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>connect</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>host</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>port</span>: <span class='ident'>u16</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>stream</span>; + <span class='kw'>if</span> <span class='ident'>s</span>.<span class='ident'>is_some</span>() { <span class='kw'>return</span> <span class='prelude-ty'>Result</span>(<span class='prelude-val'>Err</span>(<span class='ident'>IrscError</span>::<span class='ident'>AlreadyConnected</span>)) } + <span class='op'>*</span><span class='ident'>s</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>TcpStream</span>::<span class='ident'>connect</span>((<span class='ident'>host</span>, <span class='ident'>port</span>)) { + <span class='prelude-val'>Ok</span>(<span class='ident'>tcp</span>) <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>StreamKind</span>::<span class='ident'>Plain</span>(<span class='ident'>tcp</span>)), + <span class='prelude-val'>Err</span>(<span class='ident'>e</span>) <span class='op'>=></span> <span class='kw'>return</span> <span class='prelude-ty'>Result</span>(<span class='prelude-val'>Err</span>(<span class='ident'>IrscError</span>::<span class='ident'>Io</span>(<span class='ident'>e</span>))) + }; + + <span class='prelude-ty'>Result</span>(<span class='prelude-val'>Ok</span>(())) + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>connect_ssl</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>host</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>port</span>: <span class='ident'>u16</span>, <span class='ident'>ssl</span>: <span class='ident'>Ssl</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>stream</span>; + <span class='kw'>if</span> <span class='ident'>s</span>.<span class='ident'>is_some</span>() { <span class='kw'>return</span> <span class='prelude-ty'>Result</span>(<span class='prelude-val'>Err</span>(<span class='ident'>IrscError</span>::<span class='ident'>AlreadyConnected</span>)) }; + <span class='kw'>let</span> <span class='ident'>tcp_stream</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>TcpStream</span>::<span class='ident'>connect</span>((<span class='ident'>host</span>, <span class='ident'>port</span>)) { + <span class='prelude-val'>Ok</span>(<span class='ident'>tcp</span>) <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>tcp</span>), + <span class='prelude-val'>Err</span>(<span class='ident'>e</span>) <span class='op'>=></span> <span class='kw'>return</span> <span class='prelude-ty'>Result</span>(<span class='prelude-val'>Err</span>(<span class='ident'>IrscError</span>::<span class='ident'>Io</span>(<span class='ident'>e</span>))) + }; + + <span class='kw'>match</span> <span class='ident'>tcp_stream</span>.<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>tcp</span><span class='op'>|</span> <span class='ident'>SslStream</span>::<span class='ident'>new_from</span>(<span class='ident'>ssl</span>, <span class='ident'>tcp</span>)) { + <span class='prelude-val'>Some</span>(<span class='prelude-val'>Ok</span>(<span class='ident'>ssl_stream</span>)) <span class='op'>=></span> { + <span class='op'>*</span><span class='ident'>s</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>StreamKind</span>::<span class='ident'>Ssl</span>(<span class='ident'>ssl_stream</span>)); + <span class='prelude-ty'>Result</span>(<span class='prelude-val'>Ok</span>(())) + }, + <span class='prelude-val'>Some</span>(<span class='prelude-val'>Err</span>(<span class='ident'>ssl_error</span>)) <span class='op'>=></span> <span class='prelude-ty'>Result</span>(<span class='prelude-val'>Err</span>(<span class='ident'>IrscError</span>::<span class='ident'>Ssl</span>(<span class='ident'>ssl_error</span>))), + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='prelude-ty'>Result</span>(<span class='prelude-val'>Err</span>(<span class='ident'>IrscError</span>::<span class='ident'>NotConnected</span>)) + } + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>send_raw</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='macro'>info</span><span class='macro'>!</span>(<span class='string'>">> {}"</span>, <span class='ident'>s</span>); + <span class='kw'>if</span> <span class='ident'>DEBUG</span> <span class='op'>&&</span> <span class='ident'>s</span>.<span class='ident'>len</span>() <span class='op'>></span> <span class='number'>512</span> { + <span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>"Message too long, kittens will die if this runs in release mode. Msg: {}"</span>, <span class='ident'>s</span>) + } + + <span class='prelude-ty'>Result</span>(<span class='self'>self</span>.<span class='ident'>stream</span>.<span class='ident'>as_mut</span>() + .<span class='ident'>ok_or</span>(<span class='ident'>IrscError</span>::<span class='ident'>NotConnected</span>) + .<span class='ident'>and_then</span>(<span class='op'>|</span><span class='kw-2'>mut</span> <span class='ident'>stream</span><span class='op'>|</span> <span class='ident'>stream</span>.<span class='ident'>write_all</span>(<span class='ident'>s</span>.<span class='ident'>as_bytes</span>()) + .<span class='ident'>and_then</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='ident'>stream</span>.<span class='ident'>flush</span>()) + .<span class='ident'>map_err</span>(<span class='ident'>IrscError</span>::<span class='ident'>Io</span>))) + } + + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>send</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>cmd</span>: <span class='ident'>Command</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>send_message</span>(<span class='ident'>cmd</span>.<span class='ident'>to_message</span>()) + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>listen_with_callback</span><span class='op'><</span><span class='ident'>F</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>on_event</span>: <span class='ident'>F</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>F</span>: <span class='ident'>Fn</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Client</span>, <span class='kw-2'>&</span><span class='ident'>Message</span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Event</span><span class='op'>></span>) { + <span class='kw'>let</span> <span class='ident'>reader</span> <span class='op'>=</span> <span class='ident'>BufReader</span>::<span class='ident'>new</span>(<span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>stream</span> { + <span class='prelude-val'>Some</span>(<span class='ident'>StreamKind</span>::<span class='ident'>Plain</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>)) <span class='op'>=></span> <span class='ident'>StreamKind</span>::<span class='ident'>Plain</span>((<span class='op'>*</span><span class='ident'>s</span>).<span class='ident'>try_clone</span>().<span class='ident'>unwrap</span>()), + <span class='prelude-val'>Some</span>(<span class='ident'>StreamKind</span>::<span class='ident'>Ssl</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>)) <span class='op'>=></span> <span class='ident'>StreamKind</span>::<span class='ident'>Ssl</span>((<span class='op'>*</span><span class='ident'>s</span>).<span class='ident'>try_clone</span>().<span class='ident'>unwrap</span>()), + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='kw'>return</span> <span class='prelude-ty'>Result</span>(<span class='prelude-val'>Err</span>(<span class='ident'>IrscError</span>::<span class='ident'>NotConnected</span>)) + }); + + <span class='kw'>for</span> <span class='ident'>raw_line</span> <span class='kw'>in</span> <span class='ident'>reader</span>.<span class='ident'>lines</span>() { + <span class='kw'>let</span> <span class='ident'>line</span> <span class='op'>=</span> <span class='ident'>raw_line</span>.<span class='ident'>as_ref</span>().<span class='ident'>unwrap</span>().<span class='ident'>parse</span>(); + <span class='macro'>info</span><span class='macro'>!</span>(<span class='string'>"<< {}"</span>, <span class='ident'>raw_line</span>.<span class='ident'>unwrap</span>()); + + <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Ok</span>(<span class='ident'>msg</span>) <span class='op'>=</span> <span class='ident'>line</span> { + <span class='self'>self</span>.<span class='ident'>handle_event</span>(<span class='kw-2'>&</span><span class='ident'>msg</span>); + + <span class='comment'>// Try to parse the message into a Command or a Reply, and call back.</span> + <span class='kw'>let</span> <span class='ident'>event</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>Command</span>::<span class='ident'>from_message</span>(<span class='kw-2'>&</span><span class='ident'>msg</span>) { + <span class='prelude-val'>Some</span>(<span class='ident'>m</span>) <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>Event</span>::<span class='ident'>Command</span>(<span class='ident'>m</span>)), + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='kw'>match</span> <span class='ident'>Reply</span>::<span class='ident'>from_message</span>(<span class='kw-2'>&</span><span class='ident'>msg</span>) { + <span class='prelude-val'>Some</span>(<span class='ident'>r</span>) <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>Event</span>::<span class='ident'>Reply</span>(<span class='ident'>r</span>)), + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='prelude-val'>None</span> + } + }; + <span class='ident'>on_event</span>(<span class='self'>self</span>, <span class='kw-2'>&</span><span class='ident'>msg</span>, <span class='ident'>event</span>); + } + } + <span class='prelude-ty'>Result</span>(<span class='prelude-val'>Ok</span>(())) + } + + <span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>mutable_transmutes</span>)]</span> + <span class='kw'>fn</span> <span class='ident'>listen_with_events</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>OwnedClient</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='self'>self</span>) }; + <span class='kw'>let</span> <span class='ident'>reader</span> <span class='op'>=</span> <span class='ident'>BufReader</span>::<span class='ident'>new</span>(<span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>stream</span> { + <span class='prelude-val'>Some</span>(<span class='ident'>StreamKind</span>::<span class='ident'>Plain</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>)) <span class='op'>=></span> <span class='ident'>StreamKind</span>::<span class='ident'>Plain</span>((<span class='op'>*</span><span class='ident'>s</span>).<span class='ident'>try_clone</span>().<span class='ident'>unwrap</span>()), + <span class='prelude-val'>Some</span>(<span class='ident'>StreamKind</span>::<span class='ident'>Ssl</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>)) <span class='op'>=></span> <span class='ident'>StreamKind</span>::<span class='ident'>Ssl</span>((<span class='op'>*</span><span class='ident'>s</span>).<span class='ident'>try_clone</span>().<span class='ident'>unwrap</span>()), + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='kw'>return</span> <span class='prelude-ty'>Result</span>(<span class='prelude-val'>Err</span>(<span class='ident'>IrscError</span>::<span class='ident'>NotConnected</span>)) + }); + + <span class='kw'>for</span> <span class='ident'>raw_line</span> <span class='kw'>in</span> <span class='ident'>reader</span>.<span class='ident'>lines</span>() { + <span class='kw'>let</span> <span class='ident'>line</span> <span class='op'>=</span> <span class='ident'>raw_line</span>.<span class='ident'>as_ref</span>().<span class='ident'>unwrap</span>().<span class='ident'>parse</span>(); + <span class='macro'>info</span><span class='macro'>!</span>(<span class='string'>"<< {}"</span>, <span class='ident'>raw_line</span>.<span class='ident'>unwrap</span>()); + + <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Ok</span>(<span class='ident'>msg</span>) <span class='op'>=</span> <span class='ident'>line</span> { + <span class='ident'>s</span>.<span class='ident'>handle_event</span>(<span class='kw-2'>&</span><span class='ident'>msg</span>); + <span class='self'>self</span>.<span class='ident'>sink</span>.<span class='ident'>send</span>(<span class='ident'>msg</span>); + } + } + <span class='prelude-ty'>Result</span>(<span class='prelude-val'>Ok</span>(())) + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>into_shared</span>(<span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>SharedClient</span> { + <span class='ident'>SharedClient</span> { + <span class='ident'>client</span>: <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>OwnedClientCell</span>(<span class='ident'>UnsafeCell</span>::<span class='ident'>new</span>(<span class='self'>self</span>))), + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>messages</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span><span class='ident'>Message</span><span class='op'>></span> { <span class='self'>self</span>.<span class='ident'>sink</span>.<span class='ident'>stream</span>() } +} + +<span class='kw'>struct</span> <span class='ident'>OwnedClientCell</span>(<span class='ident'>UnsafeCell</span><span class='op'><</span><span class='ident'>OwnedClient</span><span class='op'>></span>); +<span class='kw'>unsafe</span> <span class='kw'>impl</span> <span class='ident'>Sync</span> <span class='kw'>for</span> <span class='ident'>OwnedClientCell</span> {} + +<span class='kw'>impl</span> <span class='ident'>Client</span> <span class='kw'>for</span> <span class='ident'>OwnedClient</span> { + <span class='kw'>fn</span> <span class='ident'>send_message</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>msg</span>: <span class='ident'>Message</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>send_raw</span>(<span class='kw-2'>&</span><span class='ident'>msg</span>.<span class='ident'>to_string</span>()) + } +} + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>SharedClient</span> { + <span class='ident'>client</span>: <span class='ident'>Arc</span><span class='op'><</span><span class='ident'>OwnedClientCell</span><span class='op'>></span>, +} + +<span class='kw'>impl</span> <span class='ident'>SharedClient</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>messages</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span>(<span class='ident'>SharedClient</span>, <span class='ident'>Message</span>)<span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>cl</span> <span class='op'>=</span> <span class='ident'>SharedClient</span> { <span class='ident'>client</span>: <span class='self'>self</span>.<span class='ident'>client</span>.<span class='ident'>clone</span>() }; + <span class='kw'>unsafe</span> { <span class='kw-2'>&</span><span class='op'>*</span><span class='self'>self</span>.<span class='ident'>client</span>.<span class='number'>0</span>.<span class='ident'>get</span>() }.<span class='ident'>messages</span>() + .<span class='ident'>map</span>(<span class='kw'>move</span> <span class='op'>|</span><span class='ident'>m</span><span class='op'>|</span> (<span class='ident'>cl</span>.<span class='ident'>clone</span>(), <span class='ident'>m</span>)) + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>events</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span>(<span class='ident'>SharedClient</span>, <span class='ident'>Message</span>, <span class='ident'>Event</span><span class='op'><</span><span class='lifetime'>'static</span><span class='op'>></span>)<span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>messages</span>().<span class='ident'>filter_map</span>(<span class='op'>|</span>(<span class='ident'>cl</span>, <span class='ident'>msg</span>)<span class='op'>|</span> <span class='kw'>match</span> <span class='ident'>Command</span>::<span class='ident'>from_message</span>(<span class='kw-2'>&</span><span class='ident'>msg</span>) { + <span class='prelude-val'>Some</span>(<span class='ident'>m</span>) <span class='op'>=></span> <span class='prelude-val'>Some</span>((<span class='ident'>cl</span>, <span class='ident'>msg</span>.<span class='ident'>clone</span>(), <span class='ident'>Event</span>::<span class='ident'>Command</span>(<span class='ident'>m</span>.<span class='ident'>clone</span>()).<span class='ident'>to_static</span>())), + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='kw'>match</span> <span class='ident'>Reply</span>::<span class='ident'>from_message</span>(<span class='kw-2'>&</span><span class='ident'>msg</span>) { + <span class='prelude-val'>Some</span>(<span class='ident'>r</span>) <span class='op'>=></span> <span class='prelude-val'>Some</span>((<span class='ident'>cl</span>, <span class='ident'>msg</span>.<span class='ident'>clone</span>(), <span class='ident'>Event</span>::<span class='ident'>Reply</span>(<span class='ident'>r</span>).<span class='ident'>to_static</span>())), + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='prelude-val'>None</span> + } + }) + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>listen_with_events</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='kw'>unsafe</span> { <span class='kw-2'>&</span><span class='op'>*</span><span class='self'>self</span>.<span class='ident'>client</span>.<span class='number'>0</span>.<span class='ident'>get</span>() }.<span class='ident'>listen_with_events</span>() + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>commands</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span>(<span class='ident'>SharedClient</span>, <span class='ident'>Message</span>, <span class='ident'>Command</span><span class='op'><</span><span class='lifetime'>'static</span><span class='op'>></span>)<span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>messages</span>().<span class='ident'>filter_map</span>(<span class='op'>|</span>(<span class='ident'>cl</span>, <span class='ident'>msg</span>)<span class='op'>|</span> <span class='kw'>match</span> <span class='ident'>Command</span>::<span class='ident'>from_message</span>(<span class='kw-2'>&</span><span class='ident'>msg</span>) { + <span class='prelude-val'>Some</span>(<span class='ident'>m</span>) <span class='op'>=></span> <span class='prelude-val'>Some</span>((<span class='ident'>cl</span>, <span class='ident'>msg</span>.<span class='ident'>clone</span>(), <span class='ident'>m</span>.<span class='ident'>to_static</span>())), + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='prelude-val'>None</span> + }) + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>replies</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Stream</span><span class='op'><</span>(<span class='ident'>SharedClient</span>, <span class='ident'>Message</span>, <span class='ident'>Reply</span><span class='op'><</span><span class='lifetime'>'static</span><span class='op'>></span>)<span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>messages</span>().<span class='ident'>filter_map</span>(<span class='op'>|</span>(<span class='ident'>cl</span>, <span class='ident'>msg</span>)<span class='op'>|</span> <span class='kw'>match</span> <span class='ident'>Reply</span>::<span class='ident'>from_message</span>(<span class='kw-2'>&</span><span class='ident'>msg</span>) { + <span class='prelude-val'>Some</span>(<span class='ident'>m</span>) <span class='op'>=></span> <span class='prelude-val'>Some</span>((<span class='ident'>cl</span>, <span class='ident'>msg</span>.<span class='ident'>clone</span>(), <span class='ident'>m</span>.<span class='ident'>to_static</span>())), + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='prelude-val'>None</span> + }) + } +} + +<span class='kw'>impl</span> <span class='ident'>Client</span> <span class='kw'>for</span> <span class='ident'>SharedClient</span> { + <span class='kw'>fn</span> <span class='ident'>send_message</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>msg</span>: <span class='ident'>Message</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='kw'>unsafe</span> { <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='self'>self</span>.<span class='ident'>client</span>.<span class='number'>0</span>.<span class='ident'>get</span>() }.<span class='ident'>send_raw</span>(<span class='kw-2'>&</span><span class='ident'>msg</span>.<span class='ident'>to_string</span>()) + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "irsc"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/irsc/color.rs.html b/src/irsc/color.rs.html new file mode 100644 index 0000000..de361f2 --- /dev/null +++ b/src/irsc/color.rs.html @@ -0,0 +1,189 @@ +<!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="Source to the Rust file `src/color.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>color.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10">10</span> +<span id="11">11</span> +<span id="12">12</span> +<span id="13">13</span> +<span id="14">14</span> +<span id="15">15</span> +<span id="16">16</span> +<span id="17">17</span> +<span id="18">18</span> +<span id="19">19</span> +<span id="20">20</span> +<span id="21">21</span> +<span id="22">22</span> +<span id="23">23</span> +<span id="24">24</span> +<span id="25">25</span> +<span id="26">26</span> +<span id="27">27</span> +<span id="28">28</span> +<span id="29">29</span> +<span id="30">30</span> +<span id="31">31</span> +<span id="32">32</span> +<span id="33">33</span> +<span id="34">34</span> +<span id="35">35</span> +<span id="36">36</span> +<span id="37">37</span> +<span id="38">38</span> +<span id="39">39</span> +<span id="40">40</span> +<span id="41">41</span> +<span id="42">42</span> +<span id="43">43</span> +<span id="44">44</span> +<span id="45">45</span> +<span id="46">46</span> +</pre><pre class='rust '> +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WHITE</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"00"</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>BLACK</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"01"</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>BLUE</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"02"</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GREEN</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"03"</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RED</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"04"</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>BROWN</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"05"</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PURPLE</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"06"</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ORANGE</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"07"</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>YELLOW</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"08"</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>LIME</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"09"</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TEAL</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"10"</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>LIGHT_CYAN</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"11"</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>LIGHT_BLUE</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"12"</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PINK</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"13"</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GREY</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"14"</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>LIGHT_GREY</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"15"</span>; + +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TRANSPARENT</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>"99"</span>; + +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>normal</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"\x0F{}\x0F"</span>, <span class='ident'>s</span>) +} + +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>bold</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"\x02{}\x02"</span>, <span class='ident'>s</span>) +} + +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>italic</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"\x1D{}\x1D"</span>, <span class='ident'>s</span>) +} + +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>underline</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"\x1F{}\x1F"</span>, <span class='ident'>s</span>) +} + +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>foreground</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>foreground</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"\x03{}{}\x03"</span>, <span class='ident'>foreground</span>, <span class='ident'>s</span>) +} + +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>background</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>background</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"\x03,{}{}\x03"</span>, <span class='ident'>background</span>, <span class='ident'>s</span>) +} + +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>color</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>foreground</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>background</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"\x03{},{}{}\x03"</span>, <span class='ident'>foreground</span>, <span class='ident'>background</span>, <span class='ident'>s</span>) +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "irsc"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/irsc/command.rs.html b/src/irsc/command.rs.html new file mode 100644 index 0000000..37fc316 --- /dev/null +++ b/src/irsc/command.rs.html @@ -0,0 +1,3997 @@ +<!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="Source to the Rust file `src/command.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>command.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100"> 100</span> +<span id="101"> 101</span> +<span id="102"> 102</span> +<span id="103"> 103</span> +<span id="104"> 104</span> +<span id="105"> 105</span> +<span id="106"> 106</span> +<span id="107"> 107</span> +<span id="108"> 108</span> +<span id="109"> 109</span> +<span id="110"> 110</span> +<span id="111"> 111</span> +<span id="112"> 112</span> +<span id="113"> 113</span> +<span id="114"> 114</span> +<span id="115"> 115</span> +<span id="116"> 116</span> +<span id="117"> 117</span> +<span id="118"> 118</span> +<span id="119"> 119</span> +<span id="120"> 120</span> +<span id="121"> 121</span> +<span id="122"> 122</span> +<span id="123"> 123</span> +<span id="124"> 124</span> +<span id="125"> 125</span> +<span id="126"> 126</span> +<span id="127"> 127</span> +<span id="128"> 128</span> +<span id="129"> 129</span> +<span id="130"> 130</span> +<span id="131"> 131</span> +<span id="132"> 132</span> +<span id="133"> 133</span> +<span id="134"> 134</span> +<span id="135"> 135</span> +<span id="136"> 136</span> +<span id="137"> 137</span> +<span id="138"> 138</span> +<span id="139"> 139</span> +<span id="140"> 140</span> +<span id="141"> 141</span> +<span id="142"> 142</span> +<span id="143"> 143</span> +<span id="144"> 144</span> +<span id="145"> 145</span> +<span id="146"> 146</span> +<span id="147"> 147</span> +<span id="148"> 148</span> +<span id="149"> 149</span> +<span id="150"> 150</span> +<span id="151"> 151</span> +<span id="152"> 152</span> +<span id="153"> 153</span> +<span id="154"> 154</span> +<span id="155"> 155</span> +<span id="156"> 156</span> +<span id="157"> 157</span> +<span id="158"> 158</span> +<span id="159"> 159</span> +<span id="160"> 160</span> +<span id="161"> 161</span> +<span id="162"> 162</span> +<span id="163"> 163</span> +<span id="164"> 164</span> +<span id="165"> 165</span> +<span id="166"> 166</span> +<span id="167"> 167</span> +<span id="168"> 168</span> +<span id="169"> 169</span> +<span id="170"> 170</span> +<span id="171"> 171</span> +<span id="172"> 172</span> +<span id="173"> 173</span> +<span id="174"> 174</span> +<span id="175"> 175</span> +<span id="176"> 176</span> +<span id="177"> 177</span> +<span id="178"> 178</span> +<span id="179"> 179</span> +<span id="180"> 180</span> +<span id="181"> 181</span> +<span id="182"> 182</span> +<span id="183"> 183</span> +<span id="184"> 184</span> +<span id="185"> 185</span> +<span id="186"> 186</span> +<span id="187"> 187</span> +<span id="188"> 188</span> +<span id="189"> 189</span> +<span id="190"> 190</span> +<span id="191"> 191</span> +<span id="192"> 192</span> +<span id="193"> 193</span> +<span id="194"> 194</span> +<span id="195"> 195</span> +<span id="196"> 196</span> +<span id="197"> 197</span> +<span id="198"> 198</span> +<span id="199"> 199</span> +<span id="200"> 200</span> +<span id="201"> 201</span> +<span id="202"> 202</span> +<span id="203"> 203</span> +<span id="204"> 204</span> +<span id="205"> 205</span> +<span id="206"> 206</span> +<span id="207"> 207</span> +<span id="208"> 208</span> +<span id="209"> 209</span> +<span id="210"> 210</span> +<span id="211"> 211</span> +<span id="212"> 212</span> +<span id="213"> 213</span> +<span id="214"> 214</span> +<span id="215"> 215</span> +<span id="216"> 216</span> +<span id="217"> 217</span> +<span id="218"> 218</span> +<span id="219"> 219</span> +<span id="220"> 220</span> +<span id="221"> 221</span> +<span id="222"> 222</span> +<span id="223"> 223</span> +<span id="224"> 224</span> +<span id="225"> 225</span> +<span id="226"> 226</span> +<span id="227"> 227</span> +<span id="228"> 228</span> +<span id="229"> 229</span> +<span id="230"> 230</span> +<span id="231"> 231</span> +<span id="232"> 232</span> +<span id="233"> 233</span> +<span id="234"> 234</span> +<span id="235"> 235</span> +<span id="236"> 236</span> +<span id="237"> 237</span> +<span id="238"> 238</span> +<span id="239"> 239</span> +<span id="240"> 240</span> +<span id="241"> 241</span> +<span id="242"> 242</span> +<span id="243"> 243</span> +<span id="244"> 244</span> +<span id="245"> 245</span> +<span id="246"> 246</span> +<span id="247"> 247</span> +<span id="248"> 248</span> +<span id="249"> 249</span> +<span id="250"> 250</span> +<span id="251"> 251</span> +<span id="252"> 252</span> +<span id="253"> 253</span> +<span id="254"> 254</span> +<span id="255"> 255</span> +<span id="256"> 256</span> +<span id="257"> 257</span> +<span id="258"> 258</span> +<span id="259"> 259</span> +<span id="260"> 260</span> +<span id="261"> 261</span> +<span id="262"> 262</span> +<span id="263"> 263</span> +<span id="264"> 264</span> +<span id="265"> 265</span> +<span id="266"> 266</span> +<span id="267"> 267</span> +<span id="268"> 268</span> +<span id="269"> 269</span> +<span id="270"> 270</span> +<span id="271"> 271</span> +<span id="272"> 272</span> +<span id="273"> 273</span> +<span id="274"> 274</span> +<span id="275"> 275</span> +<span id="276"> 276</span> +<span id="277"> 277</span> +<span id="278"> 278</span> +<span id="279"> 279</span> +<span id="280"> 280</span> +<span id="281"> 281</span> +<span id="282"> 282</span> +<span id="283"> 283</span> +<span id="284"> 284</span> +<span id="285"> 285</span> +<span id="286"> 286</span> +<span id="287"> 287</span> +<span id="288"> 288</span> +<span id="289"> 289</span> +<span id="290"> 290</span> +<span id="291"> 291</span> +<span id="292"> 292</span> +<span id="293"> 293</span> +<span id="294"> 294</span> +<span id="295"> 295</span> +<span id="296"> 296</span> +<span id="297"> 297</span> +<span id="298"> 298</span> +<span id="299"> 299</span> +<span id="300"> 300</span> +<span id="301"> 301</span> +<span id="302"> 302</span> +<span id="303"> 303</span> +<span id="304"> 304</span> +<span id="305"> 305</span> +<span id="306"> 306</span> +<span id="307"> 307</span> +<span id="308"> 308</span> +<span id="309"> 309</span> +<span id="310"> 310</span> +<span id="311"> 311</span> +<span id="312"> 312</span> +<span id="313"> 313</span> +<span id="314"> 314</span> +<span id="315"> 315</span> +<span id="316"> 316</span> +<span id="317"> 317</span> +<span id="318"> 318</span> +<span id="319"> 319</span> +<span id="320"> 320</span> +<span id="321"> 321</span> +<span id="322"> 322</span> +<span id="323"> 323</span> +<span id="324"> 324</span> +<span id="325"> 325</span> +<span id="326"> 326</span> +<span id="327"> 327</span> +<span id="328"> 328</span> +<span id="329"> 329</span> +<span id="330"> 330</span> +<span id="331"> 331</span> +<span id="332"> 332</span> +<span id="333"> 333</span> +<span id="334"> 334</span> +<span id="335"> 335</span> +<span id="336"> 336</span> +<span id="337"> 337</span> +<span id="338"> 338</span> +<span id="339"> 339</span> +<span id="340"> 340</span> +<span id="341"> 341</span> +<span id="342"> 342</span> +<span id="343"> 343</span> +<span id="344"> 344</span> +<span id="345"> 345</span> +<span id="346"> 346</span> +<span id="347"> 347</span> +<span id="348"> 348</span> +<span id="349"> 349</span> +<span id="350"> 350</span> +<span id="351"> 351</span> +<span id="352"> 352</span> +<span id="353"> 353</span> +<span id="354"> 354</span> +<span id="355"> 355</span> +<span id="356"> 356</span> +<span id="357"> 357</span> +<span id="358"> 358</span> +<span id="359"> 359</span> +<span id="360"> 360</span> +<span id="361"> 361</span> +<span id="362"> 362</span> +<span id="363"> 363</span> +<span id="364"> 364</span> +<span id="365"> 365</span> +<span id="366"> 366</span> +<span id="367"> 367</span> +<span id="368"> 368</span> +<span id="369"> 369</span> +<span id="370"> 370</span> +<span id="371"> 371</span> +<span id="372"> 372</span> +<span id="373"> 373</span> +<span id="374"> 374</span> +<span id="375"> 375</span> +<span id="376"> 376</span> +<span id="377"> 377</span> +<span id="378"> 378</span> +<span id="379"> 379</span> +<span id="380"> 380</span> +<span id="381"> 381</span> +<span id="382"> 382</span> +<span id="383"> 383</span> +<span id="384"> 384</span> +<span id="385"> 385</span> +<span id="386"> 386</span> +<span id="387"> 387</span> +<span id="388"> 388</span> +<span id="389"> 389</span> +<span id="390"> 390</span> +<span id="391"> 391</span> +<span id="392"> 392</span> +<span id="393"> 393</span> +<span id="394"> 394</span> +<span id="395"> 395</span> +<span id="396"> 396</span> +<span id="397"> 397</span> +<span id="398"> 398</span> +<span id="399"> 399</span> +<span id="400"> 400</span> +<span id="401"> 401</span> +<span id="402"> 402</span> +<span id="403"> 403</span> +<span id="404"> 404</span> +<span id="405"> 405</span> +<span id="406"> 406</span> +<span id="407"> 407</span> +<span id="408"> 408</span> +<span id="409"> 409</span> +<span id="410"> 410</span> +<span id="411"> 411</span> +<span id="412"> 412</span> +<span id="413"> 413</span> +<span id="414"> 414</span> +<span id="415"> 415</span> +<span id="416"> 416</span> +<span id="417"> 417</span> +<span id="418"> 418</span> +<span id="419"> 419</span> +<span id="420"> 420</span> +<span id="421"> 421</span> +<span id="422"> 422</span> +<span id="423"> 423</span> +<span id="424"> 424</span> +<span id="425"> 425</span> +<span id="426"> 426</span> +<span id="427"> 427</span> +<span id="428"> 428</span> +<span id="429"> 429</span> +<span id="430"> 430</span> +<span id="431"> 431</span> +<span id="432"> 432</span> +<span id="433"> 433</span> +<span id="434"> 434</span> +<span id="435"> 435</span> +<span id="436"> 436</span> +<span id="437"> 437</span> +<span id="438"> 438</span> +<span id="439"> 439</span> +<span id="440"> 440</span> +<span id="441"> 441</span> +<span id="442"> 442</span> +<span id="443"> 443</span> +<span id="444"> 444</span> +<span id="445"> 445</span> +<span id="446"> 446</span> +<span id="447"> 447</span> +<span id="448"> 448</span> +<span id="449"> 449</span> +<span id="450"> 450</span> +<span id="451"> 451</span> +<span id="452"> 452</span> +<span id="453"> 453</span> +<span id="454"> 454</span> +<span id="455"> 455</span> +<span id="456"> 456</span> +<span id="457"> 457</span> +<span id="458"> 458</span> +<span id="459"> 459</span> +<span id="460"> 460</span> +<span id="461"> 461</span> +<span id="462"> 462</span> +<span id="463"> 463</span> +<span id="464"> 464</span> +<span id="465"> 465</span> +<span id="466"> 466</span> +<span id="467"> 467</span> +<span id="468"> 468</span> +<span id="469"> 469</span> +<span id="470"> 470</span> +<span id="471"> 471</span> +<span id="472"> 472</span> +<span id="473"> 473</span> +<span id="474"> 474</span> +<span id="475"> 475</span> +<span id="476"> 476</span> +<span id="477"> 477</span> +<span id="478"> 478</span> +<span id="479"> 479</span> +<span id="480"> 480</span> +<span id="481"> 481</span> +<span id="482"> 482</span> +<span id="483"> 483</span> +<span id="484"> 484</span> +<span id="485"> 485</span> +<span id="486"> 486</span> +<span id="487"> 487</span> +<span id="488"> 488</span> +<span id="489"> 489</span> +<span id="490"> 490</span> +<span id="491"> 491</span> +<span id="492"> 492</span> +<span id="493"> 493</span> +<span id="494"> 494</span> +<span id="495"> 495</span> +<span id="496"> 496</span> +<span id="497"> 497</span> +<span id="498"> 498</span> +<span id="499"> 499</span> +<span id="500"> 500</span> +<span id="501"> 501</span> +<span id="502"> 502</span> +<span id="503"> 503</span> +<span id="504"> 504</span> +<span id="505"> 505</span> +<span id="506"> 506</span> +<span id="507"> 507</span> +<span id="508"> 508</span> +<span id="509"> 509</span> +<span id="510"> 510</span> +<span id="511"> 511</span> +<span id="512"> 512</span> +<span id="513"> 513</span> +<span id="514"> 514</span> +<span id="515"> 515</span> +<span id="516"> 516</span> +<span id="517"> 517</span> +<span id="518"> 518</span> +<span id="519"> 519</span> +<span id="520"> 520</span> +<span id="521"> 521</span> +<span id="522"> 522</span> +<span id="523"> 523</span> +<span id="524"> 524</span> +<span id="525"> 525</span> +<span id="526"> 526</span> +<span id="527"> 527</span> +<span id="528"> 528</span> +<span id="529"> 529</span> +<span id="530"> 530</span> +<span id="531"> 531</span> +<span id="532"> 532</span> +<span id="533"> 533</span> +<span id="534"> 534</span> +<span id="535"> 535</span> +<span id="536"> 536</span> +<span id="537"> 537</span> +<span id="538"> 538</span> +<span id="539"> 539</span> +<span id="540"> 540</span> +<span id="541"> 541</span> +<span id="542"> 542</span> +<span id="543"> 543</span> +<span id="544"> 544</span> +<span id="545"> 545</span> +<span id="546"> 546</span> +<span id="547"> 547</span> +<span id="548"> 548</span> +<span id="549"> 549</span> +<span id="550"> 550</span> +<span id="551"> 551</span> +<span id="552"> 552</span> +<span id="553"> 553</span> +<span id="554"> 554</span> +<span id="555"> 555</span> +<span id="556"> 556</span> +<span id="557"> 557</span> +<span id="558"> 558</span> +<span id="559"> 559</span> +<span id="560"> 560</span> +<span id="561"> 561</span> +<span id="562"> 562</span> +<span id="563"> 563</span> +<span id="564"> 564</span> +<span id="565"> 565</span> +<span id="566"> 566</span> +<span id="567"> 567</span> +<span id="568"> 568</span> +<span id="569"> 569</span> +<span id="570"> 570</span> +<span id="571"> 571</span> +<span id="572"> 572</span> +<span id="573"> 573</span> +<span id="574"> 574</span> +<span id="575"> 575</span> +<span id="576"> 576</span> +<span id="577"> 577</span> +<span id="578"> 578</span> +<span id="579"> 579</span> +<span id="580"> 580</span> +<span id="581"> 581</span> +<span id="582"> 582</span> +<span id="583"> 583</span> +<span id="584"> 584</span> +<span id="585"> 585</span> +<span id="586"> 586</span> +<span id="587"> 587</span> +<span id="588"> 588</span> +<span id="589"> 589</span> +<span id="590"> 590</span> +<span id="591"> 591</span> +<span id="592"> 592</span> +<span id="593"> 593</span> +<span id="594"> 594</span> +<span id="595"> 595</span> +<span id="596"> 596</span> +<span id="597"> 597</span> +<span id="598"> 598</span> +<span id="599"> 599</span> +<span id="600"> 600</span> +<span id="601"> 601</span> +<span id="602"> 602</span> +<span id="603"> 603</span> +<span id="604"> 604</span> +<span id="605"> 605</span> +<span id="606"> 606</span> +<span id="607"> 607</span> +<span id="608"> 608</span> +<span id="609"> 609</span> +<span id="610"> 610</span> +<span id="611"> 611</span> +<span id="612"> 612</span> +<span id="613"> 613</span> +<span id="614"> 614</span> +<span id="615"> 615</span> +<span id="616"> 616</span> +<span id="617"> 617</span> +<span id="618"> 618</span> +<span id="619"> 619</span> +<span id="620"> 620</span> +<span id="621"> 621</span> +<span id="622"> 622</span> +<span id="623"> 623</span> +<span id="624"> 624</span> +<span id="625"> 625</span> +<span id="626"> 626</span> +<span id="627"> 627</span> +<span id="628"> 628</span> +<span id="629"> 629</span> +<span id="630"> 630</span> +<span id="631"> 631</span> +<span id="632"> 632</span> +<span id="633"> 633</span> +<span id="634"> 634</span> +<span id="635"> 635</span> +<span id="636"> 636</span> +<span id="637"> 637</span> +<span id="638"> 638</span> +<span id="639"> 639</span> +<span id="640"> 640</span> +<span id="641"> 641</span> +<span id="642"> 642</span> +<span id="643"> 643</span> +<span id="644"> 644</span> +<span id="645"> 645</span> +<span id="646"> 646</span> +<span id="647"> 647</span> +<span id="648"> 648</span> +<span id="649"> 649</span> +<span id="650"> 650</span> +<span id="651"> 651</span> +<span id="652"> 652</span> +<span id="653"> 653</span> +<span id="654"> 654</span> +<span id="655"> 655</span> +<span id="656"> 656</span> +<span id="657"> 657</span> +<span id="658"> 658</span> +<span id="659"> 659</span> +<span id="660"> 660</span> +<span id="661"> 661</span> +<span id="662"> 662</span> +<span id="663"> 663</span> +<span id="664"> 664</span> +<span id="665"> 665</span> +<span id="666"> 666</span> +<span id="667"> 667</span> +<span id="668"> 668</span> +<span id="669"> 669</span> +<span id="670"> 670</span> +<span id="671"> 671</span> +<span id="672"> 672</span> +<span id="673"> 673</span> +<span id="674"> 674</span> +<span id="675"> 675</span> +<span id="676"> 676</span> +<span id="677"> 677</span> +<span id="678"> 678</span> +<span id="679"> 679</span> +<span id="680"> 680</span> +<span id="681"> 681</span> +<span id="682"> 682</span> +<span id="683"> 683</span> +<span id="684"> 684</span> +<span id="685"> 685</span> +<span id="686"> 686</span> +<span id="687"> 687</span> +<span id="688"> 688</span> +<span id="689"> 689</span> +<span id="690"> 690</span> +<span id="691"> 691</span> +<span id="692"> 692</span> +<span id="693"> 693</span> +<span id="694"> 694</span> +<span id="695"> 695</span> +<span id="696"> 696</span> +<span id="697"> 697</span> +<span id="698"> 698</span> +<span id="699"> 699</span> +<span id="700"> 700</span> +<span id="701"> 701</span> +<span id="702"> 702</span> +<span id="703"> 703</span> +<span id="704"> 704</span> +<span id="705"> 705</span> +<span id="706"> 706</span> +<span id="707"> 707</span> +<span id="708"> 708</span> +<span id="709"> 709</span> +<span id="710"> 710</span> +<span id="711"> 711</span> +<span id="712"> 712</span> +<span id="713"> 713</span> +<span id="714"> 714</span> +<span id="715"> 715</span> +<span id="716"> 716</span> +<span id="717"> 717</span> +<span id="718"> 718</span> +<span id="719"> 719</span> +<span id="720"> 720</span> +<span id="721"> 721</span> +<span id="722"> 722</span> +<span id="723"> 723</span> +<span id="724"> 724</span> +<span id="725"> 725</span> +<span id="726"> 726</span> +<span id="727"> 727</span> +<span id="728"> 728</span> +<span id="729"> 729</span> +<span id="730"> 730</span> +<span id="731"> 731</span> +<span id="732"> 732</span> +<span id="733"> 733</span> +<span id="734"> 734</span> +<span id="735"> 735</span> +<span id="736"> 736</span> +<span id="737"> 737</span> +<span id="738"> 738</span> +<span id="739"> 739</span> +<span id="740"> 740</span> +<span id="741"> 741</span> +<span id="742"> 742</span> +<span id="743"> 743</span> +<span id="744"> 744</span> +<span id="745"> 745</span> +<span id="746"> 746</span> +<span id="747"> 747</span> +<span id="748"> 748</span> +<span id="749"> 749</span> +<span id="750"> 750</span> +<span id="751"> 751</span> +<span id="752"> 752</span> +<span id="753"> 753</span> +<span id="754"> 754</span> +<span id="755"> 755</span> +<span id="756"> 756</span> +<span id="757"> 757</span> +<span id="758"> 758</span> +<span id="759"> 759</span> +<span id="760"> 760</span> +<span id="761"> 761</span> +<span id="762"> 762</span> +<span id="763"> 763</span> +<span id="764"> 764</span> +<span id="765"> 765</span> +<span id="766"> 766</span> +<span id="767"> 767</span> +<span id="768"> 768</span> +<span id="769"> 769</span> +<span id="770"> 770</span> +<span id="771"> 771</span> +<span id="772"> 772</span> +<span id="773"> 773</span> +<span id="774"> 774</span> +<span id="775"> 775</span> +<span id="776"> 776</span> +<span id="777"> 777</span> +<span id="778"> 778</span> +<span id="779"> 779</span> +<span id="780"> 780</span> +<span id="781"> 781</span> +<span id="782"> 782</span> +<span id="783"> 783</span> +<span id="784"> 784</span> +<span id="785"> 785</span> +<span id="786"> 786</span> +<span id="787"> 787</span> +<span id="788"> 788</span> +<span id="789"> 789</span> +<span id="790"> 790</span> +<span id="791"> 791</span> +<span id="792"> 792</span> +<span id="793"> 793</span> +<span id="794"> 794</span> +<span id="795"> 795</span> +<span id="796"> 796</span> +<span id="797"> 797</span> +<span id="798"> 798</span> +<span id="799"> 799</span> +<span id="800"> 800</span> +<span id="801"> 801</span> +<span id="802"> 802</span> +<span id="803"> 803</span> +<span id="804"> 804</span> +<span id="805"> 805</span> +<span id="806"> 806</span> +<span id="807"> 807</span> +<span id="808"> 808</span> +<span id="809"> 809</span> +<span id="810"> 810</span> +<span id="811"> 811</span> +<span id="812"> 812</span> +<span id="813"> 813</span> +<span id="814"> 814</span> +<span id="815"> 815</span> +<span id="816"> 816</span> +<span id="817"> 817</span> +<span id="818"> 818</span> +<span id="819"> 819</span> +<span id="820"> 820</span> +<span id="821"> 821</span> +<span id="822"> 822</span> +<span id="823"> 823</span> +<span id="824"> 824</span> +<span id="825"> 825</span> +<span id="826"> 826</span> +<span id="827"> 827</span> +<span id="828"> 828</span> +<span id="829"> 829</span> +<span id="830"> 830</span> +<span id="831"> 831</span> +<span id="832"> 832</span> +<span id="833"> 833</span> +<span id="834"> 834</span> +<span id="835"> 835</span> +<span id="836"> 836</span> +<span id="837"> 837</span> +<span id="838"> 838</span> +<span id="839"> 839</span> +<span id="840"> 840</span> +<span id="841"> 841</span> +<span id="842"> 842</span> +<span id="843"> 843</span> +<span id="844"> 844</span> +<span id="845"> 845</span> +<span id="846"> 846</span> +<span id="847"> 847</span> +<span id="848"> 848</span> +<span id="849"> 849</span> +<span id="850"> 850</span> +<span id="851"> 851</span> +<span id="852"> 852</span> +<span id="853"> 853</span> +<span id="854"> 854</span> +<span id="855"> 855</span> +<span id="856"> 856</span> +<span id="857"> 857</span> +<span id="858"> 858</span> +<span id="859"> 859</span> +<span id="860"> 860</span> +<span id="861"> 861</span> +<span id="862"> 862</span> +<span id="863"> 863</span> +<span id="864"> 864</span> +<span id="865"> 865</span> +<span id="866"> 866</span> +<span id="867"> 867</span> +<span id="868"> 868</span> +<span id="869"> 869</span> +<span id="870"> 870</span> +<span id="871"> 871</span> +<span id="872"> 872</span> +<span id="873"> 873</span> +<span id="874"> 874</span> +<span id="875"> 875</span> +<span id="876"> 876</span> +<span id="877"> 877</span> +<span id="878"> 878</span> +<span id="879"> 879</span> +<span id="880"> 880</span> +<span id="881"> 881</span> +<span id="882"> 882</span> +<span id="883"> 883</span> +<span id="884"> 884</span> +<span id="885"> 885</span> +<span id="886"> 886</span> +<span id="887"> 887</span> +<span id="888"> 888</span> +<span id="889"> 889</span> +<span id="890"> 890</span> +<span id="891"> 891</span> +<span id="892"> 892</span> +<span id="893"> 893</span> +<span id="894"> 894</span> +<span id="895"> 895</span> +<span id="896"> 896</span> +<span id="897"> 897</span> +<span id="898"> 898</span> +<span id="899"> 899</span> +<span id="900"> 900</span> +<span id="901"> 901</span> +<span id="902"> 902</span> +<span id="903"> 903</span> +<span id="904"> 904</span> +<span id="905"> 905</span> +<span id="906"> 906</span> +<span id="907"> 907</span> +<span id="908"> 908</span> +<span id="909"> 909</span> +<span id="910"> 910</span> +<span id="911"> 911</span> +<span id="912"> 912</span> +<span id="913"> 913</span> +<span id="914"> 914</span> +<span id="915"> 915</span> +<span id="916"> 916</span> +<span id="917"> 917</span> +<span id="918"> 918</span> +<span id="919"> 919</span> +<span id="920"> 920</span> +<span id="921"> 921</span> +<span id="922"> 922</span> +<span id="923"> 923</span> +<span id="924"> 924</span> +<span id="925"> 925</span> +<span id="926"> 926</span> +<span id="927"> 927</span> +<span id="928"> 928</span> +<span id="929"> 929</span> +<span id="930"> 930</span> +<span id="931"> 931</span> +<span id="932"> 932</span> +<span id="933"> 933</span> +<span id="934"> 934</span> +<span id="935"> 935</span> +<span id="936"> 936</span> +<span id="937"> 937</span> +<span id="938"> 938</span> +<span id="939"> 939</span> +<span id="940"> 940</span> +<span id="941"> 941</span> +<span id="942"> 942</span> +<span id="943"> 943</span> +<span id="944"> 944</span> +<span id="945"> 945</span> +<span id="946"> 946</span> +<span id="947"> 947</span> +<span id="948"> 948</span> +<span id="949"> 949</span> +<span id="950"> 950</span> +<span id="951"> 951</span> +<span id="952"> 952</span> +<span id="953"> 953</span> +<span id="954"> 954</span> +<span id="955"> 955</span> +<span id="956"> 956</span> +<span id="957"> 957</span> +<span id="958"> 958</span> +<span id="959"> 959</span> +<span id="960"> 960</span> +<span id="961"> 961</span> +<span id="962"> 962</span> +<span id="963"> 963</span> +<span id="964"> 964</span> +<span id="965"> 965</span> +<span id="966"> 966</span> +<span id="967"> 967</span> +<span id="968"> 968</span> +<span id="969"> 969</span> +<span id="970"> 970</span> +<span id="971"> 971</span> +<span id="972"> 972</span> +<span id="973"> 973</span> +<span id="974"> 974</span> +<span id="975"> 975</span> +<span id="976"> 976</span> +<span id="977"> 977</span> +<span id="978"> 978</span> +<span id="979"> 979</span> +<span id="980"> 980</span> +<span id="981"> 981</span> +<span id="982"> 982</span> +<span id="983"> 983</span> +<span id="984"> 984</span> +<span id="985"> 985</span> +<span id="986"> 986</span> +<span id="987"> 987</span> +<span id="988"> 988</span> +<span id="989"> 989</span> +<span id="990"> 990</span> +<span id="991"> 991</span> +<span id="992"> 992</span> +<span id="993"> 993</span> +<span id="994"> 994</span> +<span id="995"> 995</span> +<span id="996"> 996</span> +<span id="997"> 997</span> +<span id="998"> 998</span> +<span id="999"> 999</span> +<span id="1000">1000</span> +<span id="1001">1001</span> +<span id="1002">1002</span> +<span id="1003">1003</span> +<span id="1004">1004</span> +<span id="1005">1005</span> +<span id="1006">1006</span> +<span id="1007">1007</span> +<span id="1008">1008</span> +<span id="1009">1009</span> +<span id="1010">1010</span> +<span id="1011">1011</span> +<span id="1012">1012</span> +<span id="1013">1013</span> +<span id="1014">1014</span> +<span id="1015">1015</span> +<span id="1016">1016</span> +<span id="1017">1017</span> +<span id="1018">1018</span> +<span id="1019">1019</span> +<span id="1020">1020</span> +<span id="1021">1021</span> +<span id="1022">1022</span> +<span id="1023">1023</span> +<span id="1024">1024</span> +<span id="1025">1025</span> +<span id="1026">1026</span> +<span id="1027">1027</span> +<span id="1028">1028</span> +<span id="1029">1029</span> +<span id="1030">1030</span> +<span id="1031">1031</span> +<span id="1032">1032</span> +<span id="1033">1033</span> +<span id="1034">1034</span> +<span id="1035">1035</span> +<span id="1036">1036</span> +<span id="1037">1037</span> +<span id="1038">1038</span> +<span id="1039">1039</span> +<span id="1040">1040</span> +<span id="1041">1041</span> +<span id="1042">1042</span> +<span id="1043">1043</span> +<span id="1044">1044</span> +<span id="1045">1045</span> +<span id="1046">1046</span> +<span id="1047">1047</span> +<span id="1048">1048</span> +<span id="1049">1049</span> +<span id="1050">1050</span> +<span id="1051">1051</span> +<span id="1052">1052</span> +<span id="1053">1053</span> +<span id="1054">1054</span> +<span id="1055">1055</span> +<span id="1056">1056</span> +<span id="1057">1057</span> +<span id="1058">1058</span> +<span id="1059">1059</span> +<span id="1060">1060</span> +<span id="1061">1061</span> +<span id="1062">1062</span> +<span id="1063">1063</span> +<span id="1064">1064</span> +<span id="1065">1065</span> +<span id="1066">1066</span> +<span id="1067">1067</span> +<span id="1068">1068</span> +<span id="1069">1069</span> +<span id="1070">1070</span> +<span id="1071">1071</span> +<span id="1072">1072</span> +<span id="1073">1073</span> +<span id="1074">1074</span> +<span id="1075">1075</span> +<span id="1076">1076</span> +<span id="1077">1077</span> +<span id="1078">1078</span> +<span id="1079">1079</span> +<span id="1080">1080</span> +<span id="1081">1081</span> +<span id="1082">1082</span> +<span id="1083">1083</span> +<span id="1084">1084</span> +<span id="1085">1085</span> +<span id="1086">1086</span> +<span id="1087">1087</span> +<span id="1088">1088</span> +<span id="1089">1089</span> +<span id="1090">1090</span> +<span id="1091">1091</span> +<span id="1092">1092</span> +<span id="1093">1093</span> +<span id="1094">1094</span> +<span id="1095">1095</span> +<span id="1096">1096</span> +<span id="1097">1097</span> +<span id="1098">1098</span> +<span id="1099">1099</span> +<span id="1100">1100</span> +<span id="1101">1101</span> +<span id="1102">1102</span> +<span id="1103">1103</span> +<span id="1104">1104</span> +<span id="1105">1105</span> +<span id="1106">1106</span> +<span id="1107">1107</span> +<span id="1108">1108</span> +<span id="1109">1109</span> +<span id="1110">1110</span> +<span id="1111">1111</span> +<span id="1112">1112</span> +<span id="1113">1113</span> +<span id="1114">1114</span> +<span id="1115">1115</span> +<span id="1116">1116</span> +<span id="1117">1117</span> +<span id="1118">1118</span> +<span id="1119">1119</span> +<span id="1120">1120</span> +<span id="1121">1121</span> +<span id="1122">1122</span> +<span id="1123">1123</span> +<span id="1124">1124</span> +<span id="1125">1125</span> +<span id="1126">1126</span> +<span id="1127">1127</span> +<span id="1128">1128</span> +<span id="1129">1129</span> +<span id="1130">1130</span> +<span id="1131">1131</span> +<span id="1132">1132</span> +<span id="1133">1133</span> +<span id="1134">1134</span> +<span id="1135">1135</span> +<span id="1136">1136</span> +<span id="1137">1137</span> +<span id="1138">1138</span> +<span id="1139">1139</span> +<span id="1140">1140</span> +<span id="1141">1141</span> +<span id="1142">1142</span> +<span id="1143">1143</span> +<span id="1144">1144</span> +<span id="1145">1145</span> +<span id="1146">1146</span> +<span id="1147">1147</span> +<span id="1148">1148</span> +<span id="1149">1149</span> +<span id="1150">1150</span> +<span id="1151">1151</span> +<span id="1152">1152</span> +<span id="1153">1153</span> +<span id="1154">1154</span> +<span id="1155">1155</span> +<span id="1156">1156</span> +<span id="1157">1157</span> +<span id="1158">1158</span> +<span id="1159">1159</span> +<span id="1160">1160</span> +<span id="1161">1161</span> +<span id="1162">1162</span> +<span id="1163">1163</span> +<span id="1164">1164</span> +<span id="1165">1165</span> +<span id="1166">1166</span> +<span id="1167">1167</span> +<span id="1168">1168</span> +<span id="1169">1169</span> +<span id="1170">1170</span> +<span id="1171">1171</span> +<span id="1172">1172</span> +<span id="1173">1173</span> +<span id="1174">1174</span> +<span id="1175">1175</span> +<span id="1176">1176</span> +<span id="1177">1177</span> +<span id="1178">1178</span> +<span id="1179">1179</span> +<span id="1180">1180</span> +<span id="1181">1181</span> +<span id="1182">1182</span> +<span id="1183">1183</span> +<span id="1184">1184</span> +<span id="1185">1185</span> +<span id="1186">1186</span> +<span id="1187">1187</span> +<span id="1188">1188</span> +<span id="1189">1189</span> +<span id="1190">1190</span> +<span id="1191">1191</span> +<span id="1192">1192</span> +<span id="1193">1193</span> +<span id="1194">1194</span> +<span id="1195">1195</span> +<span id="1196">1196</span> +<span id="1197">1197</span> +<span id="1198">1198</span> +<span id="1199">1199</span> +<span id="1200">1200</span> +<span id="1201">1201</span> +<span id="1202">1202</span> +<span id="1203">1203</span> +<span id="1204">1204</span> +<span id="1205">1205</span> +<span id="1206">1206</span> +<span id="1207">1207</span> +<span id="1208">1208</span> +<span id="1209">1209</span> +<span id="1210">1210</span> +<span id="1211">1211</span> +<span id="1212">1212</span> +<span id="1213">1213</span> +<span id="1214">1214</span> +<span id="1215">1215</span> +<span id="1216">1216</span> +<span id="1217">1217</span> +<span id="1218">1218</span> +<span id="1219">1219</span> +<span id="1220">1220</span> +<span id="1221">1221</span> +<span id="1222">1222</span> +<span id="1223">1223</span> +<span id="1224">1224</span> +<span id="1225">1225</span> +<span id="1226">1226</span> +<span id="1227">1227</span> +<span id="1228">1228</span> +<span id="1229">1229</span> +<span id="1230">1230</span> +<span id="1231">1231</span> +<span id="1232">1232</span> +<span id="1233">1233</span> +<span id="1234">1234</span> +<span id="1235">1235</span> +<span id="1236">1236</span> +<span id="1237">1237</span> +<span id="1238">1238</span> +<span id="1239">1239</span> +<span id="1240">1240</span> +<span id="1241">1241</span> +<span id="1242">1242</span> +<span id="1243">1243</span> +<span id="1244">1244</span> +<span id="1245">1245</span> +<span id="1246">1246</span> +<span id="1247">1247</span> +<span id="1248">1248</span> +<span id="1249">1249</span> +<span id="1250">1250</span> +<span id="1251">1251</span> +<span id="1252">1252</span> +<span id="1253">1253</span> +<span id="1254">1254</span> +<span id="1255">1255</span> +<span id="1256">1256</span> +<span id="1257">1257</span> +<span id="1258">1258</span> +<span id="1259">1259</span> +<span id="1260">1260</span> +<span id="1261">1261</span> +<span id="1262">1262</span> +<span id="1263">1263</span> +<span id="1264">1264</span> +<span id="1265">1265</span> +<span id="1266">1266</span> +<span id="1267">1267</span> +<span id="1268">1268</span> +<span id="1269">1269</span> +<span id="1270">1270</span> +<span id="1271">1271</span> +<span id="1272">1272</span> +<span id="1273">1273</span> +<span id="1274">1274</span> +<span id="1275">1275</span> +<span id="1276">1276</span> +<span id="1277">1277</span> +<span id="1278">1278</span> +<span id="1279">1279</span> +<span id="1280">1280</span> +<span id="1281">1281</span> +<span id="1282">1282</span> +<span id="1283">1283</span> +<span id="1284">1284</span> +<span id="1285">1285</span> +<span id="1286">1286</span> +<span id="1287">1287</span> +<span id="1288">1288</span> +<span id="1289">1289</span> +<span id="1290">1290</span> +<span id="1291">1291</span> +<span id="1292">1292</span> +<span id="1293">1293</span> +<span id="1294">1294</span> +<span id="1295">1295</span> +<span id="1296">1296</span> +<span id="1297">1297</span> +<span id="1298">1298</span> +<span id="1299">1299</span> +<span id="1300">1300</span> +<span id="1301">1301</span> +<span id="1302">1302</span> +<span id="1303">1303</span> +<span id="1304">1304</span> +<span id="1305">1305</span> +<span id="1306">1306</span> +<span id="1307">1307</span> +<span id="1308">1308</span> +<span id="1309">1309</span> +<span id="1310">1310</span> +<span id="1311">1311</span> +<span id="1312">1312</span> +<span id="1313">1313</span> +<span id="1314">1314</span> +<span id="1315">1315</span> +<span id="1316">1316</span> +<span id="1317">1317</span> +<span id="1318">1318</span> +<span id="1319">1319</span> +<span id="1320">1320</span> +<span id="1321">1321</span> +<span id="1322">1322</span> +<span id="1323">1323</span> +<span id="1324">1324</span> +<span id="1325">1325</span> +<span id="1326">1326</span> +<span id="1327">1327</span> +<span id="1328">1328</span> +<span id="1329">1329</span> +<span id="1330">1330</span> +<span id="1331">1331</span> +<span id="1332">1332</span> +<span id="1333">1333</span> +<span id="1334">1334</span> +<span id="1335">1335</span> +<span id="1336">1336</span> +<span id="1337">1337</span> +<span id="1338">1338</span> +<span id="1339">1339</span> +<span id="1340">1340</span> +<span id="1341">1341</span> +<span id="1342">1342</span> +<span id="1343">1343</span> +<span id="1344">1344</span> +<span id="1345">1345</span> +<span id="1346">1346</span> +<span id="1347">1347</span> +<span id="1348">1348</span> +<span id="1349">1349</span> +<span id="1350">1350</span> +<span id="1351">1351</span> +<span id="1352">1352</span> +<span id="1353">1353</span> +<span id="1354">1354</span> +<span id="1355">1355</span> +<span id="1356">1356</span> +<span id="1357">1357</span> +<span id="1358">1358</span> +<span id="1359">1359</span> +<span id="1360">1360</span> +<span id="1361">1361</span> +<span id="1362">1362</span> +<span id="1363">1363</span> +<span id="1364">1364</span> +<span id="1365">1365</span> +<span id="1366">1366</span> +<span id="1367">1367</span> +<span id="1368">1368</span> +<span id="1369">1369</span> +<span id="1370">1370</span> +<span id="1371">1371</span> +<span id="1372">1372</span> +<span id="1373">1373</span> +<span id="1374">1374</span> +<span id="1375">1375</span> +<span id="1376">1376</span> +<span id="1377">1377</span> +<span id="1378">1378</span> +<span id="1379">1379</span> +<span id="1380">1380</span> +<span id="1381">1381</span> +<span id="1382">1382</span> +<span id="1383">1383</span> +<span id="1384">1384</span> +<span id="1385">1385</span> +<span id="1386">1386</span> +<span id="1387">1387</span> +<span id="1388">1388</span> +<span id="1389">1389</span> +<span id="1390">1390</span> +<span id="1391">1391</span> +<span id="1392">1392</span> +<span id="1393">1393</span> +<span id="1394">1394</span> +<span id="1395">1395</span> +<span id="1396">1396</span> +<span id="1397">1397</span> +<span id="1398">1398</span> +<span id="1399">1399</span> +<span id="1400">1400</span> +<span id="1401">1401</span> +<span id="1402">1402</span> +<span id="1403">1403</span> +<span id="1404">1404</span> +<span id="1405">1405</span> +<span id="1406">1406</span> +<span id="1407">1407</span> +<span id="1408">1408</span> +<span id="1409">1409</span> +<span id="1410">1410</span> +<span id="1411">1411</span> +<span id="1412">1412</span> +<span id="1413">1413</span> +<span id="1414">1414</span> +<span id="1415">1415</span> +<span id="1416">1416</span> +<span id="1417">1417</span> +<span id="1418">1418</span> +<span id="1419">1419</span> +<span id="1420">1420</span> +<span id="1421">1421</span> +<span id="1422">1422</span> +<span id="1423">1423</span> +<span id="1424">1424</span> +<span id="1425">1425</span> +<span id="1426">1426</span> +<span id="1427">1427</span> +<span id="1428">1428</span> +<span id="1429">1429</span> +<span id="1430">1430</span> +<span id="1431">1431</span> +<span id="1432">1432</span> +<span id="1433">1433</span> +<span id="1434">1434</span> +<span id="1435">1435</span> +<span id="1436">1436</span> +<span id="1437">1437</span> +<span id="1438">1438</span> +<span id="1439">1439</span> +<span id="1440">1440</span> +<span id="1441">1441</span> +<span id="1442">1442</span> +<span id="1443">1443</span> +<span id="1444">1444</span> +<span id="1445">1445</span> +<span id="1446">1446</span> +<span id="1447">1447</span> +<span id="1448">1448</span> +<span id="1449">1449</span> +<span id="1450">1450</span> +<span id="1451">1451</span> +<span id="1452">1452</span> +<span id="1453">1453</span> +<span id="1454">1454</span> +<span id="1455">1455</span> +<span id="1456">1456</span> +<span id="1457">1457</span> +<span id="1458">1458</span> +<span id="1459">1459</span> +<span id="1460">1460</span> +<span id="1461">1461</span> +<span id="1462">1462</span> +<span id="1463">1463</span> +<span id="1464">1464</span> +<span id="1465">1465</span> +<span id="1466">1466</span> +<span id="1467">1467</span> +<span id="1468">1468</span> +<span id="1469">1469</span> +<span id="1470">1470</span> +<span id="1471">1471</span> +<span id="1472">1472</span> +<span id="1473">1473</span> +<span id="1474">1474</span> +<span id="1475">1475</span> +<span id="1476">1476</span> +<span id="1477">1477</span> +<span id="1478">1478</span> +<span id="1479">1479</span> +<span id="1480">1480</span> +<span id="1481">1481</span> +<span id="1482">1482</span> +<span id="1483">1483</span> +<span id="1484">1484</span> +<span id="1485">1485</span> +<span id="1486">1486</span> +<span id="1487">1487</span> +<span id="1488">1488</span> +<span id="1489">1489</span> +<span id="1490">1490</span> +<span id="1491">1491</span> +<span id="1492">1492</span> +<span id="1493">1493</span> +<span id="1494">1494</span> +<span id="1495">1495</span> +<span id="1496">1496</span> +<span id="1497">1497</span> +<span id="1498">1498</span> +<span id="1499">1499</span> +<span id="1500">1500</span> +<span id="1501">1501</span> +<span id="1502">1502</span> +<span id="1503">1503</span> +<span id="1504">1504</span> +<span id="1505">1505</span> +<span id="1506">1506</span> +<span id="1507">1507</span> +<span id="1508">1508</span> +<span id="1509">1509</span> +<span id="1510">1510</span> +<span id="1511">1511</span> +<span id="1512">1512</span> +<span id="1513">1513</span> +<span id="1514">1514</span> +<span id="1515">1515</span> +<span id="1516">1516</span> +<span id="1517">1517</span> +<span id="1518">1518</span> +<span id="1519">1519</span> +<span id="1520">1520</span> +<span id="1521">1521</span> +<span id="1522">1522</span> +<span id="1523">1523</span> +<span id="1524">1524</span> +<span id="1525">1525</span> +<span id="1526">1526</span> +<span id="1527">1527</span> +<span id="1528">1528</span> +<span id="1529">1529</span> +<span id="1530">1530</span> +<span id="1531">1531</span> +<span id="1532">1532</span> +<span id="1533">1533</span> +<span id="1534">1534</span> +<span id="1535">1535</span> +<span id="1536">1536</span> +<span id="1537">1537</span> +<span id="1538">1538</span> +<span id="1539">1539</span> +<span id="1540">1540</span> +<span id="1541">1541</span> +<span id="1542">1542</span> +<span id="1543">1543</span> +<span id="1544">1544</span> +<span id="1545">1545</span> +<span id="1546">1546</span> +<span id="1547">1547</span> +<span id="1548">1548</span> +<span id="1549">1549</span> +<span id="1550">1550</span> +<span id="1551">1551</span> +<span id="1552">1552</span> +<span id="1553">1553</span> +<span id="1554">1554</span> +<span id="1555">1555</span> +<span id="1556">1556</span> +<span id="1557">1557</span> +<span id="1558">1558</span> +<span id="1559">1559</span> +<span id="1560">1560</span> +<span id="1561">1561</span> +<span id="1562">1562</span> +<span id="1563">1563</span> +<span id="1564">1564</span> +<span id="1565">1565</span> +<span id="1566">1566</span> +<span id="1567">1567</span> +<span id="1568">1568</span> +<span id="1569">1569</span> +<span id="1570">1570</span> +<span id="1571">1571</span> +<span id="1572">1572</span> +<span id="1573">1573</span> +<span id="1574">1574</span> +<span id="1575">1575</span> +<span id="1576">1576</span> +<span id="1577">1577</span> +<span id="1578">1578</span> +<span id="1579">1579</span> +<span id="1580">1580</span> +<span id="1581">1581</span> +<span id="1582">1582</span> +<span id="1583">1583</span> +<span id="1584">1584</span> +<span id="1585">1585</span> +<span id="1586">1586</span> +<span id="1587">1587</span> +<span id="1588">1588</span> +<span id="1589">1589</span> +<span id="1590">1590</span> +<span id="1591">1591</span> +<span id="1592">1592</span> +<span id="1593">1593</span> +<span id="1594">1594</span> +<span id="1595">1595</span> +<span id="1596">1596</span> +<span id="1597">1597</span> +<span id="1598">1598</span> +<span id="1599">1599</span> +<span id="1600">1600</span> +<span id="1601">1601</span> +<span id="1602">1602</span> +<span id="1603">1603</span> +<span id="1604">1604</span> +<span id="1605">1605</span> +<span id="1606">1606</span> +<span id="1607">1607</span> +<span id="1608">1608</span> +<span id="1609">1609</span> +<span id="1610">1610</span> +<span id="1611">1611</span> +<span id="1612">1612</span> +<span id="1613">1613</span> +<span id="1614">1614</span> +<span id="1615">1615</span> +<span id="1616">1616</span> +<span id="1617">1617</span> +<span id="1618">1618</span> +<span id="1619">1619</span> +<span id="1620">1620</span> +<span id="1621">1621</span> +<span id="1622">1622</span> +<span id="1623">1623</span> +<span id="1624">1624</span> +<span id="1625">1625</span> +<span id="1626">1626</span> +<span id="1627">1627</span> +<span id="1628">1628</span> +<span id="1629">1629</span> +<span id="1630">1630</span> +<span id="1631">1631</span> +<span id="1632">1632</span> +<span id="1633">1633</span> +<span id="1634">1634</span> +<span id="1635">1635</span> +<span id="1636">1636</span> +<span id="1637">1637</span> +<span id="1638">1638</span> +<span id="1639">1639</span> +<span id="1640">1640</span> +<span id="1641">1641</span> +<span id="1642">1642</span> +<span id="1643">1643</span> +<span id="1644">1644</span> +<span id="1645">1645</span> +<span id="1646">1646</span> +<span id="1647">1647</span> +<span id="1648">1648</span> +<span id="1649">1649</span> +<span id="1650">1650</span> +<span id="1651">1651</span> +<span id="1652">1652</span> +<span id="1653">1653</span> +<span id="1654">1654</span> +<span id="1655">1655</span> +<span id="1656">1656</span> +<span id="1657">1657</span> +<span id="1658">1658</span> +<span id="1659">1659</span> +<span id="1660">1660</span> +<span id="1661">1661</span> +<span id="1662">1662</span> +<span id="1663">1663</span> +<span id="1664">1664</span> +<span id="1665">1665</span> +<span id="1666">1666</span> +<span id="1667">1667</span> +<span id="1668">1668</span> +<span id="1669">1669</span> +<span id="1670">1670</span> +<span id="1671">1671</span> +<span id="1672">1672</span> +<span id="1673">1673</span> +<span id="1674">1674</span> +<span id="1675">1675</span> +<span id="1676">1676</span> +<span id="1677">1677</span> +<span id="1678">1678</span> +<span id="1679">1679</span> +<span id="1680">1680</span> +<span id="1681">1681</span> +<span id="1682">1682</span> +<span id="1683">1683</span> +<span id="1684">1684</span> +<span id="1685">1685</span> +<span id="1686">1686</span> +<span id="1687">1687</span> +<span id="1688">1688</span> +<span id="1689">1689</span> +<span id="1690">1690</span> +<span id="1691">1691</span> +<span id="1692">1692</span> +<span id="1693">1693</span> +<span id="1694">1694</span> +<span id="1695">1695</span> +<span id="1696">1696</span> +<span id="1697">1697</span> +<span id="1698">1698</span> +<span id="1699">1699</span> +<span id="1700">1700</span> +<span id="1701">1701</span> +<span id="1702">1702</span> +<span id="1703">1703</span> +<span id="1704">1704</span> +<span id="1705">1705</span> +<span id="1706">1706</span> +<span id="1707">1707</span> +<span id="1708">1708</span> +<span id="1709">1709</span> +<span id="1710">1710</span> +<span id="1711">1711</span> +<span id="1712">1712</span> +<span id="1713">1713</span> +<span id="1714">1714</span> +<span id="1715">1715</span> +<span id="1716">1716</span> +<span id="1717">1717</span> +<span id="1718">1718</span> +<span id="1719">1719</span> +<span id="1720">1720</span> +<span id="1721">1721</span> +<span id="1722">1722</span> +<span id="1723">1723</span> +<span id="1724">1724</span> +<span id="1725">1725</span> +<span id="1726">1726</span> +<span id="1727">1727</span> +<span id="1728">1728</span> +<span id="1729">1729</span> +<span id="1730">1730</span> +<span id="1731">1731</span> +<span id="1732">1732</span> +<span id="1733">1733</span> +<span id="1734">1734</span> +<span id="1735">1735</span> +<span id="1736">1736</span> +<span id="1737">1737</span> +<span id="1738">1738</span> +<span id="1739">1739</span> +<span id="1740">1740</span> +<span id="1741">1741</span> +<span id="1742">1742</span> +<span id="1743">1743</span> +<span id="1744">1744</span> +<span id="1745">1745</span> +<span id="1746">1746</span> +<span id="1747">1747</span> +<span id="1748">1748</span> +<span id="1749">1749</span> +<span id="1750">1750</span> +<span id="1751">1751</span> +<span id="1752">1752</span> +<span id="1753">1753</span> +<span id="1754">1754</span> +<span id="1755">1755</span> +<span id="1756">1756</span> +<span id="1757">1757</span> +<span id="1758">1758</span> +<span id="1759">1759</span> +<span id="1760">1760</span> +<span id="1761">1761</span> +<span id="1762">1762</span> +<span id="1763">1763</span> +<span id="1764">1764</span> +<span id="1765">1765</span> +<span id="1766">1766</span> +<span id="1767">1767</span> +<span id="1768">1768</span> +<span id="1769">1769</span> +<span id="1770">1770</span> +<span id="1771">1771</span> +<span id="1772">1772</span> +<span id="1773">1773</span> +<span id="1774">1774</span> +<span id="1775">1775</span> +<span id="1776">1776</span> +<span id="1777">1777</span> +<span id="1778">1778</span> +<span id="1779">1779</span> +<span id="1780">1780</span> +<span id="1781">1781</span> +<span id="1782">1782</span> +<span id="1783">1783</span> +<span id="1784">1784</span> +<span id="1785">1785</span> +<span id="1786">1786</span> +<span id="1787">1787</span> +<span id="1788">1788</span> +<span id="1789">1789</span> +<span id="1790">1790</span> +<span id="1791">1791</span> +<span id="1792">1792</span> +<span id="1793">1793</span> +<span id="1794">1794</span> +<span id="1795">1795</span> +<span id="1796">1796</span> +<span id="1797">1797</span> +<span id="1798">1798</span> +<span id="1799">1799</span> +<span id="1800">1800</span> +<span id="1801">1801</span> +<span id="1802">1802</span> +<span id="1803">1803</span> +<span id="1804">1804</span> +<span id="1805">1805</span> +<span id="1806">1806</span> +<span id="1807">1807</span> +<span id="1808">1808</span> +<span id="1809">1809</span> +<span id="1810">1810</span> +<span id="1811">1811</span> +<span id="1812">1812</span> +<span id="1813">1813</span> +<span id="1814">1814</span> +<span id="1815">1815</span> +<span id="1816">1816</span> +<span id="1817">1817</span> +<span id="1818">1818</span> +<span id="1819">1819</span> +<span id="1820">1820</span> +<span id="1821">1821</span> +<span id="1822">1822</span> +<span id="1823">1823</span> +<span id="1824">1824</span> +<span id="1825">1825</span> +<span id="1826">1826</span> +<span id="1827">1827</span> +<span id="1828">1828</span> +<span id="1829">1829</span> +<span id="1830">1830</span> +<span id="1831">1831</span> +<span id="1832">1832</span> +<span id="1833">1833</span> +<span id="1834">1834</span> +<span id="1835">1835</span> +<span id="1836">1836</span> +<span id="1837">1837</span> +<span id="1838">1838</span> +<span id="1839">1839</span> +<span id="1840">1840</span> +<span id="1841">1841</span> +<span id="1842">1842</span> +<span id="1843">1843</span> +<span id="1844">1844</span> +<span id="1845">1845</span> +<span id="1846">1846</span> +<span id="1847">1847</span> +<span id="1848">1848</span> +<span id="1849">1849</span> +<span id="1850">1850</span> +<span id="1851">1851</span> +<span id="1852">1852</span> +<span id="1853">1853</span> +<span id="1854">1854</span> +<span id="1855">1855</span> +<span id="1856">1856</span> +<span id="1857">1857</span> +<span id="1858">1858</span> +<span id="1859">1859</span> +<span id="1860">1860</span> +<span id="1861">1861</span> +<span id="1862">1862</span> +<span id="1863">1863</span> +<span id="1864">1864</span> +<span id="1865">1865</span> +<span id="1866">1866</span> +<span id="1867">1867</span> +<span id="1868">1868</span> +<span id="1869">1869</span> +<span id="1870">1870</span> +<span id="1871">1871</span> +<span id="1872">1872</span> +<span id="1873">1873</span> +<span id="1874">1874</span> +<span id="1875">1875</span> +<span id="1876">1876</span> +<span id="1877">1877</span> +<span id="1878">1878</span> +<span id="1879">1879</span> +<span id="1880">1880</span> +<span id="1881">1881</span> +<span id="1882">1882</span> +<span id="1883">1883</span> +<span id="1884">1884</span> +<span id="1885">1885</span> +<span id="1886">1886</span> +<span id="1887">1887</span> +<span id="1888">1888</span> +<span id="1889">1889</span> +<span id="1890">1890</span> +<span id="1891">1891</span> +<span id="1892">1892</span> +<span id="1893">1893</span> +<span id="1894">1894</span> +<span id="1895">1895</span> +<span id="1896">1896</span> +<span id="1897">1897</span> +<span id="1898">1898</span> +<span id="1899">1899</span> +<span id="1900">1900</span> +<span id="1901">1901</span> +<span id="1902">1902</span> +<span id="1903">1903</span> +<span id="1904">1904</span> +<span id="1905">1905</span> +<span id="1906">1906</span> +<span id="1907">1907</span> +<span id="1908">1908</span> +<span id="1909">1909</span> +<span id="1910">1910</span> +<span id="1911">1911</span> +<span id="1912">1912</span> +<span id="1913">1913</span> +<span id="1914">1914</span> +<span id="1915">1915</span> +<span id="1916">1916</span> +<span id="1917">1917</span> +<span id="1918">1918</span> +<span id="1919">1919</span> +<span id="1920">1920</span> +<span id="1921">1921</span> +<span id="1922">1922</span> +<span id="1923">1923</span> +<span id="1924">1924</span> +<span id="1925">1925</span> +<span id="1926">1926</span> +<span id="1927">1927</span> +<span id="1928">1928</span> +<span id="1929">1929</span> +<span id="1930">1930</span> +<span id="1931">1931</span> +<span id="1932">1932</span> +<span id="1933">1933</span> +<span id="1934">1934</span> +<span id="1935">1935</span> +<span id="1936">1936</span> +<span id="1937">1937</span> +<span id="1938">1938</span> +<span id="1939">1939</span> +<span id="1940">1940</span> +<span id="1941">1941</span> +<span id="1942">1942</span> +<span id="1943">1943</span> +<span id="1944">1944</span> +<span id="1945">1945</span> +<span id="1946">1946</span> +<span id="1947">1947</span> +<span id="1948">1948</span> +<span id="1949">1949</span> +<span id="1950">1950</span> +</pre><pre class='rust '> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>allow</span>(<span class='ident'>non_camel_case_types</span>)]</span> + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>borrow</span>::{ <span class='ident'>Cow</span>, <span class='ident'>IntoCow</span>, <span class='ident'>Borrow</span>, <span class='ident'>ToOwned</span> }; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>borrow</span>::<span class='ident'>Cow</span>::<span class='op'>*</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>iter</span>::<span class='ident'>Extend</span>; + +<span class='kw'>use</span> <span class='ident'>message</span>::{ <span class='ident'>Message</span>, <span class='ident'>MsgType</span> }; + +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>Cow</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>str</span><span class='op'>></span>; + +<span class='comment'>// If you hoped it couldn't get any uglier... I'm sorry, it does.</span> +<span class='comment'>// Why a giant match? API.</span> +<span class='comment'>//</span> +<span class='comment'>// I tried structuring it as a bunch of structs that impl a `Command` trait,</span> +<span class='comment'>// but the user would have to use Any and lots of cats. Also, extensibility isn't</span> +<span class='comment'>// really a goal; the IRC protocol doesn't seem to evolve very fast.</span> +<span class='comment'>//</span> +<span class='comment'>// Granted, I *could* have used a phf-map to map to functions to parse this, which</span> +<span class='comment'>// - while more readable - shouldn't have resulted in performance gains.</span> +<span class='comment'>//</span> +<span class='comment'>// Please don't cry.</span> + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>, <span class='ident'>Hash</span>, <span class='ident'>Clone</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Command</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.1.1 Password message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: PASS</span> + <span class='doccomment'>/// Parameters: <password></span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The PASS command is used to set a 'connection password'. The</span> + <span class='doccomment'>/// optional password can and MUST be set before any attempt to register</span> + <span class='doccomment'>/// the connection is made. Currently this requires that user send a</span> + <span class='doccomment'>/// PASS command before sending the NICK/USER combination.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NEEDMOREPARAMS ERR_ALREADYREGISTRED</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Example:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// PASS secretpasswordhere</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>PASS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.1.2 Nick message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: NICK</span> + <span class='doccomment'>/// Parameters: <nickname></span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// NICK command is used to give user a nickname or change the existing</span> + <span class='doccomment'>/// one.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NONICKNAMEGIVEN ERR_ERRONEUSNICKNAME</span> + <span class='doccomment'>/// ERR_NICKNAMEINUSE ERR_NICKCOLLISION</span> + <span class='doccomment'>/// ERR_UNAVAILRESOURCE ERR_RESTRICTED</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// NICK Wiz ; Introducing new nick "Wiz" if session is</span> + <span class='doccomment'>/// still unregistered, or user changing his</span> + <span class='doccomment'>/// nickname to "Wiz"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// :WiZ!jto@tolsun.oulu.fi NICK Kilroy</span> + <span class='doccomment'>/// ; Server telling that WiZ changed his</span> + <span class='doccomment'>/// nickname to Kilroy.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>NICK</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.1.3 User message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: USER</span> + <span class='doccomment'>/// Parameters: <user> <mode> <unused> <realname></span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The USER command is used at the beginning of connection to specify</span> + <span class='doccomment'>/// the username, hostname and realname of a new user.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The <mode> parameter should be a numeric, and can be used to</span> + <span class='doccomment'>/// automatically set user modes when registering with the server. This</span> + <span class='doccomment'>/// parameter is a bitmask, with only 2 bits having any signification: if</span> + <span class='doccomment'>/// the bit 2 is set, the user mode 'w' will be set and if the bit 3 is</span> + <span class='doccomment'>/// set, the user mode 'i' will be set. (See Section 3.1.5 "User</span> + <span class='doccomment'>/// Modes").</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The <realname> may contain space characters.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NEEDMOREPARAMS ERR_ALREADYREGISTRED</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Example:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// USER guest 0 * :Ronnie Reagan ; User registering themselves with a</span> + <span class='doccomment'>/// username of "guest" and real name</span> + <span class='doccomment'>/// "Ronnie Reagan".</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// USER guest 8 * :Ronnie Reagan ; User registering themselves with a</span> + <span class='doccomment'>/// username of "guest" and real name</span> + <span class='doccomment'>/// "Ronnie Reagan", and asking to be set</span> + <span class='doccomment'>/// invisible.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>USER</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.1.4 Oper message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: OPER</span> + <span class='doccomment'>/// Parameters: <name> <password></span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// A normal user uses the OPER command to obtain operator privileges.</span> + <span class='doccomment'>/// The combination of <name> and <password> are REQUIRED to gain</span> + <span class='doccomment'>/// Operator privileges. Upon success, the user will receive a MODE</span> + <span class='doccomment'>/// message (see section 3.1.5) indicating the new user modes.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NEEDMOREPARAMS RPL_YOUREOPER</span> + <span class='doccomment'>/// ERR_NOOPERHOST ERR_PASSWDMISMATCH</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Example:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// OPER foo bar ; Attempt to register as an operator</span> + <span class='doccomment'>/// using a username of "foo" and "bar"</span> + <span class='doccomment'>/// as the password.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>OPER</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.1.5 User mode message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: MODE</span> + <span class='doccomment'>/// Parameters: <nickname></span> + <span class='doccomment'>/// *( ( "+" / "-" ) *( "i" / "w" / "o" / "O" / "r" ) )</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The user MODE's are typically changes which affect either how the</span> + <span class='doccomment'>/// client is seen by others or what 'extra' messages the client is sent.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// A user MODE command MUST only be accepted if both the sender of the</span> + <span class='doccomment'>/// message and the nickname given as a parameter are both the same. If</span> + <span class='doccomment'>/// no other parameter is given, then the server will return the current</span> + <span class='doccomment'>/// settings for the nick.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The available modes are as follows:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// a - user is flagged as away;</span> + <span class='doccomment'>/// i - marks a users as invisible;</span> + <span class='doccomment'>/// w - user receives wallops;</span> + <span class='doccomment'>/// r - restricted user connection;</span> + <span class='doccomment'>/// o - operator flag;</span> + <span class='doccomment'>/// O - local operator flag;</span> + <span class='doccomment'>/// s - marks a user for receipt of server notices.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Additional modes may be available later on.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The flag 'a' SHALL NOT be toggled by the user using the MODE command,</span> + <span class='doccomment'>/// instead use of the AWAY command is REQUIRED.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If a user attempts to make themselves an operator using the "+o" or</span> + <span class='doccomment'>/// "+O" flag, the attempt SHOULD be ignored as users could bypass the</span> + <span class='doccomment'>/// authentication mechanisms of the OPER command. There is no</span> + <span class='doccomment'>/// restriction, however, on anyone `deopping' themselves (using "-o" or</span> + <span class='doccomment'>/// "-O").</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// On the other hand, if a user attempts to make themselves unrestricted</span> + <span class='doccomment'>/// using the "-r" flag, the attempt SHOULD be ignored. There is no</span> + <span class='doccomment'>/// restriction, however, on anyone `deopping' themselves (using "+r").</span> + <span class='doccomment'>/// This flag is typically set by the server upon connection for</span> + <span class='doccomment'>/// administrative reasons. While the restrictions imposed are left up</span> + <span class='doccomment'>/// to the implementation, it is typical that a restricted user not be</span> + <span class='doccomment'>/// allowed to change nicknames, nor make use of the channel operator</span> + <span class='doccomment'>/// status on channels.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The flag 's' is obsolete but MAY still be used.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NEEDMOREPARAMS ERR_USERSDONTMATCH</span> + <span class='doccomment'>/// ERR_UMODEUNKNOWNFLAG RPL_UMODEIS</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// MODE WiZ -w ; Command by WiZ to turn off</span> + <span class='doccomment'>/// reception of WALLOPS messages.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// MODE Angel +i ; Command from Angel to make herself</span> + <span class='doccomment'>/// invisible.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// MODE WiZ -o ; WiZ 'deopping' (removing operator</span> + <span class='doccomment'>/// status).</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>UMODE</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.1.6 Service message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: SERVICE</span> + <span class='doccomment'>/// Parameters: <nickname> <reserved> <distribution> <type></span> + <span class='doccomment'>/// <reserved> <info></span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The SERVICE command to register a new service. Command parameters</span> + <span class='doccomment'>/// specify the service nickname, distribution, type and info of a new</span> + <span class='doccomment'>/// service.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The <distribution> parameter is used to specify the visibility of a</span> + <span class='doccomment'>/// service. The service may only be known to servers which have a name</span> + <span class='doccomment'>/// matching the distribution. For a matching server to have knowledge</span> + <span class='doccomment'>/// of the service, the network path between that server and the server</span> + <span class='doccomment'>/// on which the service is connected MUST be composed of servers which</span> + <span class='doccomment'>/// names all match the mask.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The <type> parameter is currently reserved for future usage.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_ALREADYREGISTRED ERR_NEEDMOREPARAMS</span> + <span class='doccomment'>/// ERR_ERRONEUSNICKNAME</span> + <span class='doccomment'>/// RPL_YOURESERVICE RPL_YOURHOST</span> + <span class='doccomment'>/// RPL_MYINFO</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Example:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// SERVICE dict * *.fr 0 0 :French Dictionary ; Service registering</span> + <span class='doccomment'>/// itself with a name of "dict". This</span> + <span class='doccomment'>/// service will only be available on</span> + <span class='doccomment'>/// servers which name matches "*.fr".</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>SERVICE</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.1.7 Quit</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: QUIT</span> + <span class='doccomment'>/// Parameters: [ <Quit Message> ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// A client session is terminated with a quit message. The server</span> + <span class='doccomment'>/// acknowledges this by sending an ERROR message to the client.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// None.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Example:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// QUIT :Gone to have lunch ; Preferred message format.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// :syrk!kalt@millennium.stealth.net QUIT :Gone to have lunch ; User</span> + <span class='doccomment'>/// syrk has quit IRC to have lunch.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>QUIT</span>(<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.1.8 Squit</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: SQUIT</span> + <span class='doccomment'>/// Parameters: <server> <comment></span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The SQUIT command is available only to operators. It is used to</span> + <span class='doccomment'>/// disconnect server links. Also servers can generate SQUIT messages on</span> + <span class='doccomment'>/// error conditions. A SQUIT message may also target a remote server</span> + <span class='doccomment'>/// connection. In this case, the SQUIT message will simply be sent to</span> + <span class='doccomment'>/// the remote server without affecting the servers in between the</span> + <span class='doccomment'>/// operator and the remote server.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The <comment> SHOULD be supplied by all operators who execute a SQUIT</span> + <span class='doccomment'>/// for a remote server. The server ordered to disconnect its peer</span> + <span class='doccomment'>/// generates a WALLOPS message with <comment> included, so that other</span> + <span class='doccomment'>/// users may be aware of the reason of this action.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NOPRIVILEGES ERR_NOSUCHSERVER</span> + <span class='doccomment'>/// ERR_NEEDMOREPARAMS</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// SQUIT tolsun.oulu.fi :Bad Link ? ; Command to uplink of the server</span> + <span class='doccomment'>/// tolson.oulu.fi to terminate its</span> + <span class='doccomment'>/// connection with comment "Bad Link".</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// :Trillian SQUIT cm22.eng.umd.edu :Server out of control ; Command</span> + <span class='doccomment'>/// from Trillian from to disconnect</span> + <span class='doccomment'>/// "cm22.eng.umd.edu" from the net with</span> + <span class='doccomment'>/// comment "Server out of control".</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>SQUIT</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.2.1 Join message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: JOIN</span> + <span class='doccomment'>/// Parameters: ( <channel> *( "," <channel> ) [ <key> *( "," <key> ) ] )</span> + <span class='doccomment'>/// / "0"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The JOIN command is used by a user to request to start listening to</span> + <span class='doccomment'>/// the specific channel. Servers MUST be able to parse arguments in the</span> + <span class='doccomment'>/// form of a list of target, but SHOULD NOT use lists when sending JOIN</span> + <span class='doccomment'>/// messages to clients.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Once a user has joined a channel, he receives information about</span> + <span class='doccomment'>/// all commands his server receives affecting the channel. This</span> + <span class='doccomment'>/// includes JOIN, MODE, KICK, PART, QUIT and of course PRIVMSG/NOTICE.</span> + <span class='doccomment'>/// This allows channel members to keep track of the other channel</span> + <span class='doccomment'>/// members, as well as channel modes.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If a JOIN is successful, the user receives a JOIN message as</span> + <span class='doccomment'>/// confirmation and is then sent the channel's topic (using RPL_TOPIC) and</span> + <span class='doccomment'>/// the list of users who are on the channel (using RPL_NAMREPLY), which</span> + <span class='doccomment'>/// MUST include the user joining.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Note that this message accepts a special argument ("0"), which is</span> + <span class='doccomment'>/// a special request to leave all channels the user is currently a member</span> + <span class='doccomment'>/// of. The server will process this message as if the user had sent</span> + <span class='doccomment'>/// a PART command (See Section 3.2.2) for each channel he is a member</span> + <span class='doccomment'>/// of.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NEEDMOREPARAMS ERR_BANNEDFROMCHAN</span> + <span class='doccomment'>/// ERR_INVITEONLYCHAN ERR_BADCHANNELKEY</span> + <span class='doccomment'>/// ERR_CHANNELISFULL ERR_BADCHANMASK</span> + <span class='doccomment'>/// ERR_NOSUCHCHANNEL ERR_TOOMANYCHANNELS</span> + <span class='doccomment'>/// ERR_TOOMANYTARGETS ERR_UNAVAILRESOURCE</span> + <span class='doccomment'>/// RPL_TOPIC</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// JOIN #foobar ; Command to join channel #foobar.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// JOIN &foo fubar ; Command to join channel &foo using</span> + <span class='doccomment'>/// key "fubar".</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// JOIN #foo,&bar fubar ; Command to join channel #foo using</span> + <span class='doccomment'>/// key "fubar" and &bar using no key.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// JOIN #foo,#bar fubar,foobar ; Command to join channel #foo using</span> + <span class='doccomment'>/// key "fubar", and channel #bar using</span> + <span class='doccomment'>/// key "foobar".</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// JOIN #foo,#bar ; Command to join channels #foo and</span> + <span class='doccomment'>/// #bar.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// JOIN 0 ; Leave all currently joined</span> + <span class='doccomment'>/// channels.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// :WiZ!jto@tolsun.oulu.fi JOIN #Twilight_zone ; JOIN message from WiZ</span> + <span class='doccomment'>/// on channel #Twilight_zone</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>JOIN</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.2.2 Part message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: PART</span> + <span class='doccomment'>/// Parameters: <channel> *( "," <channel> ) [ <Part Message> ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The PART command causes the user sending the message to be removed</span> + <span class='doccomment'>/// from the list of active members for all given channels listed in the</span> + <span class='doccomment'>/// parameter string. If a "Part Message" is given, this will be sent</span> + <span class='doccomment'>/// instead of the default message, the nickname. This request is always</span> + <span class='doccomment'>/// granted by the server.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Servers MUST be able to parse arguments in the form of a list of</span> + <span class='doccomment'>/// target, but SHOULD NOT use lists when sending PART messages to</span> + <span class='doccomment'>/// clients.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NEEDMOREPARAMS ERR_NOSUCHCHANNEL</span> + <span class='doccomment'>/// ERR_NOTONCHANNEL</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// PART #twilight_zone ; Command to leave channel</span> + <span class='doccomment'>/// "#twilight_zone"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// PART #oz-ops,&group5 ; Command to leave both channels</span> + <span class='doccomment'>/// "&group5" and "#oz-ops".</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// :WiZ!jto@tolsun.oulu.fi PART #playzone :I lost</span> + <span class='doccomment'>/// ; User WiZ leaving channel</span> + <span class='doccomment'>/// "#playzone" with the message "I</span> + <span class='doccomment'>/// lost".</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>PART</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.2.3 Channel mode message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: MODE</span> + <span class='doccomment'>/// Parameters: <channel> *( ( "-" / "+" ) *<modes> *<modeparams> )</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The MODE command is provided so that users may query and change the</span> + <span class='doccomment'>/// characteristics of a channel. For more details on available modes</span> + <span class='doccomment'>/// and their uses, see "Internet Relay Chat: Channel Management" [IRC-</span> + <span class='doccomment'>/// CHAN]. Note that there is a maximum limit of three (3) changes per</span> + <span class='doccomment'>/// command for modes that take a parameter.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NEEDMOREPARAMS ERR_KEYSET</span> + <span class='doccomment'>/// ERR_NOCHANMODES ERR_CHANOPRIVSNEEDED</span> + <span class='doccomment'>/// ERR_USERNOTINCHANNEL ERR_UNKNOWNMODE</span> + <span class='doccomment'>/// RPL_CHANNELMODEIS</span> + <span class='doccomment'>/// RPL_BANLIST RPL_ENDOFBANLIST</span> + <span class='doccomment'>/// RPL_EXCEPTLIST RPL_ENDOFEXCEPTLIST</span> + <span class='doccomment'>/// RPL_INVITELIST RPL_ENDOFINVITELIST</span> + <span class='doccomment'>/// RPL_UNIQOPIS</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The following examples are given to help understanding the syntax of</span> + <span class='doccomment'>/// the MODE command, but refer to modes defined in "Internet Relay Chat:</span> + <span class='doccomment'>/// Channel Management" [IRC-CHAN].</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// MODE #Finnish +imI *!*@*.fi ; Command to make #Finnish channel</span> + <span class='doccomment'>/// moderated and 'invite-only' with user</span> + <span class='doccomment'>/// with a hostname matching *.fi</span> + <span class='doccomment'>/// automatically invited.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// MODE #Finnish +o Kilroy ; Command to give 'chanop' privileges</span> + <span class='doccomment'>/// to Kilroy on channel #Finnish.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// MODE #Finnish +v Wiz ; Command to allow WiZ to speak on</span> + <span class='doccomment'>/// #Finnish.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// MODE #Fins -s ; Command to remove 'secret' flag</span> + <span class='doccomment'>/// from channel #Fins.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// MODE #42 +k oulu ; Command to set the channel key to</span> + <span class='doccomment'>/// "oulu".</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// MODE #42 -k oulu ; Command to remove the "oulu"</span> + <span class='doccomment'>/// channel key on channel "#42".</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// MODE #eu-opers +l 10 ; Command to set the limit for the</span> + <span class='doccomment'>/// number of users on channel</span> + <span class='doccomment'>/// "#eu-opers" to 10.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// :WiZ!jto@tolsun.oulu.fi MODE #eu-opers -l</span> + <span class='doccomment'>/// ; User "WiZ" removing the limit for</span> + <span class='doccomment'>/// the number of users on channel "#eu-</span> + <span class='doccomment'>/// opers".</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// MODE &oulu +b ; Command to list ban masks set for</span> + <span class='doccomment'>/// the channel "&oulu".</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// MODE &oulu +b *!*@* ; Command to prevent all users from</span> + <span class='doccomment'>/// joining.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// MODE &oulu +b *!*@*.edu +e *!*@*.bu.edu</span> + <span class='doccomment'>/// ; Command to prevent any user from a</span> + <span class='doccomment'>/// hostname matching *.edu from joining,</span> + <span class='doccomment'>/// except if matching *.bu.edu</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// MODE #bu +be *!*@*.edu *!*@*.bu.edu</span> + <span class='doccomment'>/// ; Comment to prevent any user from a</span> + <span class='doccomment'>/// hostname matching *.edu from joining,</span> + <span class='doccomment'>/// except if matching *.bu.edu</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// MODE #meditation e ; Command to list exception masks set</span> + <span class='doccomment'>/// for the channel "#meditation".</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// MODE #meditation I ; Command to list invitations masks</span> + <span class='doccomment'>/// set for the channel "#meditation".</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// MODE !12345ircd O ; Command to ask who the channel</span> + <span class='doccomment'>/// creator for "!12345ircd" is</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>MODE</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>)<span class='op'>></span>), + + <span class='doccomment'>/// ```text```</span> + <span class='doccomment'>/// 3.2.4 Topic message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: TOPIC</span> + <span class='doccomment'>/// Parameters: <channel> [ <topic> ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The TOPIC command is used to change or view the topic of a channel.</span> + <span class='doccomment'>/// The topic for channel <channel> is returned if there is no <topic></span> + <span class='doccomment'>/// given. If the <topic> parameter is present, the topic for that</span> + <span class='doccomment'>/// channel will be changed, if this action is allowed for the user</span> + <span class='doccomment'>/// requesting it. If the <topic> parameter is an empty string, the</span> + <span class='doccomment'>/// topic for that channel will be removed.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NEEDMOREPARAMS ERR_NOTONCHANNEL</span> + <span class='doccomment'>/// RPL_NOTOPIC RPL_TOPIC</span> + <span class='doccomment'>/// ERR_CHANOPRIVSNEEDED ERR_NOCHANMODES</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// :WiZ!jto@tolsun.oulu.fi TOPIC #test :New topic ; User Wiz setting the</span> + <span class='doccomment'>/// topic.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// TOPIC #test :another topic ; Command to set the topic on #test</span> + <span class='doccomment'>/// to "another topic".</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// TOPIC #test : ; Command to clear the topic on</span> + <span class='doccomment'>/// #test.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// TOPIC #test ; Command to check the topic for</span> + <span class='doccomment'>/// #test.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>TOPIC</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.2.5 Names message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: NAMES</span> + <span class='doccomment'>/// Parameters: [ <channel> *( "," <channel> ) [ <target> ] ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// By using the NAMES command, a user can list all nicknames that are</span> + <span class='doccomment'>/// visible to him. For more details on what is visible and what is not,</span> + <span class='doccomment'>/// see "Internet Relay Chat: Channel Management" [IRC-CHAN]. The</span> + <span class='doccomment'>/// <channel> parameter specifies which channel(s) to return information</span> + <span class='doccomment'>/// about. There is no error reply for bad channel names.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If no <channel> parameter is given, a list of all channels and their</span> + <span class='doccomment'>/// occupants is returned. At the end of this list, a list of users who</span> + <span class='doccomment'>/// are visible but either not on any channel or not on a visible channel</span> + <span class='doccomment'>/// are listed as being on `channel' "*".</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If the <target> parameter is specified, the request is forwarded to</span> + <span class='doccomment'>/// that server which will generate the reply.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Wildcards are allowed in the <target> parameter.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numerics:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_TOOMANYMATCHES ERR_NOSUCHSERVER</span> + <span class='doccomment'>/// RPL_NAMREPLY RPL_ENDOFNAMES</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// NAMES #twilight_zone,#42 ; Command to list visible users on</span> + <span class='doccomment'>/// #twilight_zone and #42</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// NAMES ; Command to list all visible</span> + <span class='doccomment'>/// channels and users</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>NAMES</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.2.6 List message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: LIST</span> + <span class='doccomment'>/// Parameters: [ <channel> *( "," <channel> ) [ <target> ] ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The list command is used to list channels and their topics. If the</span> + <span class='doccomment'>/// <channel> parameter is used, only the status of that channel is</span> + <span class='doccomment'>/// displayed.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If the <target> parameter is specified, the request is forwarded to</span> + <span class='doccomment'>/// that server which will generate the reply.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Wildcards are allowed in the <target> parameter.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_TOOMANYMATCHES ERR_NOSUCHSERVER</span> + <span class='doccomment'>/// RPL_LIST RPL_LISTEND</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// LIST ; Command to list all channels.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// LIST #twilight_zone,#42 ; Command to list channels</span> + <span class='doccomment'>/// #twilight_zone and #42</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>LIST</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.2.7 Invite message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: INVITE</span> + <span class='doccomment'>/// Parameters: <nickname> <channel></span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The INVITE command is used to invite a user to a channel. The</span> + <span class='doccomment'>/// parameter <nickname> is the nickname of the person to be invited to</span> + <span class='doccomment'>/// the target channel <channel>. There is no requirement that the</span> + <span class='doccomment'>/// channel the target user is being invited to must exist or be a valid</span> + <span class='doccomment'>/// channel. However, if the channel exists, only members of the channel</span> + <span class='doccomment'>/// are allowed to invite other users. When the channel has invite-only</span> + <span class='doccomment'>/// flag set, only channel operators may issue INVITE command.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Only the user inviting and the user being invited will receive</span> + <span class='doccomment'>/// notification of the invitation. Other channel members are not</span> + <span class='doccomment'>/// notified. (This is unlike the MODE changes, and is occasionally the</span> + <span class='doccomment'>/// source of trouble for users.)</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NEEDMOREPARAMS ERR_NOSUCHNICK</span> + <span class='doccomment'>/// ERR_NOTONCHANNEL ERR_USERONCHANNEL</span> + <span class='doccomment'>/// ERR_CHANOPRIVSNEEDED</span> + <span class='doccomment'>/// RPL_INVITING RPL_AWAY</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// :Angel!wings@irc.org INVITE Wiz #Dust</span> + <span class='doccomment'>/// ; Message to WiZ when he has been</span> + <span class='doccomment'>/// invited by user Angel to channel</span> + <span class='doccomment'>/// #Dust</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// INVITE Wiz #Twilight_Zone ; Command to invite WiZ to</span> + <span class='doccomment'>/// #Twilight_zone</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>INVITE</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.2.8 Kick command</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: KICK</span> + <span class='doccomment'>/// Parameters: <channel> *( "," <channel> ) <user> *( "," <user> )</span> + <span class='doccomment'>/// [<comment>]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The KICK command can be used to request the forced removal of a user</span> + <span class='doccomment'>/// from a channel. It causes the <user> to PART from the <channel> by</span> + <span class='doccomment'>/// force. For the message to be syntactically correct, there MUST be</span> + <span class='doccomment'>/// either one channel parameter and multiple user parameter, or as many</span> + <span class='doccomment'>/// channel parameters as there are user parameters. If a "comment" is</span> + <span class='doccomment'>/// given, this will be sent instead of the default message, the nickname</span> + <span class='doccomment'>/// of the user issuing the KICK.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The server MUST NOT send KICK messages with multiple channels or</span> + <span class='doccomment'>/// users to clients. This is necessarily to maintain backward</span> + <span class='doccomment'>/// compatibility with old client software.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NEEDMOREPARAMS ERR_NOSUCHCHANNEL</span> + <span class='doccomment'>/// ERR_BADCHANMASK ERR_CHANOPRIVSNEEDED</span> + <span class='doccomment'>/// ERR_USERNOTINCHANNEL ERR_NOTONCHANNEL</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// KICK &Melbourne Matthew ; Command to kick Matthew from</span> + <span class='doccomment'>/// &Melbourne</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// KICK #Finnish John :Speaking English</span> + <span class='doccomment'>/// ; Command to kick John from #Finnish</span> + <span class='doccomment'>/// using "Speaking English" as the</span> + <span class='doccomment'>/// reason (comment).</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// :WiZ!jto@tolsun.oulu.fi KICK #Finnish John</span> + <span class='doccomment'>/// ; KICK message on channel #Finnish</span> + <span class='doccomment'>/// from WiZ to remove John from channel</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>KICK</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.3.1 Private messages</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: PRIVMSG</span> + <span class='doccomment'>/// Parameters: <msgtarget> <text to be sent></span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// PRIVMSG is used to send private messages between users, as well as to</span> + <span class='doccomment'>/// send messages to channels. <msgtarget> is usually the nickname of</span> + <span class='doccomment'>/// the recipient of the message, or a channel name.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The <msgtarget> parameter may also be a host mask (#<mask>) or server</span> + <span class='doccomment'>/// mask ($<mask>). In both cases the server will only send the PRIVMSG</span> + <span class='doccomment'>/// to those who have a server or host matching the mask. The mask MUST</span> + <span class='doccomment'>/// have at least 1 (one) "." in it and no wildcards following the last</span> + <span class='doccomment'>/// ".". This requirement exists to prevent people sending messages to</span> + <span class='doccomment'>/// "#*" or "$*", which would broadcast to all users. Wildcards are the</span> + <span class='doccomment'>/// '*' and '?' characters. This extension to the PRIVMSG command is</span> + <span class='doccomment'>/// only available to operators.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NORECIPIENT ERR_NOTEXTTOSEND</span> + <span class='doccomment'>/// ERR_CANNOTSENDTOCHAN ERR_NOTOPLEVEL</span> + <span class='doccomment'>/// ERR_WILDTOPLEVEL ERR_TOOMANYTARGETS</span> + <span class='doccomment'>/// ERR_NOSUCHNICK</span> + <span class='doccomment'>/// RPL_AWAY</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// :Angel!wings@irc.org PRIVMSG Wiz :Are you receiving this message ?</span> + <span class='doccomment'>/// ; Message from Angel to Wiz.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// PRIVMSG Angel :yes I'm receiving it !</span> + <span class='doccomment'>/// ; Command to send a message to Angel.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// PRIVMSG jto@tolsun.oulu.fi :Hello !</span> + <span class='doccomment'>/// ; Command to send a message to a user</span> + <span class='doccomment'>/// on server tolsun.oulu.fi with</span> + <span class='doccomment'>/// username of "jto".</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// PRIVMSG kalt%millennium.stealth.net@irc.stealth.net :Are you a frog?</span> + <span class='doccomment'>/// ; Message to a user on server</span> + <span class='doccomment'>/// irc.stealth.net with username of</span> + <span class='doccomment'>/// "kalt", and connected from the host</span> + <span class='doccomment'>/// millennium.stealth.net.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// PRIVMSG kalt%millennium.stealth.net :Do you like cheese?</span> + <span class='doccomment'>/// ; Message to a user on the local</span> + <span class='doccomment'>/// server with username of "kalt", and</span> + <span class='doccomment'>/// connected from the host</span> + <span class='doccomment'>/// millennium.stealth.net.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// PRIVMSG Wiz!jto@tolsun.oulu.fi :Hello !</span> + <span class='doccomment'>/// ; Message to the user with nickname</span> + <span class='doccomment'>/// Wiz who is connected from the host</span> + <span class='doccomment'>/// tolsun.oulu.fi and has the username</span> + <span class='doccomment'>/// "jto".</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// PRIVMSG $*.fi :Server tolsun.oulu.fi rebooting.</span> + <span class='doccomment'>/// ; Message to everyone on a server</span> + <span class='doccomment'>/// which has a name matching *.fi.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// PRIVMSG #*.edu :NSFNet is undergoing work, expect interruptions</span> + <span class='doccomment'>/// ; Message to all users who come from</span> + <span class='doccomment'>/// a host which has a name matching</span> + <span class='doccomment'>/// *.edu.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>PRIVMSG</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.3.2 Notice</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: NOTICE</span> + <span class='doccomment'>/// Parameters: <msgtarget> <text></span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The NOTICE command is used similarly to PRIVMSG. The difference</span> + <span class='doccomment'>/// between NOTICE and PRIVMSG is that automatic replies MUST NEVER be</span> + <span class='doccomment'>/// sent in response to a NOTICE message. This rule applies to servers</span> + <span class='doccomment'>/// too - they MUST NOT send any error reply back to the client on</span> + <span class='doccomment'>/// receipt of a notice. The object of this rule is to avoid loops</span> + <span class='doccomment'>/// between clients automatically sending something in response to</span> + <span class='doccomment'>/// something it received.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This command is available to services as well as users.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This is typically used by services, and automatons (clients with</span> + <span class='doccomment'>/// either an AI or other interactive program controlling their actions).</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// See PRIVMSG for more details on replies and examples.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>NOTICE</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.4.1 Motd message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: MOTD</span> + <span class='doccomment'>/// Parameters: [ <target> ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The MOTD command is used to get the "Message Of The Day" of the given</span> + <span class='doccomment'>/// server, or current server if <target> is omitted.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Wildcards are allowed in the <target> parameter.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>/// RPL_MOTDSTART RPL_MOTD</span> + <span class='doccomment'>/// RPL_ENDOFMOTD ERR_NOMOTD</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>MOTD</span>(<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.4.2 Lusers message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: LUSERS</span> + <span class='doccomment'>/// Parameters: [ <mask> [ <target> ] ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The LUSERS command is used to get statistics about the size of the</span> + <span class='doccomment'>/// IRC network. If no parameter is given, the reply will be about the</span> + <span class='doccomment'>/// whole net. If a <mask> is specified, then the reply will only</span> + <span class='doccomment'>/// concern the part of the network formed by the servers matching the</span> + <span class='doccomment'>/// mask. Finally, if the <target> parameter is specified, the request</span> + <span class='doccomment'>/// is forwarded to that server which will generate the reply.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Wildcards are allowed in the <target> parameter.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// RPL_LUSERCLIENT RPL_LUSEROP</span> + <span class='doccomment'>/// RPL_LUSERUNKOWN RPL_LUSERCHANNELS</span> + <span class='doccomment'>/// RPL_LUSERME ERR_NOSUCHSERVER</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>LUSERS</span>(<span class='prelude-ty'>Option</span><span class='op'><</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>)<span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.4.3 Version message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: VERSION</span> + <span class='doccomment'>/// Parameters: [ <target> ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The VERSION command is used to query the version of the server</span> + <span class='doccomment'>/// program. An optional parameter <target> is used to query the version</span> + <span class='doccomment'>/// of the server program which a client is not directly connected to.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Wildcards are allowed in the <target> parameter.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NOSUCHSERVER RPL_VERSION</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// VERSION tolsun.oulu.fi ; Command to check the version of</span> + <span class='doccomment'>/// server "tolsun.oulu.fi".</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>VERSION</span>(<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.4.4 Stats message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: STATS</span> + <span class='doccomment'>/// Parameters: [ <query> [ <target> ] ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The stats command is used to query statistics of certain server. If</span> + <span class='doccomment'>/// <query> parameter is omitted, only the end of stats reply is sent</span> + <span class='doccomment'>/// back.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// A query may be given for any single letter which is only checked by</span> + <span class='doccomment'>/// the destination server and is otherwise passed on by intermediate</span> + <span class='doccomment'>/// servers, ignored and unaltered.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Wildcards are allowed in the <target> parameter.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Except for the ones below, the list of valid queries is</span> + <span class='doccomment'>/// implementation dependent. The standard queries below SHOULD be</span> + <span class='doccomment'>/// supported by the server:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// l - returns a list of the server's connections, showing how</span> + <span class='doccomment'>/// long each connection has been established and the</span> + <span class='doccomment'>/// traffic over that connection in Kbytes and messages for</span> + <span class='doccomment'>/// each direction;</span> + <span class='doccomment'>/// m - returns the usage count for each of commands supported</span> + <span class='doccomment'>/// by the server; commands for which the usage count is</span> + <span class='doccomment'>/// zero MAY be omitted;</span> + <span class='doccomment'>/// o - returns a list of configured privileged users,</span> + <span class='doccomment'>/// operators;</span> + <span class='doccomment'>/// u - returns a string showing how long the server has been</span> + <span class='doccomment'>/// up.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// It is also RECOMMENDED that client and server access configuration be</span> + <span class='doccomment'>/// published this way.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NOSUCHSERVER</span> + <span class='doccomment'>/// RPL_STATSLINKINFO RPL_STATSUPTIME</span> + <span class='doccomment'>/// RPL_STATSCOMMANDS RPL_STATSOLINE</span> + <span class='doccomment'>/// RPL_ENDOFSTATS</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// STATS m ; Command to check the command usage</span> + <span class='doccomment'>/// for the server you are connected to</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>STATS</span>(<span class='prelude-ty'>Option</span><span class='op'><</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>)<span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.4.5 Links message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: LINKS</span> + <span class='doccomment'>/// Parameters: [ [ <remote server> ] <server mask> ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// With LINKS, a user can list all servernames, which are known by the</span> + <span class='doccomment'>/// server answering the query. The returned list of servers MUST match</span> + <span class='doccomment'>/// the mask, or if no mask is given, the full list is returned.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If <remote server> is given in addition to <server mask>, the LINKS</span> + <span class='doccomment'>/// command is forwarded to the first server found that matches that name</span> + <span class='doccomment'>/// (if any), and that server is then required to answer the query.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NOSUCHSERVER</span> + <span class='doccomment'>/// RPL_LINKS RPL_ENDOFLINKS</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// LINKS *.au ; Command to list all servers which</span> + <span class='doccomment'>/// have a name that matches *.au;</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// LINKS *.edu *.bu.edu ; Command to list servers matching</span> + <span class='doccomment'>/// *.bu.edu as seen by the first server</span> + <span class='doccomment'>/// matching *.edu.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>LINKS</span>(<span class='prelude-ty'>Option</span><span class='op'><</span>(<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>, <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>)<span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.4.6 Time message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: TIME</span> + <span class='doccomment'>/// Parameters: [ <target> ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The time command is used to query local time from the specified</span> + <span class='doccomment'>/// server. If the <target> parameter is not given, the server receiving</span> + <span class='doccomment'>/// the command must reply to the query.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Wildcards are allowed in the <target> parameter.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NOSUCHSERVER RPL_TIME</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>/// TIME tolsun.oulu.fi ; check the time on the server</span> + <span class='doccomment'>/// "tolson.oulu.fi"</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>TIME</span>(<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.4.7 Connect message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: CONNECT</span> + <span class='doccomment'>/// Parameters: <target server> <port> [ <remote server> ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The CONNECT command can be used to request a server to try to</span> + <span class='doccomment'>/// establish a new connection to another server immediately. CONNECT is</span> + <span class='doccomment'>/// a privileged command and SHOULD be available only to IRC Operators.</span> + <span class='doccomment'>/// If a <remote server> is given and its mask doesn't match name of the</span> + <span class='doccomment'>/// parsing server, the CONNECT attempt is sent to the first match of</span> + <span class='doccomment'>/// remote server. Otherwise the CONNECT attempt is made by the server</span> + <span class='doccomment'>/// processing the request.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The server receiving a remote CONNECT command SHOULD generate a</span> + <span class='doccomment'>/// WALLOPS message describing the source and target of the request.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NOSUCHSERVER ERR_NOPRIVILEGES</span> + <span class='doccomment'>/// ERR_NEEDMOREPARAMS</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// CONNECT tolsun.oulu.fi 6667 ; Command to attempt to connect local</span> + <span class='doccomment'>/// server to tolsun.oulu.fi on port 6667</span> + <span class='doccomment'>///</span> + <span class='ident'>CONNECT</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>i16</span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.4.8 Trace message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: TRACE</span> + <span class='doccomment'>/// Parameters: [ <target> ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// TRACE command is used to find the route to specific server and</span> + <span class='doccomment'>/// information about its peers. Each server that processes this command</span> + <span class='doccomment'>/// MUST report to the sender about it. The replies from pass-through</span> + <span class='doccomment'>/// links form a chain, which shows route to destination. After sending</span> + <span class='doccomment'>/// this reply back, the query MUST be sent to the next server until</span> + <span class='doccomment'>/// given <target> server is reached.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// TRACE command is used to find the route to specific server. Each</span> + <span class='doccomment'>/// server that processes this message MUST tell the sender about it by</span> + <span class='doccomment'>/// sending a reply indicating it is a pass-through link, forming a chain</span> + <span class='doccomment'>/// of replies. After sending this reply back, it MUST then send the</span> + <span class='doccomment'>/// TRACE message to the next server until given server is reached. If</span> + <span class='doccomment'>/// the <target> parameter is omitted, it is RECOMMENDED that TRACE</span> + <span class='doccomment'>/// command sends a message to the sender telling which servers the local</span> + <span class='doccomment'>/// server has direct connection to.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If the destination given by <target> is an actual server, the</span> + <span class='doccomment'>/// destination server is REQUIRED to report all servers, services and</span> + <span class='doccomment'>/// operators which are connected to it; if the command was issued by an</span> + <span class='doccomment'>/// operator, the server MAY also report all users which are connected to</span> + <span class='doccomment'>/// it. If the destination given by <target> is a nickname, then only a</span> + <span class='doccomment'>/// reply for that nickname is given. If the <target> parameter is</span> + <span class='doccomment'>/// omitted, it is RECOMMENDED that the TRACE command is parsed as</span> + <span class='doccomment'>/// targeted to the processing server.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Wildcards are allowed in the <target> parameter.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NOSUCHSERVER</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If the TRACE message is destined for another server, all</span> + <span class='doccomment'>/// intermediate servers must return a RPL_TRACELINK reply to indicate</span> + <span class='doccomment'>/// that the TRACE passed through it and where it is going next.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// RPL_TRACELINK</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// A TRACE reply may be composed of any number of the following</span> + <span class='doccomment'>/// numeric replies.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// RPL_TRACECONNECTING RPL_TRACEHANDSHAKE</span> + <span class='doccomment'>/// RPL_TRACEUNKNOWN RPL_TRACEOPERATOR</span> + <span class='doccomment'>/// RPL_TRACEUSER RPL_TRACESERVER</span> + <span class='doccomment'>/// RPL_TRACESERVICE RPL_TRACENEWTYPE</span> + <span class='doccomment'>/// RPL_TRACECLASS RPL_TRACELOG</span> + <span class='doccomment'>/// RPL_TRACEEND</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// TRACE *.oulu.fi ; TRACE to a server matching</span> + <span class='doccomment'>/// *.oulu.fi</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>TRACE</span>(<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.4.9 Admin command</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: ADMIN</span> + <span class='doccomment'>/// Parameters: [ <target> ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The admin command is used to find information about the administrator</span> + <span class='doccomment'>/// of the given server, or current server if <target> parameter is</span> + <span class='doccomment'>/// omitted. Each server MUST have the ability to forward ADMIN messages</span> + <span class='doccomment'>/// to other servers.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Wildcards are allowed in the <target> parameter.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NOSUCHSERVER</span> + <span class='doccomment'>/// RPL_ADMINME RPL_ADMINLOC1</span> + <span class='doccomment'>/// RPL_ADMINLOC2 RPL_ADMINEMAIL</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ADMIN tolsun.oulu.fi ; request an ADMIN reply from</span> + <span class='doccomment'>/// tolsun.oulu.fi</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ADMIN syrk ; ADMIN request for the server to</span> + <span class='doccomment'>/// which the user syrk is connected</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>ADMIN</span>(<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.4.10 Info command</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: INFO</span> + <span class='doccomment'>/// Parameters: [ <target> ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The INFO command is REQUIRED to return information describing the</span> + <span class='doccomment'>/// server: its version, when it was compiled, the patchlevel, when it</span> + <span class='doccomment'>/// was started, and any other miscellaneous information which may be</span> + <span class='doccomment'>/// considered to be relevant.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Wildcards are allowed in the <target> parameter.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NOSUCHSERVER</span> + <span class='doccomment'>/// RPL_INFO RPL_ENDOFINFO</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// INFO csd.bu.edu ; request an INFO reply from</span> + <span class='doccomment'>/// csd.bu.edu</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// INFO Angel ; request info from the server that</span> + <span class='doccomment'>/// Angel is connected to.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>INFO</span>(<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.5.1 Servlist message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: SERVLIST</span> + <span class='doccomment'>/// Parameters: [ <mask> [ <type> ] ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The SERVLIST command is used to list services currently connected to</span> + <span class='doccomment'>/// the network and visible to the user issuing the command. The</span> + <span class='doccomment'>/// optional parameters may be used to restrict the result of the query</span> + <span class='doccomment'>/// (to matching services names, and services type).</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// RPL_SERVLIST RPL_SERVLISTEND</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>SERVLIST</span>(<span class='prelude-ty'>Option</span><span class='op'><</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>)<span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.5.2 Squery</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: SQUERY</span> + <span class='doccomment'>/// Parameters: <servicename> <text></span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The SQUERY command is used similarly to PRIVMSG. The only difference</span> + <span class='doccomment'>/// is that the recipient MUST be a service. This is the only way for a</span> + <span class='doccomment'>/// text message to be delivered to a service.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// See PRIVMSG for more details on replies and example.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// SQUERY irchelp :HELP privmsg</span> + <span class='doccomment'>/// ; Message to the service with</span> + <span class='doccomment'>/// nickname irchelp.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// SQUERY dict@irc.fr :fr2en blaireau</span> + <span class='doccomment'>/// ; Message to the service with name</span> + <span class='doccomment'>/// dict@irc.fr.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>SQUERY</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.6.1 Who query</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: WHO</span> + <span class='doccomment'>/// Parameters: [ <mask> [ "o" ] ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The WHO command is used by a client to generate a query which returns</span> + <span class='doccomment'>/// a list of information which 'matches' the <mask> parameter given by</span> + <span class='doccomment'>/// the client. In the absence of the <mask> parameter, all visible</span> + <span class='doccomment'>/// (users who aren't invisible (user mode +i) and who don't have a</span> + <span class='doccomment'>/// common channel with the requesting client) are listed. The same</span> + <span class='doccomment'>/// result can be achieved by using a <mask> of "0" or any wildcard which</span> + <span class='doccomment'>/// will end up matching every visible user.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The <mask> passed to WHO is matched against users' host, server, real</span> + <span class='doccomment'>/// name and nickname if the channel <mask> cannot be found.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If the "o" parameter is passed only operators are returned according</span> + <span class='doccomment'>/// to the <mask> supplied.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NOSUCHSERVER</span> + <span class='doccomment'>/// RPL_WHOREPLY RPL_ENDOFWHO</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// WHO *.fi ; Command to list all users who match</span> + <span class='doccomment'>/// against "*.fi".</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// WHO jto* o ; Command to list all users with a</span> + <span class='doccomment'>/// match against "jto*" if they are an</span> + <span class='doccomment'>/// operator.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>WHO</span>(<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>, <span class='ident'>bool</span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.6.2 Whois query</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: WHOIS</span> + <span class='doccomment'>/// Parameters: [ <target> ] <mask> *( "," <mask> )</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This command is used to query information about particular user.</span> + <span class='doccomment'>/// The server will answer this command with several numeric messages</span> + <span class='doccomment'>/// indicating different statuses of each user which matches the mask (if</span> + <span class='doccomment'>/// you are entitled to see them). If no wildcard is present in the</span> + <span class='doccomment'>/// <mask>, any information about that nick which you are allowed to see</span> + <span class='doccomment'>/// is presented.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If the <target> parameter is specified, it sends the query to a</span> + <span class='doccomment'>/// specific server. It is useful if you want to know how long the user</span> + <span class='doccomment'>/// in question has been idle as only local server (i.e., the server the</span> + <span class='doccomment'>/// user is directly connected to) knows that information, while</span> + <span class='doccomment'>/// everything else is globally known.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Wildcards are allowed in the <target> parameter.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NOSUCHSERVER ERR_NONICKNAMEGIVEN</span> + <span class='doccomment'>/// RPL_WHOISUSER RPL_WHOISCHANNELS</span> + <span class='doccomment'>/// RPL_WHOISCHANNELS RPL_WHOISSERVER</span> + <span class='doccomment'>/// RPL_AWAY RPL_WHOISOPERATOR</span> + <span class='doccomment'>/// RPL_WHOISIDLE ERR_NOSUCHNICK</span> + <span class='doccomment'>/// RPL_ENDOFWHOIS</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// WHOIS wiz ; return available user information</span> + <span class='doccomment'>/// about nick WiZ</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// WHOIS eff.org trillian ; ask server eff.org for user</span> + <span class='doccomment'>/// information about trillian</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>WHOIS</span>(<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.6.3 Whowas</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: WHOWAS</span> + <span class='doccomment'>/// Parameters: <nickname> *( "," <nickname> ) [ <count> [ <target> ] ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Whowas asks for information about a nickname which no longer exists.</span> + <span class='doccomment'>/// This may either be due to a nickname change or the user leaving IRC.</span> + <span class='doccomment'>/// In response to this query, the server searches through its nickname</span> + <span class='doccomment'>/// history, looking for any nicks which are lexically the same (no wild</span> + <span class='doccomment'>/// card matching here). The history is searched backward, returning the</span> + <span class='doccomment'>/// most recent entry first. If there are multiple entries, up to</span> + <span class='doccomment'>/// <count> replies will be returned (or all of them if no <count></span> + <span class='doccomment'>/// parameter is given). If a non-positive number is passed as being</span> + <span class='doccomment'>/// <count>, then a full search is done.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Wildcards are allowed in the <target> parameter.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NONICKNAMEGIVEN ERR_WASNOSUCHNICK</span> + <span class='doccomment'>/// RPL_WHOWASUSER RPL_WHOISSERVER</span> + <span class='doccomment'>/// RPL_ENDOFWHOWAS</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// WHOWAS Wiz ; return all information in the nick</span> + <span class='doccomment'>/// history about nick "WiZ";</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// WHOWAS Mermaid 9 ; return at most, the 9 most recent</span> + <span class='doccomment'>/// entries in the nick history for</span> + <span class='doccomment'>/// "Mermaid";</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// WHOWAS Trillian 1 *.edu ; return the most recent history for</span> + <span class='doccomment'>/// "Trillian" from the first server</span> + <span class='doccomment'>/// found to match "*.edu".</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>WHOWAS</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>, <span class='prelude-ty'>Option</span><span class='op'><</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>)<span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.7.1 Kill message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: KILL</span> + <span class='doccomment'>/// Parameters: <nickname> <comment></span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The KILL command is used to cause a client-server connection to be</span> + <span class='doccomment'>/// closed by the server which has the actual connection. Servers</span> + <span class='doccomment'>/// generate KILL messages on nickname collisions. It MAY also be</span> + <span class='doccomment'>/// available available to users who have the operator status.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Clients which have automatic reconnect algorithms effectively make</span> + <span class='doccomment'>/// this command useless since the disconnection is only brief. It does</span> + <span class='doccomment'>/// however break the flow of data and can be used to stop large amounts</span> + <span class='doccomment'>/// of 'flooding' from abusive users or accidents. Abusive users usually</span> + <span class='doccomment'>/// don't care as they will reconnect promptly and resume their abusive</span> + <span class='doccomment'>/// behaviour. To prevent this command from being abused, any user may</span> + <span class='doccomment'>/// elect to receive KILL messages generated for others to keep an 'eye'</span> + <span class='doccomment'>/// on would be trouble spots.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// In an arena where nicknames are REQUIRED to be globally unique at all</span> + <span class='doccomment'>/// times, KILL messages are sent whenever 'duplicates' are detected</span> + <span class='doccomment'>/// (that is an attempt to register two users with the same nickname) in</span> + <span class='doccomment'>/// the hope that both of them will disappear and only 1 reappear.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// When a client is removed as the result of a KILL message, the server</span> + <span class='doccomment'>/// SHOULD add the nickname to the list of unavailable nicknames in an</span> + <span class='doccomment'>/// attempt to avoid clients to reuse this name immediately which is</span> + <span class='doccomment'>/// usually the pattern of abusive behaviour often leading to useless</span> + <span class='doccomment'>/// "KILL loops". See the "IRC Server Protocol" document [IRC-SERVER]</span> + <span class='doccomment'>/// for more information on this procedure.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The comment given MUST reflect the actual reason for the KILL. For</span> + <span class='doccomment'>/// server-generated KILLs it usually is made up of details concerning</span> + <span class='doccomment'>/// the origins of the two conflicting nicknames. For users it is left</span> + <span class='doccomment'>/// up to them to provide an adequate reason to satisfy others who see</span> + <span class='doccomment'>/// it. To prevent/discourage fake KILLs from being generated to hide</span> + <span class='doccomment'>/// the identify of the KILLer, the comment also shows a 'kill-path'</span> + <span class='doccomment'>/// which is updated by each server it passes through, each prepending</span> + <span class='doccomment'>/// its name to the path.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NOPRIVILEGES ERR_NEEDMOREPARAMS</span> + <span class='doccomment'>/// ERR_NOSUCHNICK ERR_CANTKILLSERVER</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// NOTE:</span> + <span class='doccomment'>/// It is RECOMMENDED that only Operators be allowed to kill other users</span> + <span class='doccomment'>/// with KILL command. This command has been the subject of many</span> + <span class='doccomment'>/// controversies over the years, and along with the above</span> + <span class='doccomment'>/// recommendation, it is also widely recognized that not even operators</span> + <span class='doccomment'>/// should be allowed to kill users on remote servers.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>KILL</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.7.2 Ping message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: PING</span> + <span class='doccomment'>/// Parameters: <server1> [ <server2> ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The PING command is used to test the presence of an active client or</span> + <span class='doccomment'>/// server at the other end of the connection. Servers send a PING</span> + <span class='doccomment'>/// message at regular intervals if no other activity detected coming</span> + <span class='doccomment'>/// from a connection. If a connection fails to respond to a PING</span> + <span class='doccomment'>/// message within a set amount of time, that connection is closed. A</span> + <span class='doccomment'>/// PING message MAY be sent even if the connection is active.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// When a PING message is received, the appropriate PONG message MUST be</span> + <span class='doccomment'>/// sent as reply to <server1> (server which sent the PING message out)</span> + <span class='doccomment'>/// as soon as possible. If the <server2> parameter is specified, it</span> + <span class='doccomment'>/// represents the target of the ping, and the message gets forwarded</span> + <span class='doccomment'>/// there.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NOORIGIN ERR_NOSUCHSERVER</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// PING tolsun.oulu.fi ; Command to send a PING message to</span> + <span class='doccomment'>/// server</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// PING WiZ tolsun.oulu.fi ; Command from WiZ to send a PING</span> + <span class='doccomment'>/// message to server "tolsun.oulu.fi"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// PING :irc.funet.fi ; Ping message sent by server</span> + <span class='doccomment'>/// "irc.funet.fi"</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>PING</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.7.3 Pong message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: PONG</span> + <span class='doccomment'>/// Parameters: <server> [ <server2> ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// PONG message is a reply to ping message. If parameter <server2> is</span> + <span class='doccomment'>/// given, this message MUST be forwarded to given target. The <server></span> + <span class='doccomment'>/// parameter is the name of the entity who has responded to PING message</span> + <span class='doccomment'>/// and generated this message.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NOORIGIN ERR_NOSUCHSERVER</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Example:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// PONG csd.bu.edu tolsun.oulu.fi ; PONG message from csd.bu.edu to</span> + <span class='doccomment'>/// tolsun.oulu.fi</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>PONG</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 3.7.4 Error</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: ERROR</span> + <span class='doccomment'>/// Parameters: <error message></span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The ERROR command is for use by servers when reporting a serious or</span> + <span class='doccomment'>/// fatal error to its peers. It may also be sent from one server to</span> + <span class='doccomment'>/// another but MUST NOT be accepted from any normal unknown clients.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Only an ERROR message SHOULD be used for reporting errors which occur</span> + <span class='doccomment'>/// with a server-to-server link. An ERROR message is sent to the server</span> + <span class='doccomment'>/// at the other end (which reports it to appropriate local users and</span> + <span class='doccomment'>/// logs) and to appropriate local users and logs. It is not to be</span> + <span class='doccomment'>/// passed onto any other servers by a server if it is received from a</span> + <span class='doccomment'>/// server.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The ERROR message is also used before terminating a client</span> + <span class='doccomment'>/// connection.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// When a server sends a received ERROR message to its operators, the</span> + <span class='doccomment'>/// message SHOULD be encapsulated inside a NOTICE message, indicating</span> + <span class='doccomment'>/// that the client was not responsible for the error.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numerics:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// None.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERROR :Server *.fi already exists ; ERROR message to the other server</span> + <span class='doccomment'>/// which caused this error.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// NOTICE WiZ :ERROR from csd.bu.edu -- Server *.fi already exists</span> + <span class='doccomment'>/// ; Same ERROR message as above but</span> + <span class='doccomment'>/// sent to user WiZ on the other server.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>ERROR</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 4.1 Away</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: AWAY</span> + <span class='doccomment'>/// Parameters: [ <text> ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// With the AWAY command, clients can set an automatic reply string for</span> + <span class='doccomment'>/// any PRIVMSG commands directed at them (not to a channel they are on).</span> + <span class='doccomment'>/// The server sends an automatic reply to the client sending the PRIVMSG</span> + <span class='doccomment'>/// command. The only replying server is the one to which the sending</span> + <span class='doccomment'>/// client is connected to.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The AWAY command is used either with one parameter, to set an AWAY</span> + <span class='doccomment'>/// message, or with no parameters, to remove the AWAY message.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Because of its high cost (memory and bandwidth wise), the AWAY</span> + <span class='doccomment'>/// message SHOULD only be used for client-server communication. A</span> + <span class='doccomment'>/// server MAY choose to silently ignore AWAY messages received from</span> + <span class='doccomment'>/// other servers. To update the away status of a client across servers,</span> + <span class='doccomment'>/// the user mode 'a' SHOULD be used instead. (See Section 3.1.5)</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// RPL_UNAWAY RPL_NOWAWAY</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Example:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// AWAY :Gone to lunch. Back in 5 ; Command to set away message to</span> + <span class='doccomment'>/// "Gone to lunch. Back in 5".</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>AWAY</span>(<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 4.2 Rehash message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: REHASH</span> + <span class='doccomment'>/// Parameters: None</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The rehash command is an administrative command which can be used by</span> + <span class='doccomment'>/// an operator to force the server to re-read and process its</span> + <span class='doccomment'>/// configuration file.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// RPL_REHASHING ERR_NOPRIVILEGES</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Example:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// REHASH ; message from user with operator</span> + <span class='doccomment'>/// status to server asking it to reread</span> + <span class='doccomment'>/// its configuration file.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>REHASH</span>, + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 4.3 Die message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: DIE</span> + <span class='doccomment'>/// Parameters: None</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// An operator can use the DIE command to shutdown the server. This</span> + <span class='doccomment'>/// message is optional since it may be viewed as a risk to allow</span> + <span class='doccomment'>/// arbitrary people to connect to a server as an operator and execute</span> + <span class='doccomment'>/// this command.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The DIE command MUST always be fully processed by the server to which</span> + <span class='doccomment'>/// the sending client is connected and MUST NOT be passed onto other</span> + <span class='doccomment'>/// connected servers.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NOPRIVILEGES</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Example:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// DIE ; no parameters required.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>DIE</span>, + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 4.4 Restart message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: RESTART</span> + <span class='doccomment'>/// Parameters: None</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// An operator can use the restart command to force the server to</span> + <span class='doccomment'>/// restart itself. This message is optional since it may be viewed as a</span> + <span class='doccomment'>/// risk to allow arbitrary people to connect to a server as an operator</span> + <span class='doccomment'>/// and execute this command, causing (at least) a disruption to service.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The RESTART command MUST always be fully processed by the server to</span> + <span class='doccomment'>/// which the sending client is connected and MUST NOT be passed onto</span> + <span class='doccomment'>/// other connected servers.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NOPRIVILEGES</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Example:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// RESTART ; no parameters required.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>RESTART</span>, + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 4.5 Summon message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: SUMMON</span> + <span class='doccomment'>/// Parameters: <user> [ <target> [ <channel> ] ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The SUMMON command can be used to give users who are on a host</span> + <span class='doccomment'>/// running an IRC server a message asking them to please join IRC. This</span> + <span class='doccomment'>/// message is only sent if the target server (a) has SUMMON enabled, (b)</span> + <span class='doccomment'>/// the user is logged in and (c) the server process can write to the</span> + <span class='doccomment'>/// user's tty (or similar).</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If no <server> parameter is given it tries to summon <user> from the</span> + <span class='doccomment'>/// server the client is connected to is assumed as the target.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If summon is not enabled in a server, it MUST return the</span> + <span class='doccomment'>/// ERR_SUMMONDISABLED numeric.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NORECIPIENT ERR_FILEERROR</span> + <span class='doccomment'>/// ERR_NOLOGIN ERR_NOSUCHSERVER</span> + <span class='doccomment'>/// ERR_SUMMONDISABLED RPL_SUMMONING</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Examples:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// SUMMON jto ; summon user jto on the server's</span> + <span class='doccomment'>/// host</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// SUMMON jto tolsun.oulu.fi ; summon user jto on the host which a</span> + <span class='doccomment'>/// server named "tolsun.oulu.fi" is</span> + <span class='doccomment'>/// running.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>SUMMON</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='prelude-ty'>Option</span><span class='op'><</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>)<span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 4.6 Users</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: USERS</span> + <span class='doccomment'>/// Parameters: [ <target> ]</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The USERS command returns a list of users logged into the server in a</span> + <span class='doccomment'>/// format similar to the UNIX commands who(1), rusers(1) and finger(1).</span> + <span class='doccomment'>/// If disabled, the correct numeric MUST be returned to indicate this.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Because of the security implications of such a command, it SHOULD be</span> + <span class='doccomment'>/// disabled by default in server implementations. Enabling it SHOULD</span> + <span class='doccomment'>/// require recompiling the server or some equivalent change rather than</span> + <span class='doccomment'>/// simply toggling an option and restarting the server. The procedure</span> + <span class='doccomment'>/// to enable this command SHOULD also include suitable large comments.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NOSUCHSERVER ERR_FILEERROR</span> + <span class='doccomment'>/// RPL_USERSSTART RPL_USERS</span> + <span class='doccomment'>/// RPL_NOUSERS RPL_ENDOFUSERS</span> + <span class='doccomment'>/// ERR_USERSDISABLED</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Disabled Reply:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_USERSDISABLED</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Example:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// USERS eff.org ; request a list of users logged in</span> + <span class='doccomment'>/// on server eff.org</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>USERS</span>(<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 4.7 Operwall message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: WALLOPS</span> + <span class='doccomment'>/// Parameters: <Text to be sent></span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The WALLOPS command is used to send a message to all currently</span> + <span class='doccomment'>/// connected users who have set the 'w' user mode for themselves. (See</span> + <span class='doccomment'>/// Section 3.1.5 "User modes").</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// After implementing WALLOPS as a user command it was found that it was</span> + <span class='doccomment'>/// often and commonly abused as a means of sending a message to a lot of</span> + <span class='doccomment'>/// people. Due to this, it is RECOMMENDED that the implementation of</span> + <span class='doccomment'>/// WALLOPS allows and recognizes only servers as the originators of</span> + <span class='doccomment'>/// WALLOPS.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ERR_NEEDMOREPARAMS</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Example:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// :csd.bu.edu WALLOPS :Connect '*.uiuc.edu 6667' from Joshua ; WALLOPS</span> + <span class='doccomment'>/// message from csd.bu.edu announcing a</span> + <span class='doccomment'>/// CONNECT message it received from</span> + <span class='doccomment'>/// Joshua and acted upon.</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>WALLOPS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// ```text</span> + <span class='doccomment'>/// 4.8 Userhost message</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Command: USERHOST</span> + <span class='doccomment'>/// Parameters: <nickname> *( SPACE <nickname> )</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The USERHOST command takes a list of up to 5 nicknames, each</span> + <span class='doccomment'>/// separated by a space character and returns a list of information</span> + <span class='doccomment'>/// about each nickname that it found. The returned list has each reply</span> + <span class='doccomment'>/// separated by a space.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Numeric Replies:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// RPL_USERHOST ERR_NEEDMOREPARAMS</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Example:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// USERHOST Wiz Michael syrk ; USERHOST request for information on</span> + <span class='doccomment'>/// nicks "Wiz", "Michael", and "syrk"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// :ircd.stealth.net 302 yournick :syrk=+syrk@millennium.stealth.net</span> + <span class='doccomment'>/// ; Reply for user syrk</span> + <span class='doccomment'>/// ```</span> + <span class='ident'>USERHOST</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span>), +} + +<span class='comment'>/*impl<'a> Clone for Command<'a> { + fn clone(&self) -> Command<'a> { + use self::Command::*; + match self { + &PASS(ref pw) => PASS(pw.to_owned().clone()), + /*&NICK(ref nick) => + Message::format(None, Borrowed("NICK"), vec![], Some(nick.clone()), MsgType::Irc), + &USER(ref user, ref mode, ref unused, ref realname) => + Message::format(None, Borrowed("USER"), + vec![user.clone(), mode.clone(), unused.clone()], + Some(realname.clone()), MsgType::Irc), + &OPER(ref name, ref pw) => + Message::format(None, Borrowed("OPER"), + vec![name.clone(), pw.clone()], None, MsgType::Irc), + &UMODE(ref mode) => + Message::format(None, Borrowed("MODE"), vec![], Some(mode.clone()), MsgType::Irc), + &SERVICE(ref nick, ref reserved, ref distribution, ref type_, ref reserved2, ref info) => + Message::format(None, Borrowed("SERVICE"), + vec![nick.clone(), reserved.clone(), distribution.clone(), + type_.clone(), reserved2.clone()], Some(info.clone()), MsgType::Irc), + &QUIT(ref msg) => + Message::format(None, Borrowed("QUIT"), vec![], msg.clone(), MsgType::Irc), + &SQUIT(ref server, ref comment) => + Message::format(None, Borrowed("SQUIT"), + vec![server.clone()], Some(comment.clone()), MsgType::Irc), + &JOIN(ref ch, ref pw) => + Message::format(None, Borrowed("JOIN"), + vec![Owned(ch.connect(",")), Owned(pw.connect(","))], None, MsgType::Irc), + &PART(ref ch, ref reason) => + Message::format(None, Borrowed("PART"), + vec![Owned(ch.connect(","))], reason.clone(), MsgType::Irc), + &MODE(ref channel, ref modes) => + // Screw this, folding will have to do. + Message::format(None, Borrowed("MODE"), + modes.iter().fold(vec![channel.clone()], |mut v, &(ref a, ref b)| { + v.push(a.clone()); + v.push(b.clone()); + v + }), None, MsgType::Irc), + &TOPIC(ref channel, ref topic) => + Message::format(None, Borrowed("TOPIC"), + vec![channel.clone()], topic.clone(), MsgType::Irc), + &NAMES(ref ch, ref target) => + Message::format(None, Borrowed("NAMES"), + vec![Owned(ch.connect(","))], target.clone(), MsgType::Irc), + &LIST(ref ch, ref target) => + Message::format(None, Borrowed("LIST"), + vec![Owned(ch.connect(","))], target.clone(), MsgType::Irc), + &INVITE(ref nick, ref channel) => + Message::format(None, Borrowed("INVITE"), + vec![nick.clone()], Some(channel.clone()), MsgType::Irc), + &KICK(ref ch, ref users, ref comment) => + Message::format(None, Borrowed("KICK"), + vec![Owned(ch.connect(",")), Owned(users.connect(","))], + comment.clone(), MsgType::Irc), + &PRIVMSG(ref target, ref msg) => + Message::format(None, Borrowed("PRIVMSG"), + vec![target.clone()], Some(msg.clone()), MsgType::Irc), + &NOTICE(ref target, ref text) => + Message::format(None, Borrowed("NOTICE"), + vec![target.clone()], Some(text.clone()), MsgType::Irc), + &MOTD(ref target) => + Message::format(None, Borrowed("MOTD"), vec![], target.clone(), MsgType::Irc), + &LUSERS(ref lu) => + Message::format(None, Borrowed("LUSERS"), + lu.as_ref().map(|&(ref mask, _)| vec![mask.clone()]).unwrap_or(vec![]), + lu.as_ref().and_then(|&(_, ref target)| target.clone()), MsgType::Irc), + &VERSION(ref target) => + Message::format(None, Borrowed("VERSION"), vec![], target.clone(), MsgType::Irc), + &STATS(ref st) => + Message::format(None, Borrowed("STATS"), + st.as_ref().map(|&(ref query, _)| vec![query.clone()]).unwrap_or(vec![]), + st.as_ref().and_then(|&(_, ref target)| target.clone()), MsgType::Irc), + &LINKS(ref l) => + Message::format(None, Borrowed("LINKS"), + l.as_ref().map(|&(ref remote, ref mask)| if remote.is_some() { + vec![remote.clone().unwrap(), mask.clone()] } else { vec![mask.clone()] }).unwrap_or(vec![]), + None, MsgType::Irc), + &TIME(ref target) => + Message::format(None, Borrowed("TIME"), vec![], target.clone(), MsgType::Irc), + &CONNECT(ref server, ref port, ref remote) => + Message::format(None, Borrowed("CONNECT"), + vec![server.clone(), Owned(format!("{}", port))], remote.clone(), MsgType::Irc), + &TRACE(ref target) => + Message::format(None, Borrowed("TRACE"), vec![], target.clone(), MsgType::Irc), + &ADMIN(ref target) => + Message::format(None, Borrowed("ADMIN"), vec![], target.clone(), MsgType::Irc), + &INFO(ref target) => + Message::format(None, Borrowed("INFO"), vec![], target.clone(), MsgType::Irc), + &SERVLIST(ref sl) => + Message::format(None, Borrowed("SERVLIST"), + sl.as_ref().map(|&(ref mask, ref target)| target.as_ref() + .map(|t| vec![mask.clone(), t.clone()]) + .unwrap_or_else(|| vec![mask.clone()])) + .unwrap_or(vec![]), None, MsgType::Irc), + &SQUERY(ref name, ref text) => + Message::format(None, Borrowed("SQUERY"), + vec![name.clone()], Some(text.clone()), MsgType::Irc), + &WHO(ref mask, o) => + Message::format(None, Borrowed("WHO"), + match (mask, o) { + (&Some(ref m), true) => vec![m.clone(), Borrowed("o")], + (&Some(ref m), false) => vec![m.clone()], + (&None, _) => vec![] + }, None, MsgType::Irc), + &WHOIS(ref target, ref masks) => + Message::format(None, Borrowed("WHOIS"), + target.as_ref().map(|t| vec![t.clone(), Owned(masks.connect(","))]) + .unwrap_or_else(|| vec![Owned(masks.connect(","))]), None, MsgType::Irc), + &WHOWAS(ref nick, ref count) => + Message::format(None, Borrowed("WHOWAS"), match count { + &Some((ref c, Some(ref t))) => vec![Owned(nick.connect(",")), c.clone(), t.clone()], + &Some((ref c, None)) => vec![Owned(nick.connect(",")), c.clone()], + &None => vec![Owned(nick.connect(","))] + }, None, MsgType::Irc), + &PING(ref s1, ref s2) => + Message::format(None, Borrowed("PING"), vec![s1.clone()], s2.clone(), MsgType::Irc), + &PONG(ref s1, ref s2) => + Message::format(None, Borrowed("PONG"), vec![s1.clone()], s2.clone(), MsgType::Irc), + */ /*&Command::PING(ref server1, ref server2) => { + let mut c = Vec::new(); + c.push(server1.clone()); + if let &Some(ref s) = server2 { c.push(s.clone()) } + Message::format(None, "PING", c, None, MsgType::Irc) + }, + &Command::PONG(ref server1, ref server2) => { + let mut c = Vec::new(); + c.push(server1.clone()); + if let &Some(ref s) = server2 { c.push(s.clone()) } + Message::format(None, "PONG", c, None, MsgType::Irc) + },*/ + _ => unimplemented!() + } + + } +}*/</span> + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>Command</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>from_message</span>(<span class='ident'>msg</span>: <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>Message</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Command</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span> { + <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>Command</span>::<span class='op'>*</span>; + <span class='kw'>match</span> <span class='ident'>msg</span>.<span class='ident'>command</span>() { + <span class='string'>"PASS"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>m</span><span class='op'>|</span> <span class='ident'>m</span>).<span class='ident'>map</span>(<span class='ident'>Borrowed</span>).<span class='ident'>map</span>(<span class='ident'>PASS</span>), + <span class='string'>"NICK"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>suffix</span>().<span class='ident'>or_else</span>(<span class='op'>||</span> <span class='ident'>msg</span>.<span class='ident'>content</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>m</span><span class='op'>|</span> <span class='ident'>m</span>)) + .<span class='ident'>map</span>(<span class='ident'>Borrowed</span>).<span class='ident'>map</span>(<span class='ident'>NICK</span>), + <span class='string'>"USER"</span> <span class='op'>=></span> <span class='kw'>if</span> <span class='kw'>let</span> [<span class='ident'>user</span>, <span class='ident'>mode</span>, <span class='ident'>unused</span>, <span class='ident'>realname</span>, ..] <span class='op'>=</span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>as_ref</span>() { + <span class='prelude-val'>Some</span>(<span class='ident'>USER</span>(<span class='ident'>Borrowed</span>(<span class='ident'>user</span>), <span class='ident'>Borrowed</span>(<span class='ident'>mode</span>), + <span class='ident'>Borrowed</span>(<span class='ident'>unused</span>), <span class='ident'>Borrowed</span>(<span class='ident'>realname</span>))) + } <span class='kw'>else</span> { <span class='prelude-val'>None</span> }, + <span class='string'>"OPER"</span> <span class='op'>=></span> <span class='kw'>if</span> <span class='kw'>let</span> [<span class='ident'>name</span>, <span class='ident'>pw</span>, ..] <span class='op'>=</span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>as_ref</span>() { + <span class='prelude-val'>Some</span>(<span class='ident'>OPER</span>(<span class='ident'>Borrowed</span>(<span class='ident'>name</span>), <span class='ident'>Borrowed</span>(<span class='ident'>pw</span>))) + } <span class='kw'>else</span> { <span class='prelude-val'>None</span> }, + <span class='string'>"PING"</span> <span class='op'>=></span> { + <span class='kw'>let</span> <span class='ident'>e</span> <span class='op'>=</span> <span class='ident'>msg</span>.<span class='ident'>elements</span>(); + <span class='ident'>e</span>.<span class='ident'>first</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>s1</span><span class='op'>|</span> <span class='ident'>PING</span>(<span class='ident'>Borrowed</span>(<span class='ident'>s1</span>), <span class='ident'>e</span>.<span class='ident'>get</span>(<span class='number'>1</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>m</span><span class='op'>|</span> <span class='ident'>m</span>).<span class='ident'>map</span>(<span class='ident'>Borrowed</span>))) + }, + <span class='string'>"PONG"</span> <span class='op'>=></span> { + <span class='kw'>let</span> <span class='ident'>e</span> <span class='op'>=</span> <span class='ident'>msg</span>.<span class='ident'>elements</span>(); + <span class='ident'>e</span>.<span class='ident'>first</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>s1</span><span class='op'>|</span> <span class='ident'>PONG</span>(<span class='ident'>Borrowed</span>(<span class='ident'>s1</span>), <span class='ident'>e</span>.<span class='ident'>get</span>(<span class='number'>1</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>m</span><span class='op'>|</span> <span class='ident'>m</span>).<span class='ident'>map</span>(<span class='ident'>Borrowed</span>))) + }, + <span class='string'>"JOIN"</span> <span class='op'>=></span> <span class='kw'>if</span> <span class='kw'>let</span> [<span class='ident'>ch</span>, <span class='ident'>pw</span>, ..] <span class='op'>=</span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>as_ref</span>() { + <span class='prelude-val'>Some</span>(<span class='ident'>JOIN</span>(<span class='ident'>ch</span>.<span class='ident'>split</span>(<span class='string'>","</span>).<span class='ident'>map</span>(<span class='ident'>Borrowed</span>).<span class='ident'>collect</span>(), + <span class='ident'>pw</span>.<span class='ident'>split</span>(<span class='string'>","</span>).<span class='ident'>map</span>(<span class='ident'>Borrowed</span>).<span class='ident'>collect</span>())) + } <span class='kw'>else</span> { <span class='prelude-val'>None</span> }, + <span class='string'>"PART"</span> <span class='op'>=></span> <span class='kw'>if</span> <span class='kw'>let</span> [<span class='ident'>ch</span>, <span class='ident'>reason</span>..] <span class='op'>=</span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>as_ref</span>() { + <span class='prelude-val'>Some</span>(<span class='ident'>PART</span>(<span class='ident'>ch</span>.<span class='ident'>split</span>(<span class='string'>","</span>).<span class='ident'>map</span>(<span class='ident'>Borrowed</span>).<span class='ident'>collect</span>(), + <span class='ident'>reason</span>.<span class='ident'>first</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>m</span><span class='op'>|</span> <span class='ident'>m</span>).<span class='ident'>map</span>(<span class='ident'>Borrowed</span>))) + } <span class='kw'>else</span> { <span class='prelude-val'>None</span> }, + <span class='string'>"PRIVMSG"</span> <span class='op'>=></span> <span class='kw'>if</span> <span class='kw'>let</span> [<span class='ident'>target</span>, <span class='ident'>msg</span>, ..] <span class='op'>=</span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>as_ref</span>() { + <span class='prelude-val'>Some</span>(<span class='ident'>PRIVMSG</span>(<span class='ident'>Borrowed</span>(<span class='ident'>target</span>), <span class='ident'>Borrowed</span>(<span class='ident'>msg</span>))) + } <span class='kw'>else</span> { <span class='prelude-val'>None</span> }, + <span class='string'>"NOTICE"</span> <span class='op'>=></span> <span class='kw'>if</span> <span class='kw'>let</span> [<span class='ident'>target</span>, <span class='ident'>msg</span>, ..] <span class='op'>=</span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>as_ref</span>() { + <span class='prelude-val'>Some</span>(<span class='ident'>NOTICE</span>(<span class='ident'>Borrowed</span>(<span class='ident'>target</span>), <span class='ident'>Borrowed</span>(<span class='ident'>msg</span>))) + } <span class='kw'>else</span> { <span class='prelude-val'>None</span> }, + _ <span class='op'>=></span> <span class='prelude-val'>None</span> + } + } + + <span class='doccomment'>/// It started out pretty, but was quickly infested with `ref` and cloning.</span> + <span class='doccomment'>/// I'm sorry, this one might not make it.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>to_message</span>(<span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Message</span> { + <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>Command</span>::<span class='op'>*</span>; + <span class='kw'>match</span> <span class='self'>self</span> { + <span class='kw-2'>&</span><span class='ident'>PASS</span>(<span class='kw-2'>ref</span> <span class='ident'>pw</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"PASS"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>pw</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>NICK</span>(<span class='kw-2'>ref</span> <span class='ident'>nick</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"NICK"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>nick</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>USER</span>(<span class='kw-2'>ref</span> <span class='ident'>user</span>, <span class='kw-2'>ref</span> <span class='ident'>mode</span>, <span class='kw-2'>ref</span> <span class='ident'>unused</span>, <span class='kw-2'>ref</span> <span class='ident'>realname</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"USER"</span>), + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>user</span>.<span class='ident'>clone</span>(), <span class='ident'>mode</span>.<span class='ident'>clone</span>(), <span class='ident'>unused</span>.<span class='ident'>clone</span>()], + <span class='prelude-val'>Some</span>(<span class='ident'>realname</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>OPER</span>(<span class='kw-2'>ref</span> <span class='ident'>name</span>, <span class='kw-2'>ref</span> <span class='ident'>pw</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"OPER"</span>), + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>name</span>.<span class='ident'>clone</span>(), <span class='ident'>pw</span>.<span class='ident'>clone</span>()], <span class='prelude-val'>None</span>, <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>UMODE</span>(<span class='kw-2'>ref</span> <span class='ident'>mode</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"MODE"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>mode</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>SERVICE</span>(<span class='kw-2'>ref</span> <span class='ident'>nick</span>, <span class='kw-2'>ref</span> <span class='ident'>reserved</span>, <span class='kw-2'>ref</span> <span class='ident'>distribution</span>, <span class='kw-2'>ref</span> <span class='ident'>type_</span>, <span class='kw-2'>ref</span> <span class='ident'>reserved2</span>, <span class='kw-2'>ref</span> <span class='ident'>info</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"SERVICE"</span>), + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>nick</span>.<span class='ident'>clone</span>(), <span class='ident'>reserved</span>.<span class='ident'>clone</span>(), <span class='ident'>distribution</span>.<span class='ident'>clone</span>(), + <span class='ident'>type_</span>.<span class='ident'>clone</span>(), <span class='ident'>reserved2</span>.<span class='ident'>clone</span>()], <span class='prelude-val'>Some</span>(<span class='ident'>info</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>QUIT</span>(<span class='kw-2'>ref</span> <span class='ident'>msg</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"QUIT"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='ident'>msg</span>.<span class='ident'>clone</span>(), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>SQUIT</span>(<span class='kw-2'>ref</span> <span class='ident'>server</span>, <span class='kw-2'>ref</span> <span class='ident'>comment</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"SQUIT"</span>), + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>server</span>.<span class='ident'>clone</span>()], <span class='prelude-val'>Some</span>(<span class='ident'>comment</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>JOIN</span>(<span class='kw-2'>ref</span> <span class='ident'>ch</span>, <span class='kw-2'>ref</span> <span class='ident'>pw</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"JOIN"</span>), + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>Owned</span>(<span class='ident'>ch</span>.<span class='ident'>connect</span>(<span class='string'>","</span>)), <span class='ident'>Owned</span>(<span class='ident'>pw</span>.<span class='ident'>connect</span>(<span class='string'>","</span>))], <span class='prelude-val'>None</span>, <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>PART</span>(<span class='kw-2'>ref</span> <span class='ident'>ch</span>, <span class='kw-2'>ref</span> <span class='ident'>reason</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"PART"</span>), + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>Owned</span>(<span class='ident'>ch</span>.<span class='ident'>connect</span>(<span class='string'>","</span>))], <span class='ident'>reason</span>.<span class='ident'>clone</span>(), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>MODE</span>(<span class='kw-2'>ref</span> <span class='ident'>channel</span>, <span class='kw-2'>ref</span> <span class='ident'>modes</span>) <span class='op'>=></span> + <span class='comment'>// Screw this, folding will have to do.</span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"MODE"</span>), + <span class='ident'>modes</span>.<span class='ident'>iter</span>().<span class='ident'>fold</span>(<span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>channel</span>.<span class='ident'>clone</span>()], <span class='op'>|</span><span class='kw-2'>mut</span> <span class='ident'>v</span>, <span class='kw-2'>&</span>(<span class='kw-2'>ref</span> <span class='ident'>a</span>, <span class='kw-2'>ref</span> <span class='ident'>b</span>)<span class='op'>|</span> { + <span class='ident'>v</span>.<span class='ident'>push</span>(<span class='ident'>a</span>.<span class='ident'>clone</span>()); + <span class='ident'>v</span>.<span class='ident'>push</span>(<span class='ident'>b</span>.<span class='ident'>clone</span>()); + <span class='ident'>v</span> + }), <span class='prelude-val'>None</span>, <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>TOPIC</span>(<span class='kw-2'>ref</span> <span class='ident'>channel</span>, <span class='kw-2'>ref</span> <span class='ident'>topic</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"TOPIC"</span>), + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>channel</span>.<span class='ident'>clone</span>()], <span class='ident'>topic</span>.<span class='ident'>clone</span>(), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>NAMES</span>(<span class='kw-2'>ref</span> <span class='ident'>ch</span>, <span class='kw-2'>ref</span> <span class='ident'>target</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"NAMES"</span>), + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>Owned</span>(<span class='ident'>ch</span>.<span class='ident'>connect</span>(<span class='string'>","</span>))], <span class='ident'>target</span>.<span class='ident'>clone</span>(), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>LIST</span>(<span class='kw-2'>ref</span> <span class='ident'>ch</span>, <span class='kw-2'>ref</span> <span class='ident'>target</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"LIST"</span>), + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>Owned</span>(<span class='ident'>ch</span>.<span class='ident'>connect</span>(<span class='string'>","</span>))], <span class='ident'>target</span>.<span class='ident'>clone</span>(), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>INVITE</span>(<span class='kw-2'>ref</span> <span class='ident'>nick</span>, <span class='kw-2'>ref</span> <span class='ident'>channel</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"INVITE"</span>), + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>nick</span>.<span class='ident'>clone</span>()], <span class='prelude-val'>Some</span>(<span class='ident'>channel</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>KICK</span>(<span class='kw-2'>ref</span> <span class='ident'>ch</span>, <span class='kw-2'>ref</span> <span class='ident'>users</span>, <span class='kw-2'>ref</span> <span class='ident'>comment</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"KICK"</span>), + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>Owned</span>(<span class='ident'>ch</span>.<span class='ident'>connect</span>(<span class='string'>","</span>)), <span class='ident'>Owned</span>(<span class='ident'>users</span>.<span class='ident'>connect</span>(<span class='string'>","</span>))], + <span class='ident'>comment</span>.<span class='ident'>clone</span>(), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>PRIVMSG</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>, <span class='kw-2'>ref</span> <span class='ident'>msg</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"PRIVMSG"</span>), + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>target</span>.<span class='ident'>clone</span>()], <span class='prelude-val'>Some</span>(<span class='ident'>msg</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>NOTICE</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>, <span class='kw-2'>ref</span> <span class='ident'>text</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"NOTICE"</span>), + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>target</span>.<span class='ident'>clone</span>()], <span class='prelude-val'>Some</span>(<span class='ident'>text</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>MOTD</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"MOTD"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='ident'>target</span>.<span class='ident'>clone</span>(), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>LUSERS</span>(<span class='kw-2'>ref</span> <span class='ident'>lu</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"LUSERS"</span>), + <span class='ident'>lu</span>.<span class='ident'>as_ref</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span>(<span class='kw-2'>ref</span> <span class='ident'>mask</span>, _)<span class='op'>|</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>mask</span>.<span class='ident'>clone</span>()]).<span class='ident'>unwrap_or</span>(<span class='macro'>vec</span><span class='macro'>!</span>[]), + <span class='ident'>lu</span>.<span class='ident'>as_ref</span>().<span class='ident'>and_then</span>(<span class='op'>|</span><span class='kw-2'>&</span>(_, <span class='kw-2'>ref</span> <span class='ident'>target</span>)<span class='op'>|</span> <span class='ident'>target</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>VERSION</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"VERSION"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='ident'>target</span>.<span class='ident'>clone</span>(), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>STATS</span>(<span class='kw-2'>ref</span> <span class='ident'>st</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"STATS"</span>), + <span class='ident'>st</span>.<span class='ident'>as_ref</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span>(<span class='kw-2'>ref</span> <span class='ident'>query</span>, _)<span class='op'>|</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>query</span>.<span class='ident'>clone</span>()]).<span class='ident'>unwrap_or</span>(<span class='macro'>vec</span><span class='macro'>!</span>[]), + <span class='ident'>st</span>.<span class='ident'>as_ref</span>().<span class='ident'>and_then</span>(<span class='op'>|</span><span class='kw-2'>&</span>(_, <span class='kw-2'>ref</span> <span class='ident'>target</span>)<span class='op'>|</span> <span class='ident'>target</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>LINKS</span>(<span class='kw-2'>ref</span> <span class='ident'>l</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"LINKS"</span>), + <span class='ident'>l</span>.<span class='ident'>as_ref</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span>(<span class='kw-2'>ref</span> <span class='ident'>remote</span>, <span class='kw-2'>ref</span> <span class='ident'>mask</span>)<span class='op'>|</span> <span class='kw'>if</span> <span class='ident'>remote</span>.<span class='ident'>is_some</span>() { + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>remote</span>.<span class='ident'>clone</span>().<span class='ident'>unwrap</span>(), <span class='ident'>mask</span>.<span class='ident'>clone</span>()] } <span class='kw'>else</span> { <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>mask</span>.<span class='ident'>clone</span>()] }).<span class='ident'>unwrap_or</span>(<span class='macro'>vec</span><span class='macro'>!</span>[]), + <span class='prelude-val'>None</span>, <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>TIME</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"TIME"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='ident'>target</span>.<span class='ident'>clone</span>(), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>CONNECT</span>(<span class='kw-2'>ref</span> <span class='ident'>server</span>, <span class='kw-2'>ref</span> <span class='ident'>port</span>, <span class='kw-2'>ref</span> <span class='ident'>remote</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"CONNECT"</span>), + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>server</span>.<span class='ident'>clone</span>(), <span class='ident'>Owned</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}"</span>, <span class='ident'>port</span>))], <span class='ident'>remote</span>.<span class='ident'>clone</span>(), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>TRACE</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"TRACE"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='ident'>target</span>.<span class='ident'>clone</span>(), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ADMIN</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"ADMIN"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='ident'>target</span>.<span class='ident'>clone</span>(), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>INFO</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"INFO"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='ident'>target</span>.<span class='ident'>clone</span>(), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>SERVLIST</span>(<span class='kw-2'>ref</span> <span class='ident'>sl</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"SERVLIST"</span>), + <span class='ident'>sl</span>.<span class='ident'>as_ref</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span>(<span class='kw-2'>ref</span> <span class='ident'>mask</span>, <span class='kw-2'>ref</span> <span class='ident'>target</span>)<span class='op'>|</span> <span class='ident'>target</span>.<span class='ident'>as_ref</span>() + .<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>t</span><span class='op'>|</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>mask</span>.<span class='ident'>clone</span>(), <span class='ident'>t</span>.<span class='ident'>clone</span>()]) + .<span class='ident'>unwrap_or_else</span>(<span class='op'>||</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>mask</span>.<span class='ident'>clone</span>()])) + .<span class='ident'>unwrap_or</span>(<span class='macro'>vec</span><span class='macro'>!</span>[]), <span class='prelude-val'>None</span>, <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>SQUERY</span>(<span class='kw-2'>ref</span> <span class='ident'>name</span>, <span class='kw-2'>ref</span> <span class='ident'>text</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"SQUERY"</span>), + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>name</span>.<span class='ident'>clone</span>()], <span class='prelude-val'>Some</span>(<span class='ident'>text</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>WHO</span>(<span class='kw-2'>ref</span> <span class='ident'>mask</span>, <span class='ident'>o</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"WHO"</span>), + <span class='kw'>match</span> (<span class='ident'>mask</span>, <span class='ident'>o</span>) { + (<span class='kw-2'>&</span><span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>m</span>), <span class='boolval'>true</span>) <span class='op'>=></span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>m</span>.<span class='ident'>clone</span>(), <span class='ident'>Borrowed</span>(<span class='string'>"o"</span>)], + (<span class='kw-2'>&</span><span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>m</span>), <span class='boolval'>false</span>) <span class='op'>=></span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>m</span>.<span class='ident'>clone</span>()], + (<span class='kw-2'>&</span><span class='prelude-val'>None</span>, _) <span class='op'>=></span> <span class='macro'>vec</span><span class='macro'>!</span>[] + }, <span class='prelude-val'>None</span>, <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>WHOIS</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>, <span class='kw-2'>ref</span> <span class='ident'>masks</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"WHOIS"</span>), + <span class='ident'>target</span>.<span class='ident'>as_ref</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>t</span><span class='op'>|</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>t</span>.<span class='ident'>clone</span>(), <span class='ident'>Owned</span>(<span class='ident'>masks</span>.<span class='ident'>connect</span>(<span class='string'>","</span>))]) + .<span class='ident'>unwrap_or_else</span>(<span class='op'>||</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>Owned</span>(<span class='ident'>masks</span>.<span class='ident'>connect</span>(<span class='string'>","</span>))]), <span class='prelude-val'>None</span>, <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>WHOWAS</span>(<span class='kw-2'>ref</span> <span class='ident'>nick</span>, <span class='kw-2'>ref</span> <span class='ident'>count</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"WHOWAS"</span>), <span class='kw'>match</span> <span class='ident'>count</span> { + <span class='kw-2'>&</span><span class='prelude-val'>Some</span>((<span class='kw-2'>ref</span> <span class='ident'>c</span>, <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>t</span>))) <span class='op'>=></span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>Owned</span>(<span class='ident'>nick</span>.<span class='ident'>connect</span>(<span class='string'>","</span>)), <span class='ident'>c</span>.<span class='ident'>clone</span>(), <span class='ident'>t</span>.<span class='ident'>clone</span>()], + <span class='kw-2'>&</span><span class='prelude-val'>Some</span>((<span class='kw-2'>ref</span> <span class='ident'>c</span>, <span class='prelude-val'>None</span>)) <span class='op'>=></span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>Owned</span>(<span class='ident'>nick</span>.<span class='ident'>connect</span>(<span class='string'>","</span>)), <span class='ident'>c</span>.<span class='ident'>clone</span>()], + <span class='kw-2'>&</span><span class='prelude-val'>None</span> <span class='op'>=></span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>Owned</span>(<span class='ident'>nick</span>.<span class='ident'>connect</span>(<span class='string'>","</span>))] + }, <span class='prelude-val'>None</span>, <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>PING</span>(<span class='kw-2'>ref</span> <span class='ident'>s1</span>, <span class='kw-2'>ref</span> <span class='ident'>s2</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"PING"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>s1</span>.<span class='ident'>clone</span>()], <span class='ident'>s2</span>.<span class='ident'>clone</span>(), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>PONG</span>(<span class='kw-2'>ref</span> <span class='ident'>s1</span>, <span class='kw-2'>ref</span> <span class='ident'>s2</span>) <span class='op'>=></span> + <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"PONG"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>s1</span>.<span class='ident'>clone</span>()], <span class='ident'>s2</span>.<span class='ident'>clone</span>(), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + _ <span class='op'>=></span> <span class='macro'>unimplemented</span><span class='macro'>!</span>() + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>to_static</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Command</span><span class='op'><</span><span class='lifetime'>'static</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>s</span>(<span class='ident'>c</span>: <span class='kw-2'>&</span><span class='ident'>Cow</span><span class='op'><</span><span class='ident'>str</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>Cow</span><span class='op'><</span><span class='lifetime'>'static</span>, <span class='ident'>str</span><span class='op'>></span> { + <span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>c</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>()) + } + <span class='kw'>fn</span> <span class='ident'>so</span>(<span class='ident'>c</span>: <span class='kw-2'>&</span><span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Cow</span><span class='op'><</span><span class='ident'>str</span><span class='op'>>></span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Cow</span><span class='op'><</span><span class='lifetime'>'static</span>, <span class='ident'>str</span><span class='op'>>></span> { + <span class='ident'>c</span>.<span class='ident'>as_ref</span>().<span class='ident'>map</span>(<span class='ident'>s</span>) + } + <span class='kw'>fn</span> <span class='ident'>sv</span>(<span class='ident'>c</span>: <span class='kw-2'>&</span><span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Cow</span><span class='op'><</span><span class='ident'>str</span><span class='op'>>></span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Cow</span><span class='op'><</span><span class='lifetime'>'static</span>, <span class='ident'>str</span><span class='op'>>></span> { + <span class='ident'>c</span>.<span class='ident'>iter</span>().<span class='ident'>map</span>(<span class='ident'>s</span>).<span class='ident'>collect</span>() + } + <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>Command</span>::<span class='op'>*</span>; + <span class='kw'>match</span> <span class='self'>self</span> { + <span class='kw-2'>&</span><span class='ident'>PASS</span>(<span class='kw-2'>ref</span> <span class='ident'>pw</span>) <span class='op'>=></span> <span class='ident'>PASS</span>(<span class='ident'>s</span>(<span class='ident'>pw</span>)), + <span class='kw-2'>&</span><span class='ident'>NICK</span>(<span class='kw-2'>ref</span> <span class='ident'>nick</span>) <span class='op'>=></span> <span class='ident'>NICK</span>(<span class='ident'>s</span>(<span class='ident'>nick</span>)), + <span class='kw-2'>&</span><span class='ident'>USER</span>(<span class='kw-2'>ref</span> <span class='ident'>user</span>, <span class='kw-2'>ref</span> <span class='ident'>mode</span>, <span class='kw-2'>ref</span> <span class='ident'>unused</span>, <span class='kw-2'>ref</span> <span class='ident'>realname</span>) <span class='op'>=></span> + <span class='ident'>USER</span>(<span class='ident'>s</span>(<span class='ident'>user</span>), <span class='ident'>s</span>(<span class='ident'>mode</span>), <span class='ident'>s</span>(<span class='ident'>unused</span>), <span class='ident'>s</span>(<span class='ident'>realname</span>)), + <span class='kw-2'>&</span><span class='ident'>OPER</span>(<span class='kw-2'>ref</span> <span class='ident'>name</span>, <span class='kw-2'>ref</span> <span class='ident'>pw</span>) <span class='op'>=></span> <span class='ident'>OPER</span>(<span class='ident'>s</span>(<span class='ident'>name</span>), <span class='ident'>s</span>(<span class='ident'>pw</span>)), + <span class='kw-2'>&</span><span class='ident'>UMODE</span>(<span class='kw-2'>ref</span> <span class='ident'>mode</span>) <span class='op'>=></span> <span class='ident'>UMODE</span>(<span class='ident'>s</span>(<span class='ident'>mode</span>)), + <span class='kw-2'>&</span><span class='ident'>SERVICE</span>(<span class='kw-2'>ref</span> <span class='ident'>nick</span>, <span class='kw-2'>ref</span> <span class='ident'>reserved</span>, <span class='kw-2'>ref</span> <span class='ident'>distribution</span>, <span class='kw-2'>ref</span> <span class='ident'>type_</span>, <span class='kw-2'>ref</span> <span class='ident'>reserved2</span>, <span class='kw-2'>ref</span> <span class='ident'>info</span>) <span class='op'>=></span> + <span class='ident'>SERVICE</span>(<span class='ident'>s</span>(<span class='ident'>nick</span>), <span class='ident'>s</span>(<span class='ident'>reserved</span>), <span class='ident'>s</span>(<span class='ident'>distribution</span>), <span class='ident'>s</span>(<span class='ident'>type_</span>), <span class='ident'>s</span>(<span class='ident'>reserved2</span>), <span class='ident'>s</span>(<span class='ident'>info</span>)), + <span class='kw-2'>&</span><span class='ident'>QUIT</span>(<span class='kw-2'>ref</span> <span class='ident'>msg</span>) <span class='op'>=></span> <span class='ident'>QUIT</span>(<span class='ident'>so</span>(<span class='ident'>msg</span>)), + <span class='kw-2'>&</span><span class='ident'>SQUIT</span>(<span class='kw-2'>ref</span> <span class='ident'>server</span>, <span class='kw-2'>ref</span> <span class='ident'>comment</span>) <span class='op'>=></span> <span class='ident'>SQUIT</span>(<span class='ident'>s</span>(<span class='ident'>server</span>), <span class='ident'>s</span>(<span class='ident'>comment</span>)), + <span class='kw-2'>&</span><span class='ident'>JOIN</span>(<span class='kw-2'>ref</span> <span class='ident'>ch</span>, <span class='kw-2'>ref</span> <span class='ident'>pw</span>) <span class='op'>=></span> <span class='ident'>JOIN</span>(<span class='ident'>sv</span>(<span class='ident'>ch</span>), <span class='ident'>sv</span>(<span class='ident'>pw</span>)), + <span class='kw-2'>&</span><span class='ident'>PART</span>(<span class='kw-2'>ref</span> <span class='ident'>ch</span>, <span class='kw-2'>ref</span> <span class='ident'>reason</span>) <span class='op'>=></span> <span class='ident'>PART</span>(<span class='ident'>sv</span>(<span class='ident'>ch</span>), <span class='ident'>so</span>(<span class='ident'>reason</span>)), + <span class='kw-2'>&</span><span class='ident'>MODE</span>(<span class='kw-2'>ref</span> <span class='ident'>channel</span>, <span class='kw-2'>ref</span> <span class='ident'>modes</span>) <span class='op'>=></span> + <span class='ident'>MODE</span>(<span class='ident'>s</span>(<span class='ident'>channel</span>), <span class='ident'>modes</span>.<span class='ident'>iter</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span>(<span class='kw-2'>ref</span> <span class='ident'>a</span>, <span class='kw-2'>ref</span> <span class='ident'>b</span>)<span class='op'>|</span> (<span class='ident'>s</span>(<span class='ident'>a</span>), <span class='ident'>s</span>(<span class='ident'>b</span>))).<span class='ident'>collect</span>()), + <span class='kw-2'>&</span><span class='ident'>TOPIC</span>(<span class='kw-2'>ref</span> <span class='ident'>channel</span>, <span class='kw-2'>ref</span> <span class='ident'>topic</span>) <span class='op'>=></span> <span class='ident'>TOPIC</span>(<span class='ident'>s</span>(<span class='ident'>channel</span>), <span class='ident'>so</span>(<span class='ident'>topic</span>)), + <span class='kw-2'>&</span><span class='ident'>NAMES</span>(<span class='kw-2'>ref</span> <span class='ident'>ch</span>, <span class='kw-2'>ref</span> <span class='ident'>target</span>) <span class='op'>=></span> <span class='ident'>NAMES</span>(<span class='ident'>sv</span>(<span class='ident'>ch</span>), <span class='ident'>so</span>(<span class='ident'>target</span>)), + <span class='kw-2'>&</span><span class='ident'>LIST</span>(<span class='kw-2'>ref</span> <span class='ident'>ch</span>, <span class='kw-2'>ref</span> <span class='ident'>target</span>) <span class='op'>=></span> <span class='ident'>LIST</span>(<span class='ident'>sv</span>(<span class='ident'>ch</span>), <span class='ident'>so</span>(<span class='ident'>target</span>)), + <span class='kw-2'>&</span><span class='ident'>INVITE</span>(<span class='kw-2'>ref</span> <span class='ident'>nick</span>, <span class='kw-2'>ref</span> <span class='ident'>channel</span>) <span class='op'>=></span> <span class='ident'>INVITE</span>(<span class='ident'>s</span>(<span class='ident'>nick</span>), <span class='ident'>s</span>(<span class='ident'>channel</span>)), + <span class='kw-2'>&</span><span class='ident'>KICK</span>(<span class='kw-2'>ref</span> <span class='ident'>ch</span>, <span class='kw-2'>ref</span> <span class='ident'>users</span>, <span class='kw-2'>ref</span> <span class='ident'>comment</span>) <span class='op'>=></span> <span class='ident'>KICK</span>(<span class='ident'>sv</span>(<span class='ident'>ch</span>), <span class='ident'>sv</span>(<span class='ident'>users</span>), <span class='ident'>so</span>(<span class='ident'>comment</span>)), + <span class='kw-2'>&</span><span class='ident'>PRIVMSG</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>, <span class='kw-2'>ref</span> <span class='ident'>msg</span>) <span class='op'>=></span> <span class='ident'>PRIVMSG</span>(<span class='ident'>s</span>(<span class='ident'>target</span>), <span class='ident'>s</span>(<span class='ident'>msg</span>)), + <span class='kw-2'>&</span><span class='ident'>NOTICE</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>, <span class='kw-2'>ref</span> <span class='ident'>text</span>) <span class='op'>=></span> <span class='ident'>NOTICE</span>(<span class='ident'>s</span>(<span class='ident'>target</span>), <span class='ident'>s</span>(<span class='ident'>text</span>)), + <span class='kw-2'>&</span><span class='ident'>MOTD</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>) <span class='op'>=></span> <span class='ident'>MOTD</span>(<span class='ident'>so</span>(<span class='ident'>target</span>)), + <span class='kw-2'>&</span><span class='ident'>LUSERS</span>(<span class='kw-2'>ref</span> <span class='ident'>lu</span>) <span class='op'>=></span> <span class='ident'>LUSERS</span>(<span class='ident'>lu</span>.<span class='ident'>as_ref</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span>(<span class='kw-2'>ref</span> <span class='ident'>a</span>, <span class='kw-2'>ref</span> <span class='ident'>b</span>)<span class='op'>|</span> (<span class='ident'>s</span>(<span class='ident'>a</span>), <span class='ident'>so</span>(<span class='ident'>b</span>)))), + <span class='kw-2'>&</span><span class='ident'>VERSION</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>) <span class='op'>=></span> <span class='ident'>VERSION</span>(<span class='ident'>so</span>(<span class='ident'>target</span>)), + <span class='kw-2'>&</span><span class='ident'>STATS</span>(<span class='kw-2'>ref</span> <span class='ident'>st</span>) <span class='op'>=></span> <span class='ident'>STATS</span>(<span class='ident'>st</span>.<span class='ident'>as_ref</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span>(<span class='kw-2'>ref</span> <span class='ident'>a</span>, <span class='kw-2'>ref</span> <span class='ident'>b</span>)<span class='op'>|</span> (<span class='ident'>s</span>(<span class='ident'>a</span>), <span class='ident'>so</span>(<span class='ident'>b</span>)))), + <span class='kw-2'>&</span><span class='ident'>LINKS</span>(<span class='kw-2'>ref</span> <span class='ident'>l</span>) <span class='op'>=></span> <span class='ident'>LINKS</span>(<span class='ident'>l</span>.<span class='ident'>as_ref</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span>(<span class='kw-2'>ref</span> <span class='ident'>a</span>, <span class='kw-2'>ref</span> <span class='ident'>b</span>)<span class='op'>|</span> (<span class='ident'>so</span>(<span class='ident'>a</span>), <span class='ident'>s</span>(<span class='ident'>b</span>)))), + <span class='kw-2'>&</span><span class='ident'>TIME</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>) <span class='op'>=></span> <span class='ident'>TIME</span>(<span class='ident'>so</span>(<span class='ident'>target</span>)), + <span class='kw-2'>&</span><span class='ident'>CONNECT</span>(<span class='kw-2'>ref</span> <span class='ident'>server</span>, <span class='ident'>port</span>, <span class='kw-2'>ref</span> <span class='ident'>remote</span>) <span class='op'>=></span> <span class='ident'>CONNECT</span>(<span class='ident'>s</span>(<span class='ident'>server</span>), <span class='ident'>port</span>, <span class='ident'>so</span>(<span class='ident'>remote</span>)), + <span class='kw-2'>&</span><span class='ident'>TRACE</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>) <span class='op'>=></span> <span class='ident'>TRACE</span>(<span class='ident'>so</span>(<span class='ident'>target</span>)), + <span class='kw-2'>&</span><span class='ident'>ADMIN</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>) <span class='op'>=></span> <span class='ident'>ADMIN</span>(<span class='ident'>so</span>(<span class='ident'>target</span>)), + <span class='kw-2'>&</span><span class='ident'>INFO</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>) <span class='op'>=></span> <span class='ident'>INFO</span>(<span class='ident'>so</span>(<span class='ident'>target</span>)), + <span class='kw-2'>&</span><span class='ident'>SERVLIST</span>(<span class='kw-2'>ref</span> <span class='ident'>sl</span>) <span class='op'>=></span> <span class='ident'>SERVLIST</span>(<span class='ident'>sl</span>.<span class='ident'>as_ref</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span>(<span class='kw-2'>ref</span> <span class='ident'>a</span>, <span class='kw-2'>ref</span> <span class='ident'>b</span>)<span class='op'>|</span> (<span class='ident'>s</span>(<span class='ident'>a</span>), <span class='ident'>so</span>(<span class='ident'>b</span>)))), + <span class='kw-2'>&</span><span class='ident'>SQUERY</span>(<span class='kw-2'>ref</span> <span class='ident'>name</span>, <span class='kw-2'>ref</span> <span class='ident'>text</span>) <span class='op'>=></span> <span class='ident'>SQUERY</span>(<span class='ident'>s</span>(<span class='ident'>name</span>), <span class='ident'>s</span>(<span class='ident'>text</span>)), + <span class='kw-2'>&</span><span class='ident'>WHO</span>(<span class='kw-2'>ref</span> <span class='ident'>mask</span>, <span class='ident'>o</span>) <span class='op'>=></span> <span class='ident'>WHO</span>(<span class='ident'>so</span>(<span class='ident'>mask</span>), <span class='ident'>o</span>), + <span class='kw-2'>&</span><span class='ident'>WHOIS</span>(<span class='kw-2'>ref</span> <span class='ident'>target</span>, <span class='kw-2'>ref</span> <span class='ident'>masks</span>) <span class='op'>=></span> <span class='ident'>WHOIS</span>(<span class='ident'>so</span>(<span class='ident'>target</span>), <span class='ident'>sv</span>(<span class='ident'>masks</span>)), + <span class='kw-2'>&</span><span class='ident'>WHOWAS</span>(<span class='kw-2'>ref</span> <span class='ident'>nick</span>, <span class='kw-2'>ref</span> <span class='ident'>count</span>) <span class='op'>=></span> + <span class='ident'>WHOWAS</span>(<span class='ident'>sv</span>(<span class='ident'>nick</span>), <span class='ident'>count</span>.<span class='ident'>as_ref</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span>(<span class='kw-2'>ref</span> <span class='ident'>a</span>, <span class='kw-2'>ref</span> <span class='ident'>b</span>)<span class='op'>|</span> (<span class='ident'>s</span>(<span class='ident'>a</span>), <span class='ident'>so</span>(<span class='ident'>b</span>)))), + <span class='kw-2'>&</span><span class='ident'>PING</span>(<span class='kw-2'>ref</span> <span class='ident'>s1</span>, <span class='kw-2'>ref</span> <span class='ident'>s2</span>) <span class='op'>=></span> <span class='ident'>PING</span>(<span class='ident'>s</span>(<span class='ident'>s1</span>), <span class='ident'>so</span>(<span class='ident'>s2</span>)), + <span class='kw-2'>&</span><span class='ident'>PONG</span>(<span class='kw-2'>ref</span> <span class='ident'>s1</span>, <span class='kw-2'>ref</span> <span class='ident'>s2</span>) <span class='op'>=></span> <span class='ident'>PONG</span>(<span class='ident'>s</span>(<span class='ident'>s1</span>), <span class='ident'>so</span>(<span class='ident'>s2</span>)), + _ <span class='op'>=></span> <span class='macro'>unimplemented</span><span class='macro'>!</span>() + } + } +} + +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "irsc"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/irsc/event.rs.html b/src/irsc/event.rs.html new file mode 100644 index 0000000..c2e6ef1 --- /dev/null +++ b/src/irsc/event.rs.html @@ -0,0 +1,145 @@ +<!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="Source to the Rust file `src/event.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>event.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10">10</span> +<span id="11">11</span> +<span id="12">12</span> +<span id="13">13</span> +<span id="14">14</span> +<span id="15">15</span> +<span id="16">16</span> +<span id="17">17</span> +<span id="18">18</span> +<span id="19">19</span> +<span id="20">20</span> +<span id="21">21</span> +<span id="22">22</span> +<span id="23">23</span> +<span id="24">24</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>borrow</span>::{ <span class='ident'>Borrow</span>, <span class='ident'>ToOwned</span> }; + +<span class='kw'>use</span> <span class='ident'>command</span>; +<span class='kw'>use</span> <span class='ident'>reply</span>; + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>, <span class='ident'>Clone</span>, <span class='ident'>PartialEq</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Event</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='ident'>Command</span>(<span class='ident'>command</span>::<span class='ident'>Command</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + <span class='ident'>Reply</span>(<span class='ident'>reply</span>::<span class='ident'>Reply</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + <span class='ident'>Connected</span>, + <span class='ident'>Disconnected</span> +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>Event</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>to_static</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Event</span><span class='op'><</span><span class='lifetime'>'static</span><span class='op'>></span> { + <span class='kw'>use</span> <span class='ident'>Event</span>::<span class='op'>*</span>; + <span class='kw'>match</span> <span class='self'>self</span> { + <span class='kw-2'>&</span><span class='ident'>Command</span>(<span class='kw-2'>ref</span> <span class='ident'>c</span>) <span class='op'>=></span> <span class='ident'>Command</span>(<span class='ident'>c</span>.<span class='ident'>to_static</span>()), + <span class='kw-2'>&</span><span class='ident'>Reply</span>(<span class='kw-2'>ref</span> <span class='ident'>r</span>) <span class='op'>=></span> <span class='ident'>Reply</span>(<span class='ident'>r</span>.<span class='ident'>to_static</span>()), + <span class='kw-2'>&</span><span class='ident'>Connected</span> <span class='op'>=></span> <span class='ident'>Connected</span>, + <span class='kw-2'>&</span><span class='ident'>Disconnected</span> <span class='op'>=></span> <span class='ident'>Disconnected</span> + } + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "irsc"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/irsc/ident.rs.html b/src/irsc/ident.rs.html new file mode 100644 index 0000000..6fea734 --- /dev/null +++ b/src/irsc/ident.rs.html @@ -0,0 +1,147 @@ +<!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="Source to the Rust file `src/ident.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>ident.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10">10</span> +<span id="11">11</span> +<span id="12">12</span> +<span id="13">13</span> +<span id="14">14</span> +<span id="15">15</span> +<span id="16">16</span> +<span id="17">17</span> +<span id="18">18</span> +<span id="19">19</span> +<span id="20">20</span> +<span id="21">21</span> +<span id="22">22</span> +<span id="23">23</span> +<span id="24">24</span> +<span id="25">25</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>regex</span>::<span class='ident'>Regex</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>borrow</span>::<span class='ident'>ToOwned</span>; + +<span class='kw'>static</span> <span class='ident'>PATTERN</span>: <span class='ident'>Regex</span> <span class='op'>=</span> <span class='macro'>regex</span><span class='macro'>!</span>(<span class='string'>"(.*)!(.*)@(.*)"</span>); + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>, <span class='ident'>Clone</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Ident</span> { + <span class='kw'>pub</span> <span class='ident'>nickname</span>: <span class='ident'>String</span>, + <span class='kw'>pub</span> <span class='ident'>user</span>: <span class='ident'>String</span>, + <span class='kw'>pub</span> <span class='ident'>host</span>: <span class='ident'>String</span> +} + +<span class='kw'>impl</span> <span class='ident'>Ident</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>parse</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Ident</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>c</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>PATTERN</span>.<span class='ident'>captures</span>(<span class='ident'>s</span>) { + <span class='prelude-val'>Some</span>(<span class='ident'>c</span>) <span class='op'>=></span> <span class='ident'>c</span>, + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='kw'>return</span> <span class='prelude-val'>None</span> + }; + <span class='prelude-val'>Some</span>(<span class='ident'>Ident</span> { + <span class='ident'>nickname</span>: <span class='ident'>c</span>.<span class='ident'>at</span>(<span class='number'>1</span>).<span class='ident'>unwrap</span>().<span class='ident'>to_owned</span>(), + <span class='ident'>user</span>: <span class='ident'>c</span>.<span class='ident'>at</span>(<span class='number'>2</span>).<span class='ident'>unwrap</span>().<span class='ident'>to_owned</span>(), + <span class='ident'>host</span>: <span class='ident'>c</span>.<span class='ident'>at</span>(<span class='number'>3</span>).<span class='ident'>unwrap</span>().<span class='ident'>to_owned</span>() + }) + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "irsc"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/irsc/lib.rs.html b/src/irsc/lib.rs.html new file mode 100644 index 0000000..9571fda --- /dev/null +++ b/src/irsc/lib.rs.html @@ -0,0 +1,221 @@ +<!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="Source to the Rust file `src/lib.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>lib.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10">10</span> +<span id="11">11</span> +<span id="12">12</span> +<span id="13">13</span> +<span id="14">14</span> +<span id="15">15</span> +<span id="16">16</span> +<span id="17">17</span> +<span id="18">18</span> +<span id="19">19</span> +<span id="20">20</span> +<span id="21">21</span> +<span id="22">22</span> +<span id="23">23</span> +<span id="24">24</span> +<span id="25">25</span> +<span id="26">26</span> +<span id="27">27</span> +<span id="28">28</span> +<span id="29">29</span> +<span id="30">30</span> +<span id="31">31</span> +<span id="32">32</span> +<span id="33">33</span> +<span id="34">34</span> +<span id="35">35</span> +<span id="36">36</span> +<span id="37">37</span> +<span id="38">38</span> +<span id="39">39</span> +<span id="40">40</span> +<span id="41">41</span> +<span id="42">42</span> +<span id="43">43</span> +<span id="44">44</span> +<span id="45">45</span> +<span id="46">46</span> +<span id="47">47</span> +<span id="48">48</span> +<span id="49">49</span> +<span id="50">50</span> +<span id="51">51</span> +<span id="52">52</span> +<span id="53">53</span> +<span id="54">54</span> +<span id="55">55</span> +<span id="56">56</span> +<span id="57">57</span> +<span id="58">58</span> +<span id="59">59</span> +<span id="60">60</span> +<span id="61">61</span> +<span id="62">62</span> +</pre><pre class='rust '> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>feature</span>(<span class='ident'>plugin</span>, <span class='ident'>custom_derive</span>, <span class='ident'>slice_patterns</span>)]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>plugin</span>(<span class='ident'>regex_macros</span>)]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>cfg_attr</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"lints"</span>, <span class='ident'>plugin</span>(<span class='ident'>clippy</span>))]</span> + +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>deny</span>(<span class='ident'>warnings</span>)]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>allow</span>(<span class='ident'>unused_imports</span>)]</span> + +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>regex</span>; +<span class='attribute'>#[<span class='ident'>macro_use</span>]</span> +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>log</span>; +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>openssl</span>; +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>carboxyl</span>; + +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>client</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>color</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>ident</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>callback</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>message</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>command</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>reply</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>event</span>; + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>result</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ops</span>::{ <span class='ident'>Deref</span>, <span class='ident'>DerefMut</span> }; + +<span class='kw'>use</span> <span class='ident'>openssl</span>::<span class='ident'>ssl</span>::<span class='ident'>error</span>::<span class='ident'>SslError</span>; + +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>ident</span>::<span class='ident'>Ident</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>message</span>::{ <span class='ident'>Message</span>, <span class='ident'>MsgType</span> }; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>command</span>::<span class='ident'>Command</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>reply</span>::<span class='ident'>Reply</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>event</span>::<span class='ident'>Event</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>client</span>::{ <span class='ident'>Client</span>, <span class='ident'>OwnedClient</span>, <span class='ident'>SharedClient</span> }; + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>IrscError</span> { + <span class='ident'>Io</span>(<span class='ident'>io</span>::<span class='ident'>Error</span>), + <span class='ident'>AlreadyConnected</span>, + <span class='ident'>NotConnected</span>, + <span class='ident'>NotFound</span>, + <span class='ident'>Ssl</span>(<span class='ident'>SslError</span>) +} + +<span class='kw'>impl</span> <span class='ident'>From</span><span class='op'><</span><span class='ident'>SslError</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>IrscError</span> { + <span class='kw'>fn</span> <span class='ident'>from</span>(<span class='ident'>e</span>: <span class='ident'>SslError</span>) <span class='op'>-></span> <span class='ident'>IrscError</span> { <span class='ident'>IrscError</span>::<span class='ident'>Ssl</span>(<span class='ident'>e</span>) } +} + +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span>(<span class='ident'>result</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>T</span>, <span class='ident'>IrscError</span><span class='op'>></span>); + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> <span class='ident'>Deref</span> <span class='kw'>for</span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Target</span> <span class='op'>=</span> <span class='ident'>result</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>T</span>, <span class='ident'>IrscError</span><span class='op'>></span>; + <span class='kw'>fn</span> <span class='ident'>deref</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>result</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>T</span>, <span class='ident'>IrscError</span><span class='op'>></span> { <span class='kw-2'>&</span><span class='self'>self</span>.<span class='number'>0</span> } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> <span class='ident'>DerefMut</span> <span class='kw'>for</span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>deref_mut</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>result</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>T</span>, <span class='ident'>IrscError</span><span class='op'>></span> { <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='number'>0</span> } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { <span class='kw'>fn</span> <span class='ident'>inner</span>(<span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>result</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>T</span>, <span class='ident'>IrscError</span><span class='op'>></span> { <span class='self'>self</span>.<span class='number'>0</span> } } + +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>DEBUG</span>: <span class='ident'>bool</span> <span class='op'>=</span> <span class='macro'>cfg</span><span class='macro'>!</span>(<span class='ident'>debug_assertions</span>); +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "irsc"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/irsc/message.rs.html b/src/irsc/message.rs.html new file mode 100644 index 0000000..cdc6033 --- /dev/null +++ b/src/irsc/message.rs.html @@ -0,0 +1,567 @@ +<!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="Source to the Rust file `src/message.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>message.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +</pre><pre class='rust '> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>allow</span>(<span class='ident'>non_camel_case_types</span>)]</span> + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>string</span>::{ <span class='ident'>ToString</span> }; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>borrow</span>::{ <span class='ident'>ToOwned</span> }; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ops</span>::{ <span class='ident'>Deref</span>, <span class='ident'>Range</span> }; + +<span class='kw'>use</span> ::<span class='ident'>IrscError</span>; +<span class='kw'>use</span> <span class='ident'>ident</span>::<span class='ident'>Ident</span>; + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>, <span class='ident'>Debug</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>, <span class='ident'>Hash</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>MsgType</span> { + <span class='doccomment'>/// Plain old IRC messages, as defined in [rfc2812][rfc]</span> + <span class='doccomment'>/// rfc: http://tools.ietf.org/html/rfc2812</span> + <span class='ident'>Irc</span>, + <span class='doccomment'>/// Ctcp messages, wrapped in \u{1}</span> + <span class='ident'>Ctcp</span> +} + +<span class='doccomment'>/// Byte indices, be careful.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>, <span class='ident'>Clone</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Message</span> { + <span class='kw'>pub</span> <span class='ident'>source</span>: <span class='ident'>String</span>, + <span class='ident'>prefix</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Range</span><span class='op'><</span><span class='ident'>u16</span><span class='op'>>></span>, + <span class='ident'>command</span>: <span class='ident'>Range</span><span class='op'><</span><span class='ident'>u16</span><span class='op'>></span>, + <span class='ident'>content</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Range</span><span class='op'><</span><span class='ident'>u16</span><span class='op'>>></span>, + <span class='ident'>suffix</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Range</span><span class='op'><</span><span class='ident'>u16</span><span class='op'>>></span>, + <span class='kw'>pub</span> <span class='ident'>msg_type</span>: <span class='ident'>MsgType</span> +} + +<span class='kw'>impl</span> <span class='ident'>Message</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>source</span>: <span class='ident'>String</span>, <span class='ident'>prefix</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Range</span><span class='op'><</span><span class='ident'>u16</span><span class='op'>>></span>, <span class='ident'>command</span>: <span class='ident'>Range</span><span class='op'><</span><span class='ident'>u16</span><span class='op'>></span>, <span class='ident'>content</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Range</span><span class='op'><</span><span class='ident'>u16</span><span class='op'>>></span>, <span class='ident'>suffix</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Range</span><span class='op'><</span><span class='ident'>u16</span><span class='op'>>></span>, <span class='ident'>msg_type</span>: <span class='ident'>MsgType</span>) <span class='op'>-></span> <span class='ident'>Message</span> { + <span class='ident'>Message</span> { + <span class='ident'>source</span>: <span class='ident'>source</span>, + <span class='ident'>prefix</span>: <span class='ident'>prefix</span>, + <span class='ident'>command</span>: <span class='ident'>command</span>, + <span class='ident'>content</span>: <span class='ident'>content</span>, + <span class='ident'>suffix</span>: <span class='ident'>suffix</span>, + <span class='ident'>msg_type</span>: <span class='ident'>msg_type</span> + } + } + + <span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>unused_assignments</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>format</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>Deref</span><span class='op'><</span><span class='ident'>Target</span><span class='op'>=</span><span class='ident'>str</span><span class='op'>>></span>(<span class='ident'>prefix</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span>, <span class='ident'>command</span>: <span class='ident'>T</span>, <span class='ident'>content</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span>, <span class='ident'>suffix</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span>, <span class='ident'>msg_type</span>: <span class='ident'>MsgType</span>) <span class='op'>-></span> <span class='ident'>Message</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='number'>512</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>i</span> <span class='op'>=</span> <span class='number'>0</span>; + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>i_prefix</span> <span class='op'>=</span> <span class='prelude-val'>None</span>; + <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>p</span>) <span class='op'>=</span> <span class='ident'>prefix</span> { + <span class='ident'>i_prefix</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>((<span class='ident'>i</span> <span class='op'>+</span> <span class='number'>1</span>) <span class='kw'>as</span> <span class='ident'>u16</span>..(<span class='ident'>i</span> <span class='op'>+</span> <span class='number'>2</span> <span class='op'>+</span> <span class='ident'>p</span>.<span class='ident'>len</span>()) <span class='kw'>as</span> <span class='ident'>u16</span>); + <span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>':'</span>); + <span class='ident'>s</span>.<span class='ident'>push_str</span>(<span class='ident'>p</span>); + <span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>' '</span>); + <span class='ident'>i</span> <span class='op'>+=</span> <span class='number'>2</span> <span class='op'>+</span> <span class='ident'>p</span>.<span class='ident'>len</span>(); + } + + <span class='kw'>let</span> <span class='ident'>i_command</span> <span class='op'>=</span> <span class='ident'>i</span> <span class='kw'>as</span> <span class='ident'>u16</span>..(<span class='ident'>i</span> <span class='op'>+</span> <span class='ident'>command</span>.<span class='ident'>len</span>()) <span class='kw'>as</span> <span class='ident'>u16</span>; + <span class='ident'>s</span>.<span class='ident'>push_str</span>(<span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>command</span>); + <span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>' '</span>); + <span class='ident'>i</span> <span class='op'>+=</span> <span class='number'>1</span> <span class='op'>+</span> <span class='ident'>command</span>.<span class='ident'>len</span>(); + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>i_content</span> <span class='op'>=</span> <span class='ident'>Vec</span>::<span class='ident'>new</span>(); + <span class='kw'>for</span> <span class='ident'>part</span> <span class='kw'>in</span> <span class='ident'>content</span>.<span class='ident'>iter</span>() { + <span class='ident'>i_content</span>.<span class='ident'>push</span>(<span class='ident'>i</span> <span class='kw'>as</span> <span class='ident'>u16</span>..(<span class='ident'>i</span> <span class='op'>+</span> <span class='ident'>part</span>.<span class='ident'>len</span>()) <span class='kw'>as</span> <span class='ident'>u16</span>); + <span class='ident'>s</span>.<span class='ident'>push_str</span>(<span class='ident'>part</span>); + <span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>' '</span>); + <span class='ident'>i</span> <span class='op'>+=</span> <span class='number'>1</span> <span class='op'>+</span> <span class='ident'>part</span>.<span class='ident'>len</span>(); + } + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>i_suffix</span> <span class='op'>=</span> <span class='prelude-val'>None</span>; + <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>p</span>) <span class='op'>=</span> <span class='ident'>suffix</span> { + <span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>':'</span>); + <span class='kw'>if</span> <span class='kw'>let</span> <span class='ident'>MsgType</span>::<span class='ident'>Ctcp</span> <span class='op'>=</span> <span class='ident'>msg_type</span> { <span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>'\u{1}'</span>); <span class='ident'>i</span> <span class='op'>+=</span> <span class='number'>1</span>; } + <span class='kw'>let</span> <span class='ident'>n</span> <span class='op'>=</span> <span class='ident'>i</span>; + <span class='ident'>s</span>.<span class='ident'>push_str</span>(<span class='ident'>p</span>); + <span class='kw'>if</span> <span class='kw'>let</span> <span class='ident'>MsgType</span>::<span class='ident'>Ctcp</span> <span class='op'>=</span> <span class='ident'>msg_type</span> { <span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>'\u{1}'</span>); <span class='ident'>i</span> <span class='op'>+=</span> <span class='number'>1</span>; } + <span class='ident'>i_suffix</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>n</span> <span class='kw'>as</span> <span class='ident'>u16</span>..(<span class='ident'>n</span> <span class='op'>+</span> <span class='ident'>p</span>.<span class='ident'>len</span>()) <span class='kw'>as</span> <span class='ident'>u16</span>); + <span class='ident'>i</span> <span class='op'>+=</span> <span class='number'>1</span> <span class='op'>+</span> <span class='ident'>p</span>.<span class='ident'>len</span>(); + } + + <span class='ident'>s</span>.<span class='ident'>push_str</span>(<span class='string'>"\r\n"</span>); + <span class='ident'>i</span> <span class='op'>+=</span> <span class='number'>2</span>; + + <span class='ident'>Message</span>::<span class='ident'>new</span>(<span class='ident'>s</span>, <span class='ident'>i_prefix</span>, <span class='ident'>i_command</span>, <span class='ident'>i_content</span>, <span class='ident'>i_suffix</span>, <span class='ident'>msg_type</span>) + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>range</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>r</span>: <span class='kw-2'>&</span><span class='ident'>Range</span><span class='op'><</span><span class='ident'>u16</span><span class='op'>></span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>str</span> { + <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>source</span>[<span class='ident'>r</span>.<span class='ident'>start</span> <span class='kw'>as</span> <span class='ident'>usize</span>..<span class='ident'>r</span>.<span class='ident'>end</span> <span class='kw'>as</span> <span class='ident'>usize</span>] + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>prefix</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='ident'>str</span><span class='op'>></span> { <span class='self'>self</span>.<span class='ident'>prefix</span>.<span class='ident'>as_ref</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>r</span><span class='op'>|</span> <span class='self'>self</span>.<span class='ident'>range</span>(<span class='ident'>r</span>)) } + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>command</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>str</span> { <span class='self'>self</span>.<span class='ident'>range</span>(<span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>command</span>) } + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>content</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='kw-2'>&</span><span class='ident'>str</span><span class='op'>></span> { <span class='self'>self</span>.<span class='ident'>content</span>.<span class='ident'>iter</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>r</span><span class='op'>|</span> <span class='self'>self</span>.<span class='ident'>range</span>(<span class='kw-2'>&</span><span class='ident'>r</span>)).<span class='ident'>collect</span>() } + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>suffix</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='ident'>str</span><span class='op'>></span> { <span class='self'>self</span>.<span class='ident'>suffix</span>.<span class='ident'>as_ref</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>r</span><span class='op'>|</span> <span class='self'>self</span>.<span class='ident'>range</span>(<span class='ident'>r</span>)) } + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>elements</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='kw-2'>&</span><span class='ident'>str</span><span class='op'>></span> { <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>content</span>(); <span class='self'>self</span>.<span class='ident'>suffix</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>f</span><span class='op'>|</span> <span class='ident'>s</span>.<span class='ident'>push</span>(<span class='ident'>f</span>)); <span class='ident'>s</span> } + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ident</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Ident</span><span class='op'>></span> { <span class='self'>self</span>.<span class='ident'>prefix</span>().<span class='ident'>and_then</span>(<span class='ident'>Ident</span>::<span class='ident'>parse</span>) } +} + +<span class='kw'>impl</span> <span class='ident'>FromStr</span> <span class='kw'>for</span> <span class='ident'>Message</span> { + <span class='kw'>type</span> <span class='prelude-val'>Err</span> <span class='op'>=</span> <span class='ident'>IrscError</span>; + <span class='kw'>fn</span> <span class='ident'>from_str</span>(<span class='ident'>i</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Message</span>, <span class='ident'>IrscError</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='ident'>i</span>.<span class='ident'>len</span>(); + <span class='comment'>// remember, bytes, not chars</span> + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='number'>0</span>; + + <span class='kw'>let</span> <span class='ident'>prefix</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='ident'>len</span> <span class='op'>>=</span> <span class='number'>1</span> <span class='op'>&&</span> <span class='ident'>i</span>[<span class='ident'>s</span>..].<span class='ident'>as_bytes</span>()[<span class='number'>0</span>] <span class='op'>==</span> <span class='string'>':'</span> <span class='kw'>as</span> <span class='ident'>u8</span> { + <span class='ident'>i</span>[<span class='ident'>s</span>..].<span class='ident'>find</span>(<span class='string'>' '</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>i</span><span class='op'>|</span> { <span class='kw'>let</span> <span class='ident'>n</span> <span class='op'>=</span> <span class='number'>1u16</span>..(<span class='ident'>s</span> <span class='op'>+</span> <span class='ident'>i</span>) <span class='kw'>as</span> <span class='ident'>u16</span>; <span class='ident'>s</span> <span class='op'>+=</span> <span class='ident'>i</span> <span class='op'>+</span> <span class='number'>1</span>; <span class='ident'>n</span> }) + } <span class='kw'>else</span> { <span class='prelude-val'>None</span> }; + + <span class='kw'>let</span> <span class='ident'>command</span> <span class='op'>=</span> <span class='ident'>i</span>[<span class='ident'>s</span>..].<span class='ident'>find</span>(<span class='string'>' '</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>n</span><span class='op'>|</span> { + <span class='kw'>let</span> <span class='ident'>p</span> <span class='op'>=</span> <span class='ident'>s</span> <span class='kw'>as</span> <span class='ident'>u16</span>..(<span class='ident'>s</span> <span class='op'>+</span> <span class='ident'>n</span>) <span class='kw'>as</span> <span class='ident'>u16</span>; + <span class='ident'>s</span> <span class='op'>+=</span> <span class='ident'>n</span>; + <span class='ident'>p</span> + }); + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>content</span> <span class='op'>=</span> <span class='ident'>Vec</span>::<span class='ident'>with_capacity</span>(<span class='number'>15</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>suffix</span> <span class='op'>=</span> <span class='prelude-val'>None</span>; + <span class='kw'>while</span> <span class='ident'>s</span> <span class='op'><</span> <span class='ident'>len</span> <span class='op'>-</span> <span class='number'>3</span> { + <span class='kw'>if</span> <span class='ident'>i</span>[<span class='ident'>s</span>..].<span class='ident'>as_bytes</span>()[<span class='number'>0</span>] <span class='op'>==</span> <span class='string'>':'</span> <span class='kw'>as</span> <span class='ident'>u8</span> { + <span class='ident'>suffix</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>s</span> <span class='kw'>as</span> <span class='ident'>u16</span> <span class='op'>+</span> <span class='number'>1</span> <span class='kw'>as</span> <span class='ident'>u16</span>..<span class='ident'>i</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>u16</span>); + <span class='kw'>break</span> + } + <span class='ident'>i</span>[<span class='ident'>s</span>..].<span class='ident'>find</span>(<span class='string'>' '</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>i</span><span class='op'>|</span> { + <span class='kw'>if</span> <span class='ident'>i</span> <span class='op'>></span> <span class='number'>0</span> { + <span class='ident'>content</span>.<span class='ident'>push</span>(<span class='ident'>s</span> <span class='kw'>as</span> <span class='ident'>u16</span>..(<span class='ident'>s</span> <span class='op'>+</span> <span class='ident'>i</span>) <span class='kw'>as</span> <span class='ident'>u16</span>); + <span class='ident'>s</span> <span class='op'>+=</span> <span class='ident'>i</span>; + } + }); + <span class='comment'>// if s.chars().next() == Some(' ') { s = &s[1..] };</span> + <span class='ident'>s</span> <span class='op'>+=</span> <span class='number'>1</span>; + } + + <span class='kw'>let</span> <span class='ident'>msg_type</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='ident'>suffix</span>.<span class='ident'>as_ref</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>s</span><span class='op'>|</span> <span class='ident'>i</span>[<span class='ident'>s</span>.<span class='ident'>start</span> <span class='kw'>as</span> <span class='ident'>usize</span>..].<span class='ident'>as_bytes</span>()[<span class='number'>0</span>] <span class='op'>==</span> <span class='number'>1</span> + <span class='op'>&&</span> <span class='ident'>i</span>[(<span class='ident'>s</span>.<span class='ident'>end</span> <span class='op'>-</span> <span class='number'>3</span>) <span class='kw'>as</span> <span class='ident'>usize</span>..].<span class='ident'>as_bytes</span>()[<span class='number'>0</span>] <span class='op'>==</span> <span class='number'>1</span>) + <span class='op'>==</span> <span class='prelude-val'>Some</span>(<span class='boolval'>true</span>) { <span class='ident'>MsgType</span>::<span class='ident'>Ctcp</span> } <span class='kw'>else</span> { <span class='ident'>MsgType</span>::<span class='ident'>Irc</span> }; + + <span class='ident'>command</span>.<span class='ident'>map</span>(<span class='kw'>move</span> <span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> + <span class='prelude-val'>Ok</span>(<span class='ident'>Message</span>::<span class='ident'>new</span>( + <span class='ident'>i</span>.<span class='ident'>to_owned</span>(), + <span class='ident'>prefix</span>, + <span class='ident'>c</span>, + <span class='ident'>content</span>, + <span class='comment'>// strip \{1} if CTCP message</span> + <span class='comment'>// strip \r\n for each line, relying on their existence</span> + <span class='kw'>match</span> <span class='ident'>msg_type</span> { + <span class='ident'>MsgType</span>::<span class='ident'>Irc</span> <span class='op'>=></span> <span class='ident'>suffix</span>.<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>s</span><span class='op'>|</span> <span class='ident'>s</span>.<span class='ident'>start</span>..<span class='ident'>s</span>.<span class='ident'>end</span> <span class='op'>-</span> <span class='number'>1</span>), + <span class='ident'>MsgType</span>::<span class='ident'>Ctcp</span> <span class='op'>=></span> <span class='ident'>suffix</span>.<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>s</span><span class='op'>|</span> <span class='ident'>s</span>.<span class='ident'>start</span> <span class='op'>+</span> <span class='number'>1</span>..<span class='ident'>s</span>.<span class='ident'>end</span> <span class='op'>-</span> <span class='number'>2</span>) + }, + <span class='ident'>msg_type</span> + )) + ).<span class='ident'>unwrap</span>() + + } +} + +<span class='kw'>impl</span> <span class='ident'>ToString</span> <span class='kw'>for</span> <span class='ident'>Message</span> { + <span class='kw'>fn</span> <span class='ident'>to_string</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='self'>self</span>.<span class='ident'>source</span>.<span class='ident'>clone</span>() + } +} + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>, <span class='ident'>Hash</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Mode</span> { + <span class='ident'>Away</span>, + <span class='ident'>Invisible</span>, + <span class='ident'>Wallops</span>, + <span class='ident'>Restricted</span>, + <span class='ident'>Operator</span>, + <span class='ident'>LocalOperator</span>, + <span class='ident'>ServerNotices</span>, + <span class='ident'>Custom</span>(<span class='ident'>String</span>) +} + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>, <span class='ident'>Hash</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>SetMode</span> { + <span class='ident'>Plus</span>, + <span class='ident'>Minus</span> +} + +<span class='doccomment'>/// If you hoped it couldn't get any uglier... I'm sorry, it does.</span> +<span class='doccomment'>/// Why a giant match? API.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// I tried structuring it as a bunch of structs that impl a `Command` trait,</span> +<span class='doccomment'>/// but the user would have to use Any and lots of cats. Also, extensibility isn't</span> +<span class='doccomment'>/// really a goal; the IRC protocol doesn't seem to evolve very fast.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Granted, I *could* have used a phf-map to map to functions to parse this, which</span> +<span class='doccomment'>/// - while more readable - shouldn't have resulted in performance gains.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Please don't cry.</span> + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>test</span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>borrow</span>::{ <span class='ident'>ToOwned</span> }; + <span class='kw'>use</span> <span class='ident'>message</span>::{ <span class='ident'>Message</span>, <span class='ident'>MsgType</span> }; + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>parse_message1</span>() { + <span class='kw'>let</span> <span class='ident'>b</span> <span class='op'>=</span> <span class='string'>":d PRIVMSG You :\u{1}ACTION sends you funny pictures of cats!\u{1}\r\n"</span>; + <span class='kw'>let</span> <span class='ident'>b2</span> <span class='op'>=</span> <span class='ident'>Message</span>::<span class='ident'>new</span>( + <span class='ident'>b</span>.<span class='ident'>to_owned</span>(), + <span class='prelude-val'>Some</span>(<span class='number'>1</span>..<span class='number'>2</span>), + <span class='number'>3</span>..<span class='number'>10</span>, + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='number'>11</span>..<span class='number'>14</span>], + <span class='prelude-val'>Some</span>(<span class='number'>17</span>..<span class='number'>58</span>), + <span class='ident'>MsgType</span>::<span class='ident'>Ctcp</span> + ); + + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>b</span>.<span class='ident'>parse</span>::<span class='op'><</span><span class='ident'>Message</span><span class='op'>></span>().<span class='ident'>unwrap</span>(), <span class='ident'>b2</span>.<span class='ident'>clone</span>()); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>b2</span>.<span class='ident'>to_string</span>(), <span class='ident'>b</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>parse_message2</span>() { + <span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='string'>":a.b.c NOTICE AUTH :*** Looking up your hostname...\r\n"</span>; + <span class='comment'>// I'm not even kidding...</span> + <span class='kw'>let</span> <span class='ident'>a2</span> <span class='op'>=</span> <span class='ident'>Message</span>::<span class='ident'>new</span>( + <span class='ident'>a</span>.<span class='ident'>to_owned</span>(), + <span class='prelude-val'>Some</span>(<span class='number'>1</span>..<span class='number'>6</span>), + <span class='number'>7</span>..<span class='number'>13</span>, + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='number'>14</span>..<span class='number'>18</span>], + <span class='prelude-val'>Some</span>(<span class='number'>20</span>..<span class='number'>52</span>), + <span class='ident'>MsgType</span>::<span class='ident'>Irc</span> + ); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>a</span>.<span class='ident'>parse</span>::<span class='op'><</span><span class='ident'>Message</span><span class='op'>></span>().<span class='ident'>unwrap</span>(), <span class='ident'>a2</span>.<span class='ident'>clone</span>()); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>a2</span>.<span class='ident'>to_string</span>(), <span class='ident'>a</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>format_message</span>() { + <span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>Some</span>(<span class='string'>"a.b.c"</span>), <span class='string'>"NOTICE"</span>, <span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>"AUTH"</span>], <span class='prelude-val'>Some</span>(<span class='string'>"*** Looking up your hostname..."</span>), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>); + <span class='kw'>let</span> <span class='ident'>a2</span> <span class='op'>=</span> <span class='string'>":a.b.c NOTICE AUTH :*** Looking up your hostname...\r\n"</span>; + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>a</span>.<span class='ident'>to_string</span>(), <span class='ident'>a2</span>); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "irsc"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/irsc/reply.rs.html b/src/irsc/reply.rs.html new file mode 100644 index 0000000..5d77d38 --- /dev/null +++ b/src/irsc/reply.rs.html @@ -0,0 +1,3053 @@ +<!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="Source to the Rust file `src/reply.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>reply.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100"> 100</span> +<span id="101"> 101</span> +<span id="102"> 102</span> +<span id="103"> 103</span> +<span id="104"> 104</span> +<span id="105"> 105</span> +<span id="106"> 106</span> +<span id="107"> 107</span> +<span id="108"> 108</span> +<span id="109"> 109</span> +<span id="110"> 110</span> +<span id="111"> 111</span> +<span id="112"> 112</span> +<span id="113"> 113</span> +<span id="114"> 114</span> +<span id="115"> 115</span> +<span id="116"> 116</span> +<span id="117"> 117</span> +<span id="118"> 118</span> +<span id="119"> 119</span> +<span id="120"> 120</span> +<span id="121"> 121</span> +<span id="122"> 122</span> +<span id="123"> 123</span> +<span id="124"> 124</span> +<span id="125"> 125</span> +<span id="126"> 126</span> +<span id="127"> 127</span> +<span id="128"> 128</span> +<span id="129"> 129</span> +<span id="130"> 130</span> +<span id="131"> 131</span> +<span id="132"> 132</span> +<span id="133"> 133</span> +<span id="134"> 134</span> +<span id="135"> 135</span> +<span id="136"> 136</span> +<span id="137"> 137</span> +<span id="138"> 138</span> +<span id="139"> 139</span> +<span id="140"> 140</span> +<span id="141"> 141</span> +<span id="142"> 142</span> +<span id="143"> 143</span> +<span id="144"> 144</span> +<span id="145"> 145</span> +<span id="146"> 146</span> +<span id="147"> 147</span> +<span id="148"> 148</span> +<span id="149"> 149</span> +<span id="150"> 150</span> +<span id="151"> 151</span> +<span id="152"> 152</span> +<span id="153"> 153</span> +<span id="154"> 154</span> +<span id="155"> 155</span> +<span id="156"> 156</span> +<span id="157"> 157</span> +<span id="158"> 158</span> +<span id="159"> 159</span> +<span id="160"> 160</span> +<span id="161"> 161</span> +<span id="162"> 162</span> +<span id="163"> 163</span> +<span id="164"> 164</span> +<span id="165"> 165</span> +<span id="166"> 166</span> +<span id="167"> 167</span> +<span id="168"> 168</span> +<span id="169"> 169</span> +<span id="170"> 170</span> +<span id="171"> 171</span> +<span id="172"> 172</span> +<span id="173"> 173</span> +<span id="174"> 174</span> +<span id="175"> 175</span> +<span id="176"> 176</span> +<span id="177"> 177</span> +<span id="178"> 178</span> +<span id="179"> 179</span> +<span id="180"> 180</span> +<span id="181"> 181</span> +<span id="182"> 182</span> +<span id="183"> 183</span> +<span id="184"> 184</span> +<span id="185"> 185</span> +<span id="186"> 186</span> +<span id="187"> 187</span> +<span id="188"> 188</span> +<span id="189"> 189</span> +<span id="190"> 190</span> +<span id="191"> 191</span> +<span id="192"> 192</span> +<span id="193"> 193</span> +<span id="194"> 194</span> +<span id="195"> 195</span> +<span id="196"> 196</span> +<span id="197"> 197</span> +<span id="198"> 198</span> +<span id="199"> 199</span> +<span id="200"> 200</span> +<span id="201"> 201</span> +<span id="202"> 202</span> +<span id="203"> 203</span> +<span id="204"> 204</span> +<span id="205"> 205</span> +<span id="206"> 206</span> +<span id="207"> 207</span> +<span id="208"> 208</span> +<span id="209"> 209</span> +<span id="210"> 210</span> +<span id="211"> 211</span> +<span id="212"> 212</span> +<span id="213"> 213</span> +<span id="214"> 214</span> +<span id="215"> 215</span> +<span id="216"> 216</span> +<span id="217"> 217</span> +<span id="218"> 218</span> +<span id="219"> 219</span> +<span id="220"> 220</span> +<span id="221"> 221</span> +<span id="222"> 222</span> +<span id="223"> 223</span> +<span id="224"> 224</span> +<span id="225"> 225</span> +<span id="226"> 226</span> +<span id="227"> 227</span> +<span id="228"> 228</span> +<span id="229"> 229</span> +<span id="230"> 230</span> +<span id="231"> 231</span> +<span id="232"> 232</span> +<span id="233"> 233</span> +<span id="234"> 234</span> +<span id="235"> 235</span> +<span id="236"> 236</span> +<span id="237"> 237</span> +<span id="238"> 238</span> +<span id="239"> 239</span> +<span id="240"> 240</span> +<span id="241"> 241</span> +<span id="242"> 242</span> +<span id="243"> 243</span> +<span id="244"> 244</span> +<span id="245"> 245</span> +<span id="246"> 246</span> +<span id="247"> 247</span> +<span id="248"> 248</span> +<span id="249"> 249</span> +<span id="250"> 250</span> +<span id="251"> 251</span> +<span id="252"> 252</span> +<span id="253"> 253</span> +<span id="254"> 254</span> +<span id="255"> 255</span> +<span id="256"> 256</span> +<span id="257"> 257</span> +<span id="258"> 258</span> +<span id="259"> 259</span> +<span id="260"> 260</span> +<span id="261"> 261</span> +<span id="262"> 262</span> +<span id="263"> 263</span> +<span id="264"> 264</span> +<span id="265"> 265</span> +<span id="266"> 266</span> +<span id="267"> 267</span> +<span id="268"> 268</span> +<span id="269"> 269</span> +<span id="270"> 270</span> +<span id="271"> 271</span> +<span id="272"> 272</span> +<span id="273"> 273</span> +<span id="274"> 274</span> +<span id="275"> 275</span> +<span id="276"> 276</span> +<span id="277"> 277</span> +<span id="278"> 278</span> +<span id="279"> 279</span> +<span id="280"> 280</span> +<span id="281"> 281</span> +<span id="282"> 282</span> +<span id="283"> 283</span> +<span id="284"> 284</span> +<span id="285"> 285</span> +<span id="286"> 286</span> +<span id="287"> 287</span> +<span id="288"> 288</span> +<span id="289"> 289</span> +<span id="290"> 290</span> +<span id="291"> 291</span> +<span id="292"> 292</span> +<span id="293"> 293</span> +<span id="294"> 294</span> +<span id="295"> 295</span> +<span id="296"> 296</span> +<span id="297"> 297</span> +<span id="298"> 298</span> +<span id="299"> 299</span> +<span id="300"> 300</span> +<span id="301"> 301</span> +<span id="302"> 302</span> +<span id="303"> 303</span> +<span id="304"> 304</span> +<span id="305"> 305</span> +<span id="306"> 306</span> +<span id="307"> 307</span> +<span id="308"> 308</span> +<span id="309"> 309</span> +<span id="310"> 310</span> +<span id="311"> 311</span> +<span id="312"> 312</span> +<span id="313"> 313</span> +<span id="314"> 314</span> +<span id="315"> 315</span> +<span id="316"> 316</span> +<span id="317"> 317</span> +<span id="318"> 318</span> +<span id="319"> 319</span> +<span id="320"> 320</span> +<span id="321"> 321</span> +<span id="322"> 322</span> +<span id="323"> 323</span> +<span id="324"> 324</span> +<span id="325"> 325</span> +<span id="326"> 326</span> +<span id="327"> 327</span> +<span id="328"> 328</span> +<span id="329"> 329</span> +<span id="330"> 330</span> +<span id="331"> 331</span> +<span id="332"> 332</span> +<span id="333"> 333</span> +<span id="334"> 334</span> +<span id="335"> 335</span> +<span id="336"> 336</span> +<span id="337"> 337</span> +<span id="338"> 338</span> +<span id="339"> 339</span> +<span id="340"> 340</span> +<span id="341"> 341</span> +<span id="342"> 342</span> +<span id="343"> 343</span> +<span id="344"> 344</span> +<span id="345"> 345</span> +<span id="346"> 346</span> +<span id="347"> 347</span> +<span id="348"> 348</span> +<span id="349"> 349</span> +<span id="350"> 350</span> +<span id="351"> 351</span> +<span id="352"> 352</span> +<span id="353"> 353</span> +<span id="354"> 354</span> +<span id="355"> 355</span> +<span id="356"> 356</span> +<span id="357"> 357</span> +<span id="358"> 358</span> +<span id="359"> 359</span> +<span id="360"> 360</span> +<span id="361"> 361</span> +<span id="362"> 362</span> +<span id="363"> 363</span> +<span id="364"> 364</span> +<span id="365"> 365</span> +<span id="366"> 366</span> +<span id="367"> 367</span> +<span id="368"> 368</span> +<span id="369"> 369</span> +<span id="370"> 370</span> +<span id="371"> 371</span> +<span id="372"> 372</span> +<span id="373"> 373</span> +<span id="374"> 374</span> +<span id="375"> 375</span> +<span id="376"> 376</span> +<span id="377"> 377</span> +<span id="378"> 378</span> +<span id="379"> 379</span> +<span id="380"> 380</span> +<span id="381"> 381</span> +<span id="382"> 382</span> +<span id="383"> 383</span> +<span id="384"> 384</span> +<span id="385"> 385</span> +<span id="386"> 386</span> +<span id="387"> 387</span> +<span id="388"> 388</span> +<span id="389"> 389</span> +<span id="390"> 390</span> +<span id="391"> 391</span> +<span id="392"> 392</span> +<span id="393"> 393</span> +<span id="394"> 394</span> +<span id="395"> 395</span> +<span id="396"> 396</span> +<span id="397"> 397</span> +<span id="398"> 398</span> +<span id="399"> 399</span> +<span id="400"> 400</span> +<span id="401"> 401</span> +<span id="402"> 402</span> +<span id="403"> 403</span> +<span id="404"> 404</span> +<span id="405"> 405</span> +<span id="406"> 406</span> +<span id="407"> 407</span> +<span id="408"> 408</span> +<span id="409"> 409</span> +<span id="410"> 410</span> +<span id="411"> 411</span> +<span id="412"> 412</span> +<span id="413"> 413</span> +<span id="414"> 414</span> +<span id="415"> 415</span> +<span id="416"> 416</span> +<span id="417"> 417</span> +<span id="418"> 418</span> +<span id="419"> 419</span> +<span id="420"> 420</span> +<span id="421"> 421</span> +<span id="422"> 422</span> +<span id="423"> 423</span> +<span id="424"> 424</span> +<span id="425"> 425</span> +<span id="426"> 426</span> +<span id="427"> 427</span> +<span id="428"> 428</span> +<span id="429"> 429</span> +<span id="430"> 430</span> +<span id="431"> 431</span> +<span id="432"> 432</span> +<span id="433"> 433</span> +<span id="434"> 434</span> +<span id="435"> 435</span> +<span id="436"> 436</span> +<span id="437"> 437</span> +<span id="438"> 438</span> +<span id="439"> 439</span> +<span id="440"> 440</span> +<span id="441"> 441</span> +<span id="442"> 442</span> +<span id="443"> 443</span> +<span id="444"> 444</span> +<span id="445"> 445</span> +<span id="446"> 446</span> +<span id="447"> 447</span> +<span id="448"> 448</span> +<span id="449"> 449</span> +<span id="450"> 450</span> +<span id="451"> 451</span> +<span id="452"> 452</span> +<span id="453"> 453</span> +<span id="454"> 454</span> +<span id="455"> 455</span> +<span id="456"> 456</span> +<span id="457"> 457</span> +<span id="458"> 458</span> +<span id="459"> 459</span> +<span id="460"> 460</span> +<span id="461"> 461</span> +<span id="462"> 462</span> +<span id="463"> 463</span> +<span id="464"> 464</span> +<span id="465"> 465</span> +<span id="466"> 466</span> +<span id="467"> 467</span> +<span id="468"> 468</span> +<span id="469"> 469</span> +<span id="470"> 470</span> +<span id="471"> 471</span> +<span id="472"> 472</span> +<span id="473"> 473</span> +<span id="474"> 474</span> +<span id="475"> 475</span> +<span id="476"> 476</span> +<span id="477"> 477</span> +<span id="478"> 478</span> +<span id="479"> 479</span> +<span id="480"> 480</span> +<span id="481"> 481</span> +<span id="482"> 482</span> +<span id="483"> 483</span> +<span id="484"> 484</span> +<span id="485"> 485</span> +<span id="486"> 486</span> +<span id="487"> 487</span> +<span id="488"> 488</span> +<span id="489"> 489</span> +<span id="490"> 490</span> +<span id="491"> 491</span> +<span id="492"> 492</span> +<span id="493"> 493</span> +<span id="494"> 494</span> +<span id="495"> 495</span> +<span id="496"> 496</span> +<span id="497"> 497</span> +<span id="498"> 498</span> +<span id="499"> 499</span> +<span id="500"> 500</span> +<span id="501"> 501</span> +<span id="502"> 502</span> +<span id="503"> 503</span> +<span id="504"> 504</span> +<span id="505"> 505</span> +<span id="506"> 506</span> +<span id="507"> 507</span> +<span id="508"> 508</span> +<span id="509"> 509</span> +<span id="510"> 510</span> +<span id="511"> 511</span> +<span id="512"> 512</span> +<span id="513"> 513</span> +<span id="514"> 514</span> +<span id="515"> 515</span> +<span id="516"> 516</span> +<span id="517"> 517</span> +<span id="518"> 518</span> +<span id="519"> 519</span> +<span id="520"> 520</span> +<span id="521"> 521</span> +<span id="522"> 522</span> +<span id="523"> 523</span> +<span id="524"> 524</span> +<span id="525"> 525</span> +<span id="526"> 526</span> +<span id="527"> 527</span> +<span id="528"> 528</span> +<span id="529"> 529</span> +<span id="530"> 530</span> +<span id="531"> 531</span> +<span id="532"> 532</span> +<span id="533"> 533</span> +<span id="534"> 534</span> +<span id="535"> 535</span> +<span id="536"> 536</span> +<span id="537"> 537</span> +<span id="538"> 538</span> +<span id="539"> 539</span> +<span id="540"> 540</span> +<span id="541"> 541</span> +<span id="542"> 542</span> +<span id="543"> 543</span> +<span id="544"> 544</span> +<span id="545"> 545</span> +<span id="546"> 546</span> +<span id="547"> 547</span> +<span id="548"> 548</span> +<span id="549"> 549</span> +<span id="550"> 550</span> +<span id="551"> 551</span> +<span id="552"> 552</span> +<span id="553"> 553</span> +<span id="554"> 554</span> +<span id="555"> 555</span> +<span id="556"> 556</span> +<span id="557"> 557</span> +<span id="558"> 558</span> +<span id="559"> 559</span> +<span id="560"> 560</span> +<span id="561"> 561</span> +<span id="562"> 562</span> +<span id="563"> 563</span> +<span id="564"> 564</span> +<span id="565"> 565</span> +<span id="566"> 566</span> +<span id="567"> 567</span> +<span id="568"> 568</span> +<span id="569"> 569</span> +<span id="570"> 570</span> +<span id="571"> 571</span> +<span id="572"> 572</span> +<span id="573"> 573</span> +<span id="574"> 574</span> +<span id="575"> 575</span> +<span id="576"> 576</span> +<span id="577"> 577</span> +<span id="578"> 578</span> +<span id="579"> 579</span> +<span id="580"> 580</span> +<span id="581"> 581</span> +<span id="582"> 582</span> +<span id="583"> 583</span> +<span id="584"> 584</span> +<span id="585"> 585</span> +<span id="586"> 586</span> +<span id="587"> 587</span> +<span id="588"> 588</span> +<span id="589"> 589</span> +<span id="590"> 590</span> +<span id="591"> 591</span> +<span id="592"> 592</span> +<span id="593"> 593</span> +<span id="594"> 594</span> +<span id="595"> 595</span> +<span id="596"> 596</span> +<span id="597"> 597</span> +<span id="598"> 598</span> +<span id="599"> 599</span> +<span id="600"> 600</span> +<span id="601"> 601</span> +<span id="602"> 602</span> +<span id="603"> 603</span> +<span id="604"> 604</span> +<span id="605"> 605</span> +<span id="606"> 606</span> +<span id="607"> 607</span> +<span id="608"> 608</span> +<span id="609"> 609</span> +<span id="610"> 610</span> +<span id="611"> 611</span> +<span id="612"> 612</span> +<span id="613"> 613</span> +<span id="614"> 614</span> +<span id="615"> 615</span> +<span id="616"> 616</span> +<span id="617"> 617</span> +<span id="618"> 618</span> +<span id="619"> 619</span> +<span id="620"> 620</span> +<span id="621"> 621</span> +<span id="622"> 622</span> +<span id="623"> 623</span> +<span id="624"> 624</span> +<span id="625"> 625</span> +<span id="626"> 626</span> +<span id="627"> 627</span> +<span id="628"> 628</span> +<span id="629"> 629</span> +<span id="630"> 630</span> +<span id="631"> 631</span> +<span id="632"> 632</span> +<span id="633"> 633</span> +<span id="634"> 634</span> +<span id="635"> 635</span> +<span id="636"> 636</span> +<span id="637"> 637</span> +<span id="638"> 638</span> +<span id="639"> 639</span> +<span id="640"> 640</span> +<span id="641"> 641</span> +<span id="642"> 642</span> +<span id="643"> 643</span> +<span id="644"> 644</span> +<span id="645"> 645</span> +<span id="646"> 646</span> +<span id="647"> 647</span> +<span id="648"> 648</span> +<span id="649"> 649</span> +<span id="650"> 650</span> +<span id="651"> 651</span> +<span id="652"> 652</span> +<span id="653"> 653</span> +<span id="654"> 654</span> +<span id="655"> 655</span> +<span id="656"> 656</span> +<span id="657"> 657</span> +<span id="658"> 658</span> +<span id="659"> 659</span> +<span id="660"> 660</span> +<span id="661"> 661</span> +<span id="662"> 662</span> +<span id="663"> 663</span> +<span id="664"> 664</span> +<span id="665"> 665</span> +<span id="666"> 666</span> +<span id="667"> 667</span> +<span id="668"> 668</span> +<span id="669"> 669</span> +<span id="670"> 670</span> +<span id="671"> 671</span> +<span id="672"> 672</span> +<span id="673"> 673</span> +<span id="674"> 674</span> +<span id="675"> 675</span> +<span id="676"> 676</span> +<span id="677"> 677</span> +<span id="678"> 678</span> +<span id="679"> 679</span> +<span id="680"> 680</span> +<span id="681"> 681</span> +<span id="682"> 682</span> +<span id="683"> 683</span> +<span id="684"> 684</span> +<span id="685"> 685</span> +<span id="686"> 686</span> +<span id="687"> 687</span> +<span id="688"> 688</span> +<span id="689"> 689</span> +<span id="690"> 690</span> +<span id="691"> 691</span> +<span id="692"> 692</span> +<span id="693"> 693</span> +<span id="694"> 694</span> +<span id="695"> 695</span> +<span id="696"> 696</span> +<span id="697"> 697</span> +<span id="698"> 698</span> +<span id="699"> 699</span> +<span id="700"> 700</span> +<span id="701"> 701</span> +<span id="702"> 702</span> +<span id="703"> 703</span> +<span id="704"> 704</span> +<span id="705"> 705</span> +<span id="706"> 706</span> +<span id="707"> 707</span> +<span id="708"> 708</span> +<span id="709"> 709</span> +<span id="710"> 710</span> +<span id="711"> 711</span> +<span id="712"> 712</span> +<span id="713"> 713</span> +<span id="714"> 714</span> +<span id="715"> 715</span> +<span id="716"> 716</span> +<span id="717"> 717</span> +<span id="718"> 718</span> +<span id="719"> 719</span> +<span id="720"> 720</span> +<span id="721"> 721</span> +<span id="722"> 722</span> +<span id="723"> 723</span> +<span id="724"> 724</span> +<span id="725"> 725</span> +<span id="726"> 726</span> +<span id="727"> 727</span> +<span id="728"> 728</span> +<span id="729"> 729</span> +<span id="730"> 730</span> +<span id="731"> 731</span> +<span id="732"> 732</span> +<span id="733"> 733</span> +<span id="734"> 734</span> +<span id="735"> 735</span> +<span id="736"> 736</span> +<span id="737"> 737</span> +<span id="738"> 738</span> +<span id="739"> 739</span> +<span id="740"> 740</span> +<span id="741"> 741</span> +<span id="742"> 742</span> +<span id="743"> 743</span> +<span id="744"> 744</span> +<span id="745"> 745</span> +<span id="746"> 746</span> +<span id="747"> 747</span> +<span id="748"> 748</span> +<span id="749"> 749</span> +<span id="750"> 750</span> +<span id="751"> 751</span> +<span id="752"> 752</span> +<span id="753"> 753</span> +<span id="754"> 754</span> +<span id="755"> 755</span> +<span id="756"> 756</span> +<span id="757"> 757</span> +<span id="758"> 758</span> +<span id="759"> 759</span> +<span id="760"> 760</span> +<span id="761"> 761</span> +<span id="762"> 762</span> +<span id="763"> 763</span> +<span id="764"> 764</span> +<span id="765"> 765</span> +<span id="766"> 766</span> +<span id="767"> 767</span> +<span id="768"> 768</span> +<span id="769"> 769</span> +<span id="770"> 770</span> +<span id="771"> 771</span> +<span id="772"> 772</span> +<span id="773"> 773</span> +<span id="774"> 774</span> +<span id="775"> 775</span> +<span id="776"> 776</span> +<span id="777"> 777</span> +<span id="778"> 778</span> +<span id="779"> 779</span> +<span id="780"> 780</span> +<span id="781"> 781</span> +<span id="782"> 782</span> +<span id="783"> 783</span> +<span id="784"> 784</span> +<span id="785"> 785</span> +<span id="786"> 786</span> +<span id="787"> 787</span> +<span id="788"> 788</span> +<span id="789"> 789</span> +<span id="790"> 790</span> +<span id="791"> 791</span> +<span id="792"> 792</span> +<span id="793"> 793</span> +<span id="794"> 794</span> +<span id="795"> 795</span> +<span id="796"> 796</span> +<span id="797"> 797</span> +<span id="798"> 798</span> +<span id="799"> 799</span> +<span id="800"> 800</span> +<span id="801"> 801</span> +<span id="802"> 802</span> +<span id="803"> 803</span> +<span id="804"> 804</span> +<span id="805"> 805</span> +<span id="806"> 806</span> +<span id="807"> 807</span> +<span id="808"> 808</span> +<span id="809"> 809</span> +<span id="810"> 810</span> +<span id="811"> 811</span> +<span id="812"> 812</span> +<span id="813"> 813</span> +<span id="814"> 814</span> +<span id="815"> 815</span> +<span id="816"> 816</span> +<span id="817"> 817</span> +<span id="818"> 818</span> +<span id="819"> 819</span> +<span id="820"> 820</span> +<span id="821"> 821</span> +<span id="822"> 822</span> +<span id="823"> 823</span> +<span id="824"> 824</span> +<span id="825"> 825</span> +<span id="826"> 826</span> +<span id="827"> 827</span> +<span id="828"> 828</span> +<span id="829"> 829</span> +<span id="830"> 830</span> +<span id="831"> 831</span> +<span id="832"> 832</span> +<span id="833"> 833</span> +<span id="834"> 834</span> +<span id="835"> 835</span> +<span id="836"> 836</span> +<span id="837"> 837</span> +<span id="838"> 838</span> +<span id="839"> 839</span> +<span id="840"> 840</span> +<span id="841"> 841</span> +<span id="842"> 842</span> +<span id="843"> 843</span> +<span id="844"> 844</span> +<span id="845"> 845</span> +<span id="846"> 846</span> +<span id="847"> 847</span> +<span id="848"> 848</span> +<span id="849"> 849</span> +<span id="850"> 850</span> +<span id="851"> 851</span> +<span id="852"> 852</span> +<span id="853"> 853</span> +<span id="854"> 854</span> +<span id="855"> 855</span> +<span id="856"> 856</span> +<span id="857"> 857</span> +<span id="858"> 858</span> +<span id="859"> 859</span> +<span id="860"> 860</span> +<span id="861"> 861</span> +<span id="862"> 862</span> +<span id="863"> 863</span> +<span id="864"> 864</span> +<span id="865"> 865</span> +<span id="866"> 866</span> +<span id="867"> 867</span> +<span id="868"> 868</span> +<span id="869"> 869</span> +<span id="870"> 870</span> +<span id="871"> 871</span> +<span id="872"> 872</span> +<span id="873"> 873</span> +<span id="874"> 874</span> +<span id="875"> 875</span> +<span id="876"> 876</span> +<span id="877"> 877</span> +<span id="878"> 878</span> +<span id="879"> 879</span> +<span id="880"> 880</span> +<span id="881"> 881</span> +<span id="882"> 882</span> +<span id="883"> 883</span> +<span id="884"> 884</span> +<span id="885"> 885</span> +<span id="886"> 886</span> +<span id="887"> 887</span> +<span id="888"> 888</span> +<span id="889"> 889</span> +<span id="890"> 890</span> +<span id="891"> 891</span> +<span id="892"> 892</span> +<span id="893"> 893</span> +<span id="894"> 894</span> +<span id="895"> 895</span> +<span id="896"> 896</span> +<span id="897"> 897</span> +<span id="898"> 898</span> +<span id="899"> 899</span> +<span id="900"> 900</span> +<span id="901"> 901</span> +<span id="902"> 902</span> +<span id="903"> 903</span> +<span id="904"> 904</span> +<span id="905"> 905</span> +<span id="906"> 906</span> +<span id="907"> 907</span> +<span id="908"> 908</span> +<span id="909"> 909</span> +<span id="910"> 910</span> +<span id="911"> 911</span> +<span id="912"> 912</span> +<span id="913"> 913</span> +<span id="914"> 914</span> +<span id="915"> 915</span> +<span id="916"> 916</span> +<span id="917"> 917</span> +<span id="918"> 918</span> +<span id="919"> 919</span> +<span id="920"> 920</span> +<span id="921"> 921</span> +<span id="922"> 922</span> +<span id="923"> 923</span> +<span id="924"> 924</span> +<span id="925"> 925</span> +<span id="926"> 926</span> +<span id="927"> 927</span> +<span id="928"> 928</span> +<span id="929"> 929</span> +<span id="930"> 930</span> +<span id="931"> 931</span> +<span id="932"> 932</span> +<span id="933"> 933</span> +<span id="934"> 934</span> +<span id="935"> 935</span> +<span id="936"> 936</span> +<span id="937"> 937</span> +<span id="938"> 938</span> +<span id="939"> 939</span> +<span id="940"> 940</span> +<span id="941"> 941</span> +<span id="942"> 942</span> +<span id="943"> 943</span> +<span id="944"> 944</span> +<span id="945"> 945</span> +<span id="946"> 946</span> +<span id="947"> 947</span> +<span id="948"> 948</span> +<span id="949"> 949</span> +<span id="950"> 950</span> +<span id="951"> 951</span> +<span id="952"> 952</span> +<span id="953"> 953</span> +<span id="954"> 954</span> +<span id="955"> 955</span> +<span id="956"> 956</span> +<span id="957"> 957</span> +<span id="958"> 958</span> +<span id="959"> 959</span> +<span id="960"> 960</span> +<span id="961"> 961</span> +<span id="962"> 962</span> +<span id="963"> 963</span> +<span id="964"> 964</span> +<span id="965"> 965</span> +<span id="966"> 966</span> +<span id="967"> 967</span> +<span id="968"> 968</span> +<span id="969"> 969</span> +<span id="970"> 970</span> +<span id="971"> 971</span> +<span id="972"> 972</span> +<span id="973"> 973</span> +<span id="974"> 974</span> +<span id="975"> 975</span> +<span id="976"> 976</span> +<span id="977"> 977</span> +<span id="978"> 978</span> +<span id="979"> 979</span> +<span id="980"> 980</span> +<span id="981"> 981</span> +<span id="982"> 982</span> +<span id="983"> 983</span> +<span id="984"> 984</span> +<span id="985"> 985</span> +<span id="986"> 986</span> +<span id="987"> 987</span> +<span id="988"> 988</span> +<span id="989"> 989</span> +<span id="990"> 990</span> +<span id="991"> 991</span> +<span id="992"> 992</span> +<span id="993"> 993</span> +<span id="994"> 994</span> +<span id="995"> 995</span> +<span id="996"> 996</span> +<span id="997"> 997</span> +<span id="998"> 998</span> +<span id="999"> 999</span> +<span id="1000">1000</span> +<span id="1001">1001</span> +<span id="1002">1002</span> +<span id="1003">1003</span> +<span id="1004">1004</span> +<span id="1005">1005</span> +<span id="1006">1006</span> +<span id="1007">1007</span> +<span id="1008">1008</span> +<span id="1009">1009</span> +<span id="1010">1010</span> +<span id="1011">1011</span> +<span id="1012">1012</span> +<span id="1013">1013</span> +<span id="1014">1014</span> +<span id="1015">1015</span> +<span id="1016">1016</span> +<span id="1017">1017</span> +<span id="1018">1018</span> +<span id="1019">1019</span> +<span id="1020">1020</span> +<span id="1021">1021</span> +<span id="1022">1022</span> +<span id="1023">1023</span> +<span id="1024">1024</span> +<span id="1025">1025</span> +<span id="1026">1026</span> +<span id="1027">1027</span> +<span id="1028">1028</span> +<span id="1029">1029</span> +<span id="1030">1030</span> +<span id="1031">1031</span> +<span id="1032">1032</span> +<span id="1033">1033</span> +<span id="1034">1034</span> +<span id="1035">1035</span> +<span id="1036">1036</span> +<span id="1037">1037</span> +<span id="1038">1038</span> +<span id="1039">1039</span> +<span id="1040">1040</span> +<span id="1041">1041</span> +<span id="1042">1042</span> +<span id="1043">1043</span> +<span id="1044">1044</span> +<span id="1045">1045</span> +<span id="1046">1046</span> +<span id="1047">1047</span> +<span id="1048">1048</span> +<span id="1049">1049</span> +<span id="1050">1050</span> +<span id="1051">1051</span> +<span id="1052">1052</span> +<span id="1053">1053</span> +<span id="1054">1054</span> +<span id="1055">1055</span> +<span id="1056">1056</span> +<span id="1057">1057</span> +<span id="1058">1058</span> +<span id="1059">1059</span> +<span id="1060">1060</span> +<span id="1061">1061</span> +<span id="1062">1062</span> +<span id="1063">1063</span> +<span id="1064">1064</span> +<span id="1065">1065</span> +<span id="1066">1066</span> +<span id="1067">1067</span> +<span id="1068">1068</span> +<span id="1069">1069</span> +<span id="1070">1070</span> +<span id="1071">1071</span> +<span id="1072">1072</span> +<span id="1073">1073</span> +<span id="1074">1074</span> +<span id="1075">1075</span> +<span id="1076">1076</span> +<span id="1077">1077</span> +<span id="1078">1078</span> +<span id="1079">1079</span> +<span id="1080">1080</span> +<span id="1081">1081</span> +<span id="1082">1082</span> +<span id="1083">1083</span> +<span id="1084">1084</span> +<span id="1085">1085</span> +<span id="1086">1086</span> +<span id="1087">1087</span> +<span id="1088">1088</span> +<span id="1089">1089</span> +<span id="1090">1090</span> +<span id="1091">1091</span> +<span id="1092">1092</span> +<span id="1093">1093</span> +<span id="1094">1094</span> +<span id="1095">1095</span> +<span id="1096">1096</span> +<span id="1097">1097</span> +<span id="1098">1098</span> +<span id="1099">1099</span> +<span id="1100">1100</span> +<span id="1101">1101</span> +<span id="1102">1102</span> +<span id="1103">1103</span> +<span id="1104">1104</span> +<span id="1105">1105</span> +<span id="1106">1106</span> +<span id="1107">1107</span> +<span id="1108">1108</span> +<span id="1109">1109</span> +<span id="1110">1110</span> +<span id="1111">1111</span> +<span id="1112">1112</span> +<span id="1113">1113</span> +<span id="1114">1114</span> +<span id="1115">1115</span> +<span id="1116">1116</span> +<span id="1117">1117</span> +<span id="1118">1118</span> +<span id="1119">1119</span> +<span id="1120">1120</span> +<span id="1121">1121</span> +<span id="1122">1122</span> +<span id="1123">1123</span> +<span id="1124">1124</span> +<span id="1125">1125</span> +<span id="1126">1126</span> +<span id="1127">1127</span> +<span id="1128">1128</span> +<span id="1129">1129</span> +<span id="1130">1130</span> +<span id="1131">1131</span> +<span id="1132">1132</span> +<span id="1133">1133</span> +<span id="1134">1134</span> +<span id="1135">1135</span> +<span id="1136">1136</span> +<span id="1137">1137</span> +<span id="1138">1138</span> +<span id="1139">1139</span> +<span id="1140">1140</span> +<span id="1141">1141</span> +<span id="1142">1142</span> +<span id="1143">1143</span> +<span id="1144">1144</span> +<span id="1145">1145</span> +<span id="1146">1146</span> +<span id="1147">1147</span> +<span id="1148">1148</span> +<span id="1149">1149</span> +<span id="1150">1150</span> +<span id="1151">1151</span> +<span id="1152">1152</span> +<span id="1153">1153</span> +<span id="1154">1154</span> +<span id="1155">1155</span> +<span id="1156">1156</span> +<span id="1157">1157</span> +<span id="1158">1158</span> +<span id="1159">1159</span> +<span id="1160">1160</span> +<span id="1161">1161</span> +<span id="1162">1162</span> +<span id="1163">1163</span> +<span id="1164">1164</span> +<span id="1165">1165</span> +<span id="1166">1166</span> +<span id="1167">1167</span> +<span id="1168">1168</span> +<span id="1169">1169</span> +<span id="1170">1170</span> +<span id="1171">1171</span> +<span id="1172">1172</span> +<span id="1173">1173</span> +<span id="1174">1174</span> +<span id="1175">1175</span> +<span id="1176">1176</span> +<span id="1177">1177</span> +<span id="1178">1178</span> +<span id="1179">1179</span> +<span id="1180">1180</span> +<span id="1181">1181</span> +<span id="1182">1182</span> +<span id="1183">1183</span> +<span id="1184">1184</span> +<span id="1185">1185</span> +<span id="1186">1186</span> +<span id="1187">1187</span> +<span id="1188">1188</span> +<span id="1189">1189</span> +<span id="1190">1190</span> +<span id="1191">1191</span> +<span id="1192">1192</span> +<span id="1193">1193</span> +<span id="1194">1194</span> +<span id="1195">1195</span> +<span id="1196">1196</span> +<span id="1197">1197</span> +<span id="1198">1198</span> +<span id="1199">1199</span> +<span id="1200">1200</span> +<span id="1201">1201</span> +<span id="1202">1202</span> +<span id="1203">1203</span> +<span id="1204">1204</span> +<span id="1205">1205</span> +<span id="1206">1206</span> +<span id="1207">1207</span> +<span id="1208">1208</span> +<span id="1209">1209</span> +<span id="1210">1210</span> +<span id="1211">1211</span> +<span id="1212">1212</span> +<span id="1213">1213</span> +<span id="1214">1214</span> +<span id="1215">1215</span> +<span id="1216">1216</span> +<span id="1217">1217</span> +<span id="1218">1218</span> +<span id="1219">1219</span> +<span id="1220">1220</span> +<span id="1221">1221</span> +<span id="1222">1222</span> +<span id="1223">1223</span> +<span id="1224">1224</span> +<span id="1225">1225</span> +<span id="1226">1226</span> +<span id="1227">1227</span> +<span id="1228">1228</span> +<span id="1229">1229</span> +<span id="1230">1230</span> +<span id="1231">1231</span> +<span id="1232">1232</span> +<span id="1233">1233</span> +<span id="1234">1234</span> +<span id="1235">1235</span> +<span id="1236">1236</span> +<span id="1237">1237</span> +<span id="1238">1238</span> +<span id="1239">1239</span> +<span id="1240">1240</span> +<span id="1241">1241</span> +<span id="1242">1242</span> +<span id="1243">1243</span> +<span id="1244">1244</span> +<span id="1245">1245</span> +<span id="1246">1246</span> +<span id="1247">1247</span> +<span id="1248">1248</span> +<span id="1249">1249</span> +<span id="1250">1250</span> +<span id="1251">1251</span> +<span id="1252">1252</span> +<span id="1253">1253</span> +<span id="1254">1254</span> +<span id="1255">1255</span> +<span id="1256">1256</span> +<span id="1257">1257</span> +<span id="1258">1258</span> +<span id="1259">1259</span> +<span id="1260">1260</span> +<span id="1261">1261</span> +<span id="1262">1262</span> +<span id="1263">1263</span> +<span id="1264">1264</span> +<span id="1265">1265</span> +<span id="1266">1266</span> +<span id="1267">1267</span> +<span id="1268">1268</span> +<span id="1269">1269</span> +<span id="1270">1270</span> +<span id="1271">1271</span> +<span id="1272">1272</span> +<span id="1273">1273</span> +<span id="1274">1274</span> +<span id="1275">1275</span> +<span id="1276">1276</span> +<span id="1277">1277</span> +<span id="1278">1278</span> +<span id="1279">1279</span> +<span id="1280">1280</span> +<span id="1281">1281</span> +<span id="1282">1282</span> +<span id="1283">1283</span> +<span id="1284">1284</span> +<span id="1285">1285</span> +<span id="1286">1286</span> +<span id="1287">1287</span> +<span id="1288">1288</span> +<span id="1289">1289</span> +<span id="1290">1290</span> +<span id="1291">1291</span> +<span id="1292">1292</span> +<span id="1293">1293</span> +<span id="1294">1294</span> +<span id="1295">1295</span> +<span id="1296">1296</span> +<span id="1297">1297</span> +<span id="1298">1298</span> +<span id="1299">1299</span> +<span id="1300">1300</span> +<span id="1301">1301</span> +<span id="1302">1302</span> +<span id="1303">1303</span> +<span id="1304">1304</span> +<span id="1305">1305</span> +<span id="1306">1306</span> +<span id="1307">1307</span> +<span id="1308">1308</span> +<span id="1309">1309</span> +<span id="1310">1310</span> +<span id="1311">1311</span> +<span id="1312">1312</span> +<span id="1313">1313</span> +<span id="1314">1314</span> +<span id="1315">1315</span> +<span id="1316">1316</span> +<span id="1317">1317</span> +<span id="1318">1318</span> +<span id="1319">1319</span> +<span id="1320">1320</span> +<span id="1321">1321</span> +<span id="1322">1322</span> +<span id="1323">1323</span> +<span id="1324">1324</span> +<span id="1325">1325</span> +<span id="1326">1326</span> +<span id="1327">1327</span> +<span id="1328">1328</span> +<span id="1329">1329</span> +<span id="1330">1330</span> +<span id="1331">1331</span> +<span id="1332">1332</span> +<span id="1333">1333</span> +<span id="1334">1334</span> +<span id="1335">1335</span> +<span id="1336">1336</span> +<span id="1337">1337</span> +<span id="1338">1338</span> +<span id="1339">1339</span> +<span id="1340">1340</span> +<span id="1341">1341</span> +<span id="1342">1342</span> +<span id="1343">1343</span> +<span id="1344">1344</span> +<span id="1345">1345</span> +<span id="1346">1346</span> +<span id="1347">1347</span> +<span id="1348">1348</span> +<span id="1349">1349</span> +<span id="1350">1350</span> +<span id="1351">1351</span> +<span id="1352">1352</span> +<span id="1353">1353</span> +<span id="1354">1354</span> +<span id="1355">1355</span> +<span id="1356">1356</span> +<span id="1357">1357</span> +<span id="1358">1358</span> +<span id="1359">1359</span> +<span id="1360">1360</span> +<span id="1361">1361</span> +<span id="1362">1362</span> +<span id="1363">1363</span> +<span id="1364">1364</span> +<span id="1365">1365</span> +<span id="1366">1366</span> +<span id="1367">1367</span> +<span id="1368">1368</span> +<span id="1369">1369</span> +<span id="1370">1370</span> +<span id="1371">1371</span> +<span id="1372">1372</span> +<span id="1373">1373</span> +<span id="1374">1374</span> +<span id="1375">1375</span> +<span id="1376">1376</span> +<span id="1377">1377</span> +<span id="1378">1378</span> +<span id="1379">1379</span> +<span id="1380">1380</span> +<span id="1381">1381</span> +<span id="1382">1382</span> +<span id="1383">1383</span> +<span id="1384">1384</span> +<span id="1385">1385</span> +<span id="1386">1386</span> +<span id="1387">1387</span> +<span id="1388">1388</span> +<span id="1389">1389</span> +<span id="1390">1390</span> +<span id="1391">1391</span> +<span id="1392">1392</span> +<span id="1393">1393</span> +<span id="1394">1394</span> +<span id="1395">1395</span> +<span id="1396">1396</span> +<span id="1397">1397</span> +<span id="1398">1398</span> +<span id="1399">1399</span> +<span id="1400">1400</span> +<span id="1401">1401</span> +<span id="1402">1402</span> +<span id="1403">1403</span> +<span id="1404">1404</span> +<span id="1405">1405</span> +<span id="1406">1406</span> +<span id="1407">1407</span> +<span id="1408">1408</span> +<span id="1409">1409</span> +<span id="1410">1410</span> +<span id="1411">1411</span> +<span id="1412">1412</span> +<span id="1413">1413</span> +<span id="1414">1414</span> +<span id="1415">1415</span> +<span id="1416">1416</span> +<span id="1417">1417</span> +<span id="1418">1418</span> +<span id="1419">1419</span> +<span id="1420">1420</span> +<span id="1421">1421</span> +<span id="1422">1422</span> +<span id="1423">1423</span> +<span id="1424">1424</span> +<span id="1425">1425</span> +<span id="1426">1426</span> +<span id="1427">1427</span> +<span id="1428">1428</span> +<span id="1429">1429</span> +<span id="1430">1430</span> +<span id="1431">1431</span> +<span id="1432">1432</span> +<span id="1433">1433</span> +<span id="1434">1434</span> +<span id="1435">1435</span> +<span id="1436">1436</span> +<span id="1437">1437</span> +<span id="1438">1438</span> +<span id="1439">1439</span> +<span id="1440">1440</span> +<span id="1441">1441</span> +<span id="1442">1442</span> +<span id="1443">1443</span> +<span id="1444">1444</span> +<span id="1445">1445</span> +<span id="1446">1446</span> +<span id="1447">1447</span> +<span id="1448">1448</span> +<span id="1449">1449</span> +<span id="1450">1450</span> +<span id="1451">1451</span> +<span id="1452">1452</span> +<span id="1453">1453</span> +<span id="1454">1454</span> +<span id="1455">1455</span> +<span id="1456">1456</span> +<span id="1457">1457</span> +<span id="1458">1458</span> +<span id="1459">1459</span> +<span id="1460">1460</span> +<span id="1461">1461</span> +<span id="1462">1462</span> +<span id="1463">1463</span> +<span id="1464">1464</span> +<span id="1465">1465</span> +<span id="1466">1466</span> +<span id="1467">1467</span> +<span id="1468">1468</span> +<span id="1469">1469</span> +<span id="1470">1470</span> +<span id="1471">1471</span> +<span id="1472">1472</span> +<span id="1473">1473</span> +<span id="1474">1474</span> +<span id="1475">1475</span> +<span id="1476">1476</span> +<span id="1477">1477</span> +<span id="1478">1478</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>borrow</span>::{ <span class='ident'>Cow</span>, <span class='ident'>ToOwned</span> }; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>borrow</span>::<span class='ident'>Cow</span>::<span class='op'>*</span>; + +<span class='kw'>use</span> ::{ <span class='prelude-ty'>Result</span>, <span class='ident'>IrscError</span> }; +<span class='kw'>use</span> ::<span class='ident'>message</span>::{ <span class='ident'>MsgType</span>, <span class='ident'>Message</span> }; + +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>Cow</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>str</span><span class='op'>></span>; + +<span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>non_camel_case_types</span>)]</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>, <span class='ident'>Hash</span>, <span class='ident'>Clone</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Reply</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='doccomment'>/// 001 RPL_WELCOME</span> + <span class='doccomment'>/// "Welcome to the Internet Relay Network</span> + <span class='doccomment'>/// <nick>!<user>@<host>"</span> + <span class='ident'>RPL_WELCOME</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 002 RPL_YOURHOST</span> + <span class='doccomment'>/// "Your host is <servername>, running version <ver>"</span> + <span class='ident'>RPL_YOURHOST</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 003 RPL_CREATED</span> + <span class='doccomment'>/// "This server was created <date>"</span> + <span class='ident'>RPL_CREATED</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 004 RPL_MYINFO</span> + <span class='doccomment'>/// "<servername> <version> <available user modes></span> + <span class='doccomment'>/// <available channel modes>"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - The server sends Replies 001 to 004 to a user upon</span> + <span class='doccomment'>/// successful registration.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_MYINFO</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 005 RPL_BOUNCE</span> + <span class='doccomment'>/// "Try server <server name>, port <port number>"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Sent by the server to a user to suggest an alternative</span> + <span class='doccomment'>/// server. This is often used when the connection is</span> + <span class='doccomment'>/// refused because the server is already full.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_BOUNCE</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 302 RPL_USERHOST</span> + <span class='doccomment'>/// ":*1<reply> *( " " <reply> )"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Reply format used by USERHOST to list replies to</span> + <span class='doccomment'>/// the query list. The reply string is composed as</span> + <span class='doccomment'>/// follows:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// reply = nickname [ "*" ] "=" ( "+" / "-" ) hostname</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The '*' indicates whether the client has registered</span> + <span class='doccomment'>/// as an Operator. The '-' or '+' characters represent</span> + <span class='doccomment'>/// whether the client has set an AWAY message or not</span> + <span class='doccomment'>/// respectively.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_USERHOST</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 303 RPL_ISON</span> + <span class='doccomment'>/// ":*1<nick> *( " " <nick> )"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Reply format used by ISON to list replies to the</span> + <span class='doccomment'>/// query list.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_ISON</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 301 RPL_AWAY</span> + <span class='doccomment'>/// "<nick> :<away message>"</span> + <span class='ident'>RPL_AWAY</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 305 RPL_UNAWAY</span> + <span class='doccomment'>/// ":You are no longer marked as being away"</span> + <span class='ident'>RPL_UNAWAY</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 306 RPL_NOWAWAY</span> + <span class='doccomment'>/// ":You have been marked as being away"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - These replies are used with the AWAY command (if</span> + <span class='doccomment'>/// allowed). RPL_AWAY is sent to any client sending a</span> + <span class='doccomment'>/// PRIVMSG to a client which is away. RPL_AWAY is only</span> + <span class='doccomment'>/// sent by the server to which the client is connected.</span> + <span class='doccomment'>/// Replies RPL_UNAWAY and RPL_NOWAWAY are sent when the</span> + <span class='doccomment'>/// client removes and sets an AWAY message.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_NOWAWAY</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 311 RPL_WHOISUSER</span> + <span class='doccomment'>/// "<nick> <user> <host> * :<real name>"</span> + <span class='ident'>RPL_WHOISUSER</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 312 RPL_WHOISSERVER</span> + <span class='doccomment'>/// "<nick> <server> :<server info>"</span> + <span class='ident'>RPL_WHOISSERVER</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 313 RPL_WHOISOPERATOR</span> + <span class='doccomment'>/// "<nick> :is an IRC operator"</span> + <span class='ident'>RPL_WHOISOPERATOR</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 317 RPL_WHOISIDLE</span> + <span class='doccomment'>/// "<nick> <integer> :seconds idle"</span> + <span class='ident'>RPL_WHOISIDLE</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 318 RPL_ENDOFWHOIS</span> + <span class='doccomment'>/// "<nick> :End of WHOIS list"</span> + <span class='ident'>RPL_ENDOFWHOIS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 319 RPL_WHOISCHANNELS</span> + <span class='doccomment'>/// "<nick> :*( ( "@" / "+" ) <channel> " " )"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Replies 311 - 313, 317 - 319 are all replies</span> + <span class='doccomment'>/// generated in response to a WHOIS message. Given that</span> + <span class='doccomment'>/// there are enough parameters present, the answering</span> + <span class='doccomment'>/// server MUST either formulate a reply out of the above</span> + <span class='doccomment'>/// numerics (if the query nick is found) or return an</span> + <span class='doccomment'>/// error reply. The '*' in RPL_WHOISUSER is there as</span> + <span class='doccomment'>/// the literal character and not as a wild card. For</span> + <span class='doccomment'>/// each reply set, only RPL_WHOISCHANNELS may appear</span> + <span class='doccomment'>/// more than once (for long lists of channel names).</span> + <span class='doccomment'>/// The '@' and '+' characters next to the channel name</span> + <span class='doccomment'>/// indicate whether a client is a channel operator or</span> + <span class='doccomment'>/// has been granted permission to speak on a moderated</span> + <span class='doccomment'>/// channel. The RPL_ENDOFWHOIS reply is used to mark</span> + <span class='doccomment'>/// the end of processing a WHOIS message.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_WHOISCHANNELS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 314 RPL_WHOWASUSER</span> + <span class='doccomment'>/// "<nick> <user> <host> * :<real name>"</span> + <span class='ident'>RPL_WHOWASUSER</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 369 RPL_ENDOFWHOWAS</span> + <span class='doccomment'>/// "<nick> :End of WHOWAS"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - When replying to a WHOWAS message, a server MUST use</span> + <span class='doccomment'>/// the replies RPL_WHOWASUSER, RPL_WHOISSERVER or</span> + <span class='doccomment'>/// ERR_WASNOSUCHNICK for each nickname in the presented</span> + <span class='doccomment'>/// list. At the end of all reply batches, there MUST</span> + <span class='doccomment'>/// be RPL_ENDOFWHOWAS (even if there was only one reply</span> + <span class='doccomment'>/// and it was an error).</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_ENDOFWHOWAS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 321 RPL_LISTSTART</span> + <span class='doccomment'>/// Obsolete. Not used.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_LISTSTART</span>, + + <span class='doccomment'>/// 322 RPL_LIST</span> + <span class='doccomment'>/// "<channel> <# visible> :<topic>"</span> + <span class='ident'>RPL_LIST</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 323 RPL_LISTEND</span> + <span class='doccomment'>/// ":End of LIST"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Replies RPL_LIST, RPL_LISTEND mark the actual replies</span> + <span class='doccomment'>/// with data and end of the server's response to a LIST</span> + <span class='doccomment'>/// command. If there are no channels available to return,</span> + <span class='doccomment'>/// only the end reply MUST be sent.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_LISTEND</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 325 RPL_UNIQOPIS</span> + <span class='doccomment'>/// "<channel> <nickname>"</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_UNIQOPIS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 324 RPL_CHANNELMODEIS</span> + <span class='doccomment'>/// "<channel> <mode> <mode params>"</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_CHANNELMODEIS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 331 RPL_NOTOPIC</span> + <span class='doccomment'>/// "<channel> :No topic is set"</span> + <span class='ident'>RPL_NOTOPIC</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 332 RPL_TOPIC</span> + <span class='doccomment'>/// "<channel> :<topic>"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - When sending a TOPIC message to determine the</span> + <span class='doccomment'>/// channel topic, one of two replies is sent. If</span> + <span class='doccomment'>/// the topic is set, RPL_TOPIC is sent back else</span> + <span class='doccomment'>/// RPL_NOTOPIC.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_TOPIC</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 341 RPL_INVITING</span> + <span class='doccomment'>/// "<channel> <nick>"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned by the server to indicate that the</span> + <span class='doccomment'>/// attempted INVITE message was successful and is</span> + <span class='doccomment'>/// being passed onto the end client.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_INVITING</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 342 RPL_SUMMONING</span> + <span class='doccomment'>/// "<user> :Summoning user to IRC"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned by a server answering a SUMMON message to</span> + <span class='doccomment'>/// indicate that it is summoning that user.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_SUMMONING</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 346 RPL_INVITELIST</span> + <span class='doccomment'>/// "<channel> <invitemask>"</span> + <span class='ident'>RPL_INVITELIST</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 347 RPL_ENDOFINVITELIST</span> + <span class='doccomment'>/// "<channel> :End of channel invite list"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - When listing the 'invitations masks' for a given channel,</span> + <span class='doccomment'>/// a server is required to send the list back using the</span> + <span class='doccomment'>/// RPL_INVITELIST and RPL_ENDOFINVITELIST messages. A</span> + <span class='doccomment'>/// separate RPL_INVITELIST is sent for each active mask.</span> + <span class='doccomment'>/// After the masks have been listed (or if none present) a</span> + <span class='doccomment'>/// RPL_ENDOFINVITELIST MUST be sent.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_ENDOFINVITELIST</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 348 RPL_EXCEPTLIST</span> + <span class='doccomment'>/// "<channel> <exceptionmask>"</span> + <span class='ident'>RPL_EXCEPTLIST</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 349 RPL_ENDOFEXCEPTLIST</span> + <span class='doccomment'>/// "<channel> :End of channel exception list"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - When listing the 'exception masks' for a given channel,</span> + <span class='doccomment'>/// a server is required to send the list back using the</span> + <span class='doccomment'>/// RPL_EXCEPTLIST and RPL_ENDOFEXCEPTLIST messages. A</span> + <span class='doccomment'>/// separate RPL_EXCEPTLIST is sent for each active mask.</span> + <span class='doccomment'>/// After the masks have been listed (or if none present)</span> + <span class='doccomment'>/// a RPL_ENDOFEXCEPTLIST MUST be sent.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_ENDOFEXCEPTLIST</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 351 RPL_VERSION</span> + <span class='doccomment'>/// "<version>.<debuglevel> <server> :<comments>"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Reply by the server showing its version details.</span> + <span class='doccomment'>/// The <version> is the version of the software being</span> + <span class='doccomment'>/// used (including any patchlevel revisions) and the</span> + <span class='doccomment'>/// <debuglevel> is used to indicate if the server is</span> + <span class='doccomment'>/// running in "debug mode".</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The "comments" field may contain any comments about</span> + <span class='doccomment'>/// the version or further version details.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_VERSION</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 352 RPL_WHOREPLY</span> + <span class='doccomment'>/// "<channel> <user> <host> <server> <nick></span> + <span class='doccomment'>/// ( "H" / "G" > ["*"] [ ( "@" / "+" ) ]</span> + <span class='doccomment'>/// :<hopcount> <real name>"</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_WHOREPLY</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 315 RPL_ENDOFWHO</span> + <span class='doccomment'>/// "<name> :End of WHO list"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - The RPL_WHOREPLY and RPL_ENDOFWHO pair are used</span> + <span class='doccomment'>/// to answer a WHO message. The RPL_WHOREPLY is only</span> + <span class='doccomment'>/// sent if there is an appropriate match to the WHO</span> + <span class='doccomment'>/// query. If there is a list of parameters supplied</span> + <span class='doccomment'>/// with a WHO message, a RPL_ENDOFWHO MUST be sent</span> + <span class='doccomment'>/// after processing each list item with <name> being</span> + <span class='doccomment'>/// the item.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_ENDOFWHO</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 353 RPL_NAMREPLY</span> + <span class='doccomment'>/// "( "=" / "*" / "@" ) <channel></span> + <span class='doccomment'>/// :[ "@" / "+" ] <nick> *( " " [ "@" / "+" ] <nick> )</span> + <span class='doccomment'>/// - "@" is used for secret channels, "*" for private</span> + <span class='doccomment'>/// channels, and "=" for others (public channels).</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_NAMREPLY</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 366 RPL_ENDOFNAMES</span> + <span class='doccomment'>/// "<channel> :End of NAMES list"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - To reply to a NAMES message, a reply pair consisting</span> + <span class='doccomment'>/// of RPL_NAMREPLY and RPL_ENDOFNAMES is sent by the</span> + <span class='doccomment'>/// server back to the client. If there is no channel</span> + <span class='doccomment'>/// found as in the query, then only RPL_ENDOFNAMES is</span> + <span class='doccomment'>/// returned. The exception to this is when a NAMES</span> + <span class='doccomment'>/// message is sent with no parameters and all visible</span> + <span class='doccomment'>/// channels and contents are sent back in a series of</span> + <span class='doccomment'>/// RPL_NAMEREPLY messages with a RPL_ENDOFNAMES to mark</span> + <span class='doccomment'>/// the end.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_ENDOFNAMES</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 364 RPL_LINKS</span> + <span class='doccomment'>/// "<mask> <server> :<hopcount> <server info>"</span> + <span class='ident'>RPL_LINKS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 365 RPL_ENDOFLINKS</span> + <span class='doccomment'>/// "<mask> :End of LINKS list"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - In replying to the LINKS message, a server MUST send</span> + <span class='doccomment'>/// replies back using the RPL_LINKS numeric and mark the</span> + <span class='doccomment'>/// end of the list using an RPL_ENDOFLINKS reply.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_ENDOFLINKS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 367 RPL_BANLIST</span> + <span class='doccomment'>/// "<channel> <banmask>"</span> + <span class='ident'>RPL_BANLIST</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 368 RPL_ENDOFBANLIST</span> + <span class='doccomment'>/// "<channel> :End of channel ban list"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - When listing the active 'bans' for a given channel,</span> + <span class='doccomment'>/// a server is required to send the list back using the</span> + <span class='doccomment'>/// RPL_BANLIST and RPL_ENDOFBANLIST messages. A separate</span> + <span class='doccomment'>/// RPL_BANLIST is sent for each active banmask. After the</span> + <span class='doccomment'>/// banmasks have been listed (or if none present) a</span> + <span class='doccomment'>/// RPL_ENDOFBANLIST MUST be sent.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_ENDOFBANLIST</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 371 RPL_INFO</span> + <span class='doccomment'>/// ":<string>"</span> + <span class='ident'>RPL_INFO</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 374 RPL_ENDOFINFO</span> + <span class='doccomment'>/// ":End of INFO list"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - A server responding to an INFO message is required to</span> + <span class='doccomment'>/// send all its 'info' in a series of RPL_INFO messages</span> + <span class='doccomment'>/// with a RPL_ENDOFINFO reply to indicate the end of the</span> + <span class='doccomment'>/// replies.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_ENDOFINFO</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 375 RPL_MOTDSTART</span> + <span class='doccomment'>/// ":- <server> Message of the day - "</span> + <span class='ident'>RPL_MOTDSTART</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 372 RPL_MOTD</span> + <span class='doccomment'>/// ":- <text>"</span> + <span class='ident'>RPL_MOTD</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 376 RPL_ENDOFMOTD</span> + <span class='doccomment'>/// ":End of MOTD command"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - When responding to the MOTD message and the MOTD file</span> + <span class='doccomment'>/// is found, the file is displayed line by line, with</span> + <span class='doccomment'>/// each line no longer than 80 characters, using</span> + <span class='doccomment'>/// RPL_MOTD format replies. These MUST be surrounded</span> + <span class='doccomment'>/// by a RPL_MOTDSTART (before the RPL_MOTDs) and an</span> + <span class='doccomment'>/// RPL_ENDOFMOTD (after).</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_ENDOFMOTD</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 381 RPL_YOUREOPER</span> + <span class='doccomment'>/// ":You are now an IRC operator"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - RPL_YOUREOPER is sent back to a client which has</span> + <span class='doccomment'>/// just successfully issued an OPER message and gained</span> + <span class='doccomment'>/// operator status.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_YOUREOPER</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 382 RPL_REHASHING</span> + <span class='doccomment'>/// "<config file> :Rehashing"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - If the REHASH option is used and an operator sends</span> + <span class='doccomment'>/// a REHASH message, an RPL_REHASHING is sent back to</span> + <span class='doccomment'>/// the operator.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_REHASHING</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 383 RPL_YOURESERVICE</span> + <span class='doccomment'>/// "You are service <servicename>"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Sent by the server to a service upon successful</span> + <span class='doccomment'>/// registration.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_YOURESERVICE</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 391 RPL_TIME</span> + <span class='doccomment'>/// "<server> :<string showing server's local time>"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - When replying to the TIME message, a server MUST send</span> + <span class='doccomment'>/// the reply using the RPL_TIME format above. The string</span> + <span class='doccomment'>/// showing the time need only contain the correct day and</span> + <span class='doccomment'>/// time there. There is no further requirement for the</span> + <span class='doccomment'>/// time string.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_TIME</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 392 RPL_USERSSTART</span> + <span class='doccomment'>/// ":UserID Terminal Host"</span> + <span class='ident'>RPL_USERSSTART</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 393 RPL_USERS</span> + <span class='doccomment'>/// ":<username> <ttyline> <hostname>"</span> + <span class='ident'>RPL_USERS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 394 RPL_ENDOFUSERS</span> + <span class='doccomment'>/// ":End of users"</span> + <span class='ident'>RPL_ENDOFUSERS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 395 RPL_NOUSERS</span> + <span class='doccomment'>/// ":Nobody logged in"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - If the USERS message is handled by a server, the</span> + <span class='doccomment'>/// replies RPL_USERSTART, RPL_USERS, RPL_ENDOFUSERS and</span> + <span class='doccomment'>/// RPL_NOUSERS are used. RPL_USERSSTART MUST be sent</span> + <span class='doccomment'>/// first, following by either a sequence of RPL_USERS</span> + <span class='doccomment'>/// or a single RPL_NOUSER. Following this is</span> + <span class='doccomment'>/// RPL_ENDOFUSERS.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_NOUSERS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 200 RPL_TRACELINK</span> + <span class='doccomment'>/// "Link <version & debug level> <destination></span> + <span class='doccomment'>/// <next server> V<protocol version></span> + <span class='doccomment'>/// <link uptime in seconds> <backstream sendq></span> + <span class='doccomment'>/// <upstream sendq>"</span> + <span class='ident'>RPL_TRACELINK</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 201 RPL_TRACECONNECTING</span> + <span class='doccomment'>/// "Try. <class> <server>"</span> + <span class='ident'>RPL_TRACECONNECTING</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 202 RPL_TRACEHANDSHAKE</span> + <span class='doccomment'>/// "H.S. <class> <server>"</span> + <span class='ident'>RPL_TRACEHANDSHAKE</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 203 RPL_TRACEUNKNOWN</span> + <span class='doccomment'>/// "???? <class> [<client IP address in dot form>]"</span> + <span class='ident'>RPL_TRACEUNKNOWN</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 204 RPL_TRACEOPERATOR</span> + <span class='doccomment'>/// "Oper <class> <nick>"</span> + <span class='ident'>RPL_TRACEOPERATOR</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 205 RPL_TRACEUSER</span> + <span class='doccomment'>/// "User <class> <nick>"</span> + <span class='ident'>RPL_TRACEUSER</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 206 RPL_TRACESERVER</span> + <span class='doccomment'>/// "Serv <class> <int>S <int>C <server></span> + <span class='doccomment'>/// <nick!user|*!*>@<host|server> V<protocol version>"</span> + <span class='ident'>RPL_TRACESERVER</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 207 RPL_TRACESERVICE</span> + <span class='doccomment'>/// "Service <class> <name> <type> <active type>"</span> + <span class='ident'>RPL_TRACESERVICE</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 208 RPL_TRACENEWTYPE</span> + <span class='doccomment'>/// "<newtype> 0 <client name>"</span> + <span class='ident'>RPL_TRACENEWTYPE</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 209 RPL_TRACECLASS</span> + <span class='doccomment'>/// "Class <class> <count>"</span> + <span class='ident'>RPL_TRACECLASS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 210 RPL_TRACERECONNECT</span> + <span class='doccomment'>/// Unused.</span> + <span class='ident'>RPL_TRACERECONNECT</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 261 RPL_TRACELOG</span> + <span class='doccomment'>/// "File <logfile> <debug level>"</span> + <span class='ident'>RPL_TRACELOG</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 262 RPL_TRACEEND</span> + <span class='doccomment'>/// "<server name> <version & debug level> :End of TRACE"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - The RPL_TRACE* are all returned by the server in</span> + <span class='doccomment'>/// response to the TRACE message. How many are</span> + <span class='doccomment'>/// returned is dependent on the TRACE message and</span> + <span class='doccomment'>/// whether it was sent by an operator or not. There</span> + <span class='doccomment'>/// is no predefined order for which occurs first.</span> + <span class='doccomment'>/// Replies RPL_TRACEUNKNOWN, RPL_TRACECONNECTING and</span> + <span class='doccomment'>/// RPL_TRACEHANDSHAKE are all used for connections</span> + <span class='doccomment'>/// which have not been fully established and are either</span> + <span class='doccomment'>/// unknown, still attempting to connect or in the</span> + <span class='doccomment'>/// process of completing the 'server handshake'.</span> + <span class='doccomment'>/// RPL_TRACELINK is sent by any server which handles</span> + <span class='doccomment'>/// a TRACE message and has to pass it on to another</span> + <span class='doccomment'>/// server. The list of RPL_TRACELINKs sent in</span> + <span class='doccomment'>/// response to a TRACE command traversing the IRC</span> + <span class='doccomment'>/// network should reflect the actual connectivity of</span> + <span class='doccomment'>/// the servers themselves along that path.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// RPL_TRACENEWTYPE is to be used for any connection</span> + <span class='doccomment'>/// which does not fit in the other categories but is</span> + <span class='doccomment'>/// being displayed anyway.</span> + <span class='doccomment'>/// RPL_TRACEEND is sent to indicate the end of the list.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_TRACEEND</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 211 RPL_STATSLINKINFO</span> + <span class='doccomment'>/// "<linkname> <sendq> <sent messages></span> + <span class='doccomment'>/// <sent Kbytes> <received messages></span> + <span class='doccomment'>/// <received Kbytes> <time open>"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - reports statistics on a connection. <linkname></span> + <span class='doccomment'>/// identifies the particular connection, <sendq> is</span> + <span class='doccomment'>/// the amount of data that is queued and waiting to be</span> + <span class='doccomment'>/// sent <sent messages> the number of messages sent,</span> + <span class='doccomment'>/// and <sent Kbytes> the amount of data sent, in</span> + <span class='doccomment'>/// Kbytes. <received messages> and <received Kbytes></span> + <span class='doccomment'>/// are the equivalent of <sent messages> and <sent</span> + <span class='doccomment'>/// Kbytes> for received data, respectively. <time</span> + <span class='doccomment'>/// open> indicates how long ago the connection was</span> + <span class='doccomment'>/// opened, in seconds.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_STATSLINKINFO</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 212 RPL_STATSCOMMANDS</span> + <span class='doccomment'>/// "<command> <count> <byte count> <remote count>"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - reports statistics on commands usage.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_STATSCOMMANDS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 219 RPL_ENDOFSTATS</span> + <span class='doccomment'>/// "<stats letter> :End of STATS report"</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_ENDOFSTATS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 242 RPL_STATSUPTIME</span> + <span class='doccomment'>/// ":Server Up %d days %d:%02d:%02d"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - reports the server uptime.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_STATSUPTIME</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 243 RPL_STATSOLINE</span> + <span class='doccomment'>/// "O <hostmask> * <name>"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - reports the allowed hosts from where user may become IRC</span> + <span class='doccomment'>/// operators.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_STATSOLINE</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 221 RPL_UMODEIS</span> + <span class='doccomment'>/// "<user mode string>"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - To answer a query about a client's own mode,</span> + <span class='doccomment'>/// RPL_UMODEIS is sent back.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_UMODEIS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 234 RPL_SERVLIST</span> + <span class='doccomment'>/// "<name> <server> <mask> <type> <hopcount> <info>"</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_SERVLIST</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 235 RPL_SERVLISTEND</span> + <span class='doccomment'>/// "<mask> <type> :End of service listing"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - When listing services in reply to a SERVLIST message,</span> + <span class='doccomment'>/// a server is required to send the list back using the</span> + <span class='doccomment'>/// RPL_SERVLIST and RPL_SERVLISTEND messages. A separate</span> + <span class='doccomment'>/// RPL_SERVLIST is sent for each service. After the</span> + <span class='doccomment'>/// services have been listed (or if none present) a</span> + <span class='doccomment'>/// RPL_SERVLISTEND MUST be sent.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_SERVLISTEND</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 251 RPL_LUSERCLIENT</span> + <span class='doccomment'>/// ":There are <integer> users and <integer></span> + <span class='doccomment'>/// services on <integer> servers"</span> + <span class='ident'>RPL_LUSERCLIENT</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 252 RPL_LUSEROP</span> + <span class='doccomment'>/// "<integer> :operator(s) online"</span> + <span class='ident'>RPL_LUSEROP</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 253 RPL_LUSERUNKNOWN</span> + <span class='doccomment'>/// "<integer> :unknown connection(s)"</span> + <span class='ident'>RPL_LUSERUNKNOWN</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 254 RPL_LUSERCHANNELS</span> + <span class='doccomment'>/// "<integer> :channels formed"</span> + <span class='ident'>RPL_LUSERCHANNELS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 255 RPL_LUSERME</span> + <span class='doccomment'>/// ":I have <integer> clients and <integer></span> + <span class='doccomment'>/// servers"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - In processing an LUSERS message, the server</span> + <span class='doccomment'>/// sends a set of replies from RPL_LUSERCLIENT,</span> + <span class='doccomment'>/// RPL_LUSEROP, RPL_USERUNKNOWN,</span> + <span class='doccomment'>/// RPL_LUSERCHANNELS and RPL_LUSERME. When</span> + <span class='doccomment'>/// replying, a server MUST send back</span> + <span class='doccomment'>/// RPL_LUSERCLIENT and RPL_LUSERME. The other</span> + <span class='doccomment'>/// replies are only sent back if a non-zero count</span> + <span class='doccomment'>/// is found for them.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_LUSERME</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 256 RPL_ADMINME</span> + <span class='doccomment'>/// "<server> :Administrative info"</span> + <span class='ident'>RPL_ADMINME</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 257 RPL_ADMINLOC1</span> + <span class='doccomment'>/// ":<admin info>"</span> + <span class='ident'>RPL_ADMINLOC1</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 258 RPL_ADMINLOC2</span> + <span class='doccomment'>/// ":<admin info>"</span> + <span class='ident'>RPL_ADMINLOC2</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 259 RPL_ADMINEMAIL</span> + <span class='doccomment'>/// ":<admin info>"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - When replying to an ADMIN message, a server</span> + <span class='doccomment'>/// is expected to use replies RPL_ADMINME</span> + <span class='doccomment'>/// through to RPL_ADMINEMAIL and provide a text</span> + <span class='doccomment'>/// message with each. For RPL_ADMINLOC1 a</span> + <span class='doccomment'>/// description of what city, state and country</span> + <span class='doccomment'>/// the server is in is expected, followed by</span> + <span class='doccomment'>/// details of the institution (RPL_ADMINLOC2)</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// and finally the administrative contact for the</span> + <span class='doccomment'>/// server (an email address here is REQUIRED)</span> + <span class='doccomment'>/// in RPL_ADMINEMAIL.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_ADMINEMAIL</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 263 RPL_TRYAGAIN</span> + <span class='doccomment'>/// "<command> :Please wait a while and try again."</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - When a server drops a command without processing it,</span> + <span class='doccomment'>/// it MUST use the reply RPL_TRYAGAIN to inform the</span> + <span class='doccomment'>/// originating client.</span> + <span class='doccomment'>///</span> + <span class='ident'>RPL_TRYAGAIN</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 401 ERR_NOSUCHNICK</span> + <span class='doccomment'>/// "<nickname> :No such nick/channel"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Used to indicate the nickname parameter supplied to a</span> + <span class='doccomment'>/// command is currently unused.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_NOSUCHNICK</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 402 ERR_NOSUCHSERVER</span> + <span class='doccomment'>/// "<server name> :No such server"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Used to indicate the server name given currently</span> + <span class='doccomment'>/// does not exist.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_NOSUCHSERVER</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 403 ERR_NOSUCHCHANNEL</span> + <span class='doccomment'>/// "<channel name> :No such channel"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Used to indicate the given channel name is invalid.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_NOSUCHCHANNEL</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 404 ERR_CANNOTSENDTOCHAN</span> + <span class='doccomment'>/// "<channel name> :Cannot send to channel"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Sent to a user who is either (a) not on a channel</span> + <span class='doccomment'>/// which is mode +n or (b) not a chanop (or mode +v) on</span> + <span class='doccomment'>/// a channel which has mode +m set or where the user is</span> + <span class='doccomment'>/// banned and is trying to send a PRIVMSG message to</span> + <span class='doccomment'>/// that channel.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_CANNOTSENDTOCHAN</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 405 ERR_TOOMANYCHANNELS</span> + <span class='doccomment'>/// "<channel name> :You have joined too many channels"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Sent to a user when they have joined the maximum</span> + <span class='doccomment'>/// number of allowed channels and they try to join</span> + <span class='doccomment'>/// another channel.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_TOOMANYCHANNELS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 406 ERR_WASNOSUCHNICK</span> + <span class='doccomment'>/// "<nickname> :There was no such nickname"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned by WHOWAS to indicate there is no history</span> + <span class='doccomment'>/// information for that nickname.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_WASNOSUCHNICK</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 407 ERR_TOOMANYTARGETS</span> + <span class='doccomment'>/// "<target> :<error code> recipients. <abort message>"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned to a client which is attempting to send a</span> + <span class='doccomment'>/// PRIVMSG/NOTICE using the user@host destination format</span> + <span class='doccomment'>/// and for a user@host which has several occurrences.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned to a client which trying to send a</span> + <span class='doccomment'>/// PRIVMSG/NOTICE to too many recipients.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned to a client which is attempting to JOIN a safe</span> + <span class='doccomment'>/// channel using the shortname when there are more than one</span> + <span class='doccomment'>/// such channel.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_TOOMANYTARGETS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 408 ERR_NOSUCHSERVICE</span> + <span class='doccomment'>/// "<service name> :No such service"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned to a client which is attempting to send a SQUERY</span> + <span class='doccomment'>/// to a service which does not exist.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_NOSUCHSERVICE</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 409 ERR_NOORIGIN</span> + <span class='doccomment'>/// ":No origin specified"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - PING or PONG message missing the originator parameter.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_NOORIGIN</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 411 ERR_NORECIPIENT</span> + <span class='doccomment'>/// ":No recipient given (<command>)"</span> + <span class='ident'>ERR_NORECIPIENT</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 412 ERR_NOTEXTTOSEND</span> + <span class='doccomment'>/// ":No text to send"</span> + <span class='ident'>ERR_NOTEXTTOSEND</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 413 ERR_NOTOPLEVEL</span> + <span class='doccomment'>/// "<mask> :No toplevel domain specified"</span> + <span class='ident'>ERR_NOTOPLEVEL</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 414 ERR_WILDTOPLEVEL</span> + <span class='doccomment'>/// "<mask> :Wildcard in toplevel domain"</span> + <span class='ident'>ERR_WILDTOPLEVEL</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 415 ERR_BADMASK</span> + <span class='doccomment'>/// "<mask> :Bad Server/host mask"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - 412 - 415 are returned by PRIVMSG to indicate that</span> + <span class='doccomment'>/// the message wasn't delivered for some reason.</span> + <span class='doccomment'>/// ERR_NOTOPLEVEL and ERR_WILDTOPLEVEL are errors that</span> + <span class='doccomment'>/// are returned when an invalid use of</span> + <span class='doccomment'>/// "PRIVMSG $<server>" or "PRIVMSG #<host>" is attempted.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_BADMASK</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 421 ERR_UNKNOWNCOMMAND</span> + <span class='doccomment'>/// "<command> :Unknown command"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned to a registered client to indicate that the</span> + <span class='doccomment'>/// command sent is unknown by the server.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_UNKNOWNCOMMAND</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 422 ERR_NOMOTD</span> + <span class='doccomment'>/// ":MOTD File is missing"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Server's MOTD file could not be opened by the server.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_NOMOTD</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 423 ERR_NOADMININFO</span> + <span class='doccomment'>/// "<server> :No administrative info available"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned by a server in response to an ADMIN message</span> + <span class='doccomment'>/// when there is an error in finding the appropriate</span> + <span class='doccomment'>/// information.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_NOADMININFO</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 424 ERR_FILEERROR</span> + <span class='doccomment'>/// ":File error doing <file op> on <file>"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Generic error message used to report a failed file</span> + <span class='doccomment'>/// operation during the processing of a message.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_FILEERROR</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 431 ERR_NONICKNAMEGIVEN</span> + <span class='doccomment'>/// ":No nickname given"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned when a nickname parameter expected for a</span> + <span class='doccomment'>/// command and isn't found.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_NONICKNAMEGIVEN</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 432 ERR_ERRONEUSNICKNAME</span> + <span class='doccomment'>/// "<nick> :Erroneous nickname"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned after receiving a NICK message which contains</span> + <span class='doccomment'>/// characters which do not fall in the defined set. See</span> + <span class='doccomment'>/// section 2.3.1 for details on valid nicknames.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_ERRONEUSNICKNAME</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 433 ERR_NICKNAMEINUSE</span> + <span class='doccomment'>/// "<nick> :Nickname is already in use"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned when a NICK message is processed that results</span> + <span class='doccomment'>/// in an attempt to change to a currently existing</span> + <span class='doccomment'>/// nickname.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_NICKNAMEINUSE</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 436 ERR_NICKCOLLISION</span> + <span class='doccomment'>/// "<nick> :Nickname collision KILL from <user>@<host>"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned by a server to a client when it detects a</span> + <span class='doccomment'>/// nickname collision (registered of a NICK that</span> + <span class='doccomment'>/// already exists by another server).</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_NICKCOLLISION</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 437 ERR_UNAVAILRESOURCE</span> + <span class='doccomment'>/// "<nick/channel> :Nick/channel is temporarily unavailable"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned by a server to a user trying to join a channel</span> + <span class='doccomment'>/// currently blocked by the channel delay mechanism.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned by a server to a user trying to change nickname</span> + <span class='doccomment'>/// when the desired nickname is blocked by the nick delay</span> + <span class='doccomment'>/// mechanism.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_UNAVAILRESOURCE</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 441 ERR_USERNOTINCHANNEL</span> + <span class='doccomment'>/// "<nick> <channel> :They aren't on that channel"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned by the server to indicate that the target</span> + <span class='doccomment'>/// user of the command is not on the given channel.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_USERNOTINCHANNEL</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 442 ERR_NOTONCHANNEL</span> + <span class='doccomment'>/// "<channel> :You're not on that channel"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned by the server whenever a client tries to</span> + <span class='doccomment'>/// perform a channel affecting command for which the</span> + <span class='doccomment'>/// client isn't a member.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_NOTONCHANNEL</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 443 ERR_USERONCHANNEL</span> + <span class='doccomment'>/// "<user> <channel> :is already on channel"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned when a client tries to invite a user to a</span> + <span class='doccomment'>/// channel they are already on.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_USERONCHANNEL</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 444 ERR_NOLOGIN</span> + <span class='doccomment'>/// "<user> :User not logged in"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned by the summon after a SUMMON command for a</span> + <span class='doccomment'>/// user was unable to be performed since they were not</span> + <span class='doccomment'>/// logged in.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_NOLOGIN</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 445 ERR_SUMMONDISABLED</span> + <span class='doccomment'>/// ":SUMMON has been disabled"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned as a response to the SUMMON command. MUST be</span> + <span class='doccomment'>/// returned by any server which doesn't implement it.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_SUMMONDISABLED</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 446 ERR_USERSDISABLED</span> + <span class='doccomment'>/// ":USERS has been disabled"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned as a response to the USERS command. MUST be</span> + <span class='doccomment'>/// returned by any server which does not implement it.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_USERSDISABLED</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 451 ERR_NOTREGISTERED</span> + <span class='doccomment'>/// ":You have not registered"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned by the server to indicate that the client</span> + <span class='doccomment'>/// MUST be registered before the server will allow it</span> + <span class='doccomment'>/// to be parsed in detail.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_NOTREGISTERED</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 461 ERR_NEEDMOREPARAMS</span> + <span class='doccomment'>/// "<command> :Not enough parameters"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned by the server by numerous commands to</span> + <span class='doccomment'>/// indicate to the client that it didn't supply enough</span> + <span class='doccomment'>/// parameters.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_NEEDMOREPARAMS</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 462 ERR_ALREADYREGISTRED</span> + <span class='doccomment'>/// ":Unauthorized command (already registered)"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned by the server to any link which tries to</span> + <span class='doccomment'>/// change part of the registered details (such as</span> + <span class='doccomment'>/// password or user details from second USER message).</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_ALREADYREGISTRED</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 463 ERR_NOPERMFORHOST</span> + <span class='doccomment'>/// ":Your host isn't among the privileged"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned to a client which attempts to register with</span> + <span class='doccomment'>/// a server which does not been setup to allow</span> + <span class='doccomment'>/// connections from the host the attempted connection</span> + <span class='doccomment'>/// is tried.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_NOPERMFORHOST</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 464 ERR_PASSWDMISMATCH</span> + <span class='doccomment'>/// ":Password incorrect"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned to indicate a failed attempt at registering</span> + <span class='doccomment'>/// a connection for which a password was required and</span> + <span class='doccomment'>/// was either not given or incorrect.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_PASSWDMISMATCH</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 465 ERR_YOUREBANNEDCREEP</span> + <span class='doccomment'>/// ":You are banned from this server"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned after an attempt to connect and register</span> + <span class='doccomment'>/// yourself with a server which has been setup to</span> + <span class='doccomment'>/// explicitly deny connections to you.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_YOUREBANNEDCREEP</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 466 ERR_YOUWILLBEBANNED</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Sent by a server to a user to inform that access to the</span> + <span class='doccomment'>/// server will soon be denied.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_YOUWILLBEBANNED</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 467 ERR_KEYSET</span> + <span class='doccomment'>/// "<channel> :Channel key already set"</span> + <span class='ident'>ERR_KEYSET</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 471 ERR_CHANNELISFULL</span> + <span class='doccomment'>/// "<channel> :Cannot join channel (+l)"</span> + <span class='ident'>ERR_CHANNELISFULL</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 472 ERR_UNKNOWNMODE</span> + <span class='doccomment'>/// "<char> :is unknown mode char to me for <channel>"</span> + <span class='ident'>ERR_UNKNOWNMODE</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 473 ERR_INVITEONLYCHAN</span> + <span class='doccomment'>/// "<channel> :Cannot join channel (+i)"</span> + <span class='ident'>ERR_INVITEONLYCHAN</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 474 ERR_BANNEDFROMCHAN</span> + <span class='doccomment'>/// "<channel> :Cannot join channel (+b)"</span> + <span class='ident'>ERR_BANNEDFROMCHAN</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 475 ERR_BADCHANNELKEY</span> + <span class='doccomment'>/// "<channel> :Cannot join channel (+k)"</span> + <span class='ident'>ERR_BADCHANNELKEY</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 476 ERR_BADCHANMASK</span> + <span class='doccomment'>/// "<channel> :Bad Channel Mask"</span> + <span class='ident'>ERR_BADCHANMASK</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 477 ERR_NOCHANMODES</span> + <span class='doccomment'>/// "<channel> :Channel doesn't support modes"</span> + <span class='ident'>ERR_NOCHANMODES</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 478 ERR_BANLISTFULL</span> + <span class='doccomment'>/// "<channel> <char> :Channel list is full"</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_BANLISTFULL</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 481 ERR_NOPRIVILEGES</span> + <span class='doccomment'>/// ":Permission Denied- You're not an IRC operator"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Any command requiring operator privileges to operate</span> + <span class='doccomment'>/// MUST return this error to indicate the attempt was</span> + <span class='doccomment'>/// unsuccessful.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_NOPRIVILEGES</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 482 ERR_CHANOPRIVSNEEDED</span> + <span class='doccomment'>/// "<channel> :You're not channel operator"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Any command requiring 'chanop' privileges (such as</span> + <span class='doccomment'>/// MODE messages) MUST return this error if the client</span> + <span class='doccomment'>/// making the attempt is not a chanop on the specified</span> + <span class='doccomment'>/// channel.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_CHANOPRIVSNEEDED</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 483 ERR_CANTKILLSERVER</span> + <span class='doccomment'>/// ":You can't kill a server!"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Any attempts to use the KILL command on a server</span> + <span class='doccomment'>/// are to be refused and this error returned directly</span> + <span class='doccomment'>/// to the client.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_CANTKILLSERVER</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 484 ERR_RESTRICTED</span> + <span class='doccomment'>/// ":Your connection is restricted!"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Sent by the server to a user upon connection to indicate</span> + <span class='doccomment'>/// the restricted nature of the connection (user mode "+r").</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_RESTRICTED</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 485 ERR_UNIQOPPRIVSNEEDED</span> + <span class='doccomment'>/// ":You're not the original channel operator"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Any MODE requiring "channel creator" privileges MUST</span> + <span class='doccomment'>/// return this error if the client making the attempt is not</span> + <span class='doccomment'>/// a chanop on the specified channel.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_UNIQOPPRIVSNEEDED</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 491 ERR_NOOPERHOST</span> + <span class='doccomment'>/// ":No O-lines for your host"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - If a client sends an OPER message and the server has</span> + <span class='doccomment'>/// not been configured to allow connections from the</span> + <span class='doccomment'>/// client's host as an operator, this error MUST be</span> + <span class='doccomment'>/// returned.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_NOOPERHOST</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 501 ERR_UMODEUNKNOWNFLAG</span> + <span class='doccomment'>/// ":Unknown MODE flag"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Returned by the server to indicate that a MODE</span> + <span class='doccomment'>/// message was sent with a nickname parameter and that</span> + <span class='doccomment'>/// the a mode flag sent was not recognized.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_UMODEUNKNOWNFLAG</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + + <span class='doccomment'>/// 502 ERR_USERSDONTMATCH</span> + <span class='doccomment'>/// ":Cannot change mode for other users"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// - Error sent to any user trying to view or change the</span> + <span class='doccomment'>/// user mode for a user other than themselves.</span> + <span class='doccomment'>///</span> + <span class='ident'>ERR_USERSDONTMATCH</span>(<span class='ident'>CS</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>), + +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>Reply</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>from_message</span>(<span class='ident'>msg</span>: <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>Message</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Reply</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span> { + <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>Reply</span>::<span class='op'>*</span>; + <span class='kw'>match</span> <span class='ident'>msg</span>.<span class='ident'>command</span>() { + <span class='string'>"001"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_WELCOME</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"002"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_YOURHOST</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"003"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_CREATED</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"004"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_MYINFO</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"005"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_BOUNCE</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"302"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_USERHOST</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"303"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_ISON</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"301"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_AWAY</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"305"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_UNAWAY</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"306"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_NOWAWAY</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"311"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_WHOISUSER</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"312"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_WHOISSERVER</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"313"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_WHOISOPERATOR</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"317"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_WHOISIDLE</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"318"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_ENDOFWHOIS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"319"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_WHOISCHANNELS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"314"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_WHOWASUSER</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"369"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_ENDOFWHOWAS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"321"</span> <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>RPL_LISTSTART</span>), + <span class='string'>"322"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_LIST</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"323"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_LISTEND</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"325"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_UNIQOPIS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"324"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_CHANNELMODEIS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"331"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_NOTOPIC</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"332"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_TOPIC</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"341"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_INVITING</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"342"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_SUMMONING</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"346"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_INVITELIST</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"347"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_ENDOFINVITELIST</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"348"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_EXCEPTLIST</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"349"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_ENDOFEXCEPTLIST</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"351"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_VERSION</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"352"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_WHOREPLY</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"315"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_ENDOFWHO</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"353"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_NAMREPLY</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"366"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_ENDOFNAMES</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"364"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_LINKS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"365"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_ENDOFLINKS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"367"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_BANLIST</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"368"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_ENDOFBANLIST</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"371"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_INFO</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"374"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_ENDOFINFO</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"375"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_MOTDSTART</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"372"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_MOTD</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"376"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_ENDOFMOTD</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"381"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_YOUREOPER</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"382"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_REHASHING</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"383"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_YOURESERVICE</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"391"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_TIME</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"392"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_USERSSTART</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"393"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_USERS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"394"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_ENDOFUSERS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"395"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_NOUSERS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"200"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_TRACELINK</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"201"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_TRACECONNECTING</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"202"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_TRACEHANDSHAKE</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"203"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_TRACEUNKNOWN</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"204"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_TRACEOPERATOR</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"205"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_TRACEUSER</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"206"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_TRACESERVER</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"207"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_TRACESERVICE</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"208"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_TRACENEWTYPE</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"209"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_TRACECLASS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"210"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_TRACERECONNECT</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"261"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_TRACELOG</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"262"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_TRACEEND</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"211"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_STATSLINKINFO</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"212"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_STATSCOMMANDS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"219"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_ENDOFSTATS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"242"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_STATSUPTIME</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"243"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_STATSOLINE</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"221"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_UMODEIS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"234"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_SERVLIST</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"235"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_SERVLISTEND</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"251"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_LUSERCLIENT</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"252"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_LUSEROP</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"253"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_LUSERUNKNOWN</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"254"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_LUSERCHANNELS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"255"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_LUSERME</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"256"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_ADMINME</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"257"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_ADMINLOC1</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"258"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_ADMINLOC2</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"259"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_ADMINEMAIL</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"263"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>RPL_TRYAGAIN</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"401"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NOSUCHNICK</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"402"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NOSUCHSERVER</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"403"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NOSUCHCHANNEL</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"404"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_CANNOTSENDTOCHAN</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"405"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_TOOMANYCHANNELS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"406"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_WASNOSUCHNICK</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"407"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_TOOMANYTARGETS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"408"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NOSUCHSERVICE</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"409"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NOORIGIN</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"411"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NORECIPIENT</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"412"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NOTEXTTOSEND</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"413"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NOTOPLEVEL</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"414"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_WILDTOPLEVEL</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"415"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_BADMASK</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"421"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_UNKNOWNCOMMAND</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"422"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NOMOTD</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"423"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NOADMININFO</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"424"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_FILEERROR</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"431"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NONICKNAMEGIVEN</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"432"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_ERRONEUSNICKNAME</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"433"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NICKNAMEINUSE</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"436"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NICKCOLLISION</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"437"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_UNAVAILRESOURCE</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"441"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_USERNOTINCHANNEL</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"442"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NOTONCHANNEL</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"443"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_USERONCHANNEL</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"444"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NOLOGIN</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"445"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_SUMMONDISABLED</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"446"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_USERSDISABLED</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"451"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NOTREGISTERED</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"461"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NEEDMOREPARAMS</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"462"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_ALREADYREGISTRED</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"463"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NOPERMFORHOST</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"464"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_PASSWDMISMATCH</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"465"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_YOUREBANNEDCREEP</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"466"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_YOUWILLBEBANNED</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"467"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_KEYSET</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"471"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_CHANNELISFULL</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"472"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_UNKNOWNMODE</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"473"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_INVITEONLYCHAN</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"474"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_BANNEDFROMCHAN</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"475"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_BADCHANNELKEY</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"476"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_BADCHANMASK</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"477"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NOCHANMODES</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"478"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_BANLISTFULL</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"481"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NOPRIVILEGES</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"482"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_CHANOPRIVSNEEDED</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"483"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_CANTKILLSERVER</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"484"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_RESTRICTED</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"485"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_UNIQOPPRIVSNEEDED</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"491"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_NOOPERHOST</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"501"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_UMODEUNKNOWNFLAG</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + <span class='string'>"502"</span> <span class='op'>=></span> <span class='ident'>msg</span>.<span class='ident'>elements</span>().<span class='ident'>last</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>ERR_USERSDONTMATCH</span>(<span class='ident'>Borrowed</span>(<span class='ident'>e</span>))), + _ <span class='op'>=></span> <span class='prelude-val'>None</span> + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>to_message</span>(<span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Message</span> { + <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>Reply</span>::<span class='op'>*</span>; + <span class='kw'>match</span> <span class='self'>self</span> { + <span class='kw-2'>&</span><span class='ident'>RPL_WELCOME</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"001"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_YOURHOST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"002"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_CREATED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"003"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_MYINFO</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"004"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_BOUNCE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"005"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_USERHOST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"302"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_ISON</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"303"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_AWAY</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"301"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_UNAWAY</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"305"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_NOWAWAY</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"306"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_WHOISUSER</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"311"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_WHOISSERVER</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"312"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_WHOISOPERATOR</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"313"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_WHOISIDLE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"317"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFWHOIS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"318"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_WHOISCHANNELS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"319"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_WHOWASUSER</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"314"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFWHOWAS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"369"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_LISTSTART</span> <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"321"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>None</span>, <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_LIST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"322"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_LISTEND</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"323"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_UNIQOPIS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"325"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_CHANNELMODEIS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"324"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_NOTOPIC</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"331"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_TOPIC</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"332"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_INVITING</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"341"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_SUMMONING</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"342"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_INVITELIST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"346"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFINVITELIST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"347"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_EXCEPTLIST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"348"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFEXCEPTLIST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"349"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_VERSION</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"351"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_WHOREPLY</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"352"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFWHO</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"315"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_NAMREPLY</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"353"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFNAMES</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"366"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_LINKS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"364"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFLINKS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"365"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_BANLIST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"367"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFBANLIST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"368"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_INFO</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"371"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFINFO</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"374"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_MOTDSTART</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"375"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_MOTD</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"372"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFMOTD</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"376"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_YOUREOPER</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"381"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_REHASHING</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"382"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_YOURESERVICE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"383"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_TIME</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"391"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_USERSSTART</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"392"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_USERS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"393"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFUSERS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"394"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_NOUSERS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"395"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACELINK</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"200"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACECONNECTING</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"201"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACEHANDSHAKE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"202"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACEUNKNOWN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"203"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACEOPERATOR</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"204"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACEUSER</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"205"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACESERVER</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"206"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACESERVICE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"207"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACENEWTYPE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"208"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACECLASS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"209"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACERECONNECT</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"210"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACELOG</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"261"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACEEND</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"262"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_STATSLINKINFO</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"211"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_STATSCOMMANDS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"212"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFSTATS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"219"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_STATSUPTIME</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"242"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_STATSOLINE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"243"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_UMODEIS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"221"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_SERVLIST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"234"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_SERVLISTEND</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"235"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_LUSERCLIENT</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"251"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_LUSEROP</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"252"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_LUSERUNKNOWN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"253"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_LUSERCHANNELS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"254"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_LUSERME</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"255"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_ADMINME</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"256"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_ADMINLOC1</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"257"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_ADMINLOC2</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"258"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_ADMINEMAIL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"259"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>RPL_TRYAGAIN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"263"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NOSUCHNICK</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"401"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NOSUCHSERVER</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"402"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NOSUCHCHANNEL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"403"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_CANNOTSENDTOCHAN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"404"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_TOOMANYCHANNELS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"405"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_WASNOSUCHNICK</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"406"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_TOOMANYTARGETS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"407"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NOSUCHSERVICE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"408"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NOORIGIN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"409"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NORECIPIENT</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"411"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NOTEXTTOSEND</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"412"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NOTOPLEVEL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"413"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_WILDTOPLEVEL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"414"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_BADMASK</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"415"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_UNKNOWNCOMMAND</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"421"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NOMOTD</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"422"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NOADMININFO</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"423"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_FILEERROR</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"424"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NONICKNAMEGIVEN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"431"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_ERRONEUSNICKNAME</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"432"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NICKNAMEINUSE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"433"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NICKCOLLISION</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"436"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_UNAVAILRESOURCE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"437"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_USERNOTINCHANNEL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"441"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NOTONCHANNEL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"442"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_USERONCHANNEL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"443"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NOLOGIN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"444"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_SUMMONDISABLED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"445"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_USERSDISABLED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"446"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NOTREGISTERED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"451"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NEEDMOREPARAMS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"461"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_ALREADYREGISTRED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"462"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NOPERMFORHOST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"463"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_PASSWDMISMATCH</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"464"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_YOUREBANNEDCREEP</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"465"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_YOUWILLBEBANNED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"466"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_KEYSET</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"467"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_CHANNELISFULL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"471"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_UNKNOWNMODE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"472"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_INVITEONLYCHAN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"473"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_BANNEDFROMCHAN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"474"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_BADCHANNELKEY</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"475"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_BADCHANMASK</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"476"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NOCHANMODES</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"477"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_BANLISTFULL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"478"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NOPRIVILEGES</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"481"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_CHANOPRIVSNEEDED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"482"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_CANTKILLSERVER</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"483"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_RESTRICTED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"484"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_UNIQOPPRIVSNEEDED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"485"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_NOOPERHOST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"491"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_UMODEUNKNOWNFLAG</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"501"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + <span class='kw-2'>&</span><span class='ident'>ERR_USERSDONTMATCH</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>Message</span>::<span class='ident'>format</span>(<span class='prelude-val'>None</span>, <span class='ident'>Borrowed</span>(<span class='string'>"502"</span>), <span class='macro'>vec</span><span class='macro'>!</span>[], <span class='prelude-val'>Some</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>()), <span class='ident'>MsgType</span>::<span class='ident'>Irc</span>), + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>to_static</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Reply</span><span class='op'><</span><span class='lifetime'>'static</span><span class='op'>></span> { + <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>Reply</span>::<span class='op'>*</span>; + <span class='kw'>match</span> <span class='self'>self</span> { + <span class='kw-2'>&</span><span class='ident'>RPL_WELCOME</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_WELCOME</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_YOURHOST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_YOURHOST</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_CREATED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_CREATED</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_MYINFO</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_MYINFO</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_BOUNCE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_BOUNCE</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_USERHOST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_USERHOST</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_ISON</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_ISON</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_AWAY</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_AWAY</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_UNAWAY</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_UNAWAY</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_NOWAWAY</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_NOWAWAY</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_WHOISUSER</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_WHOISUSER</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_WHOISSERVER</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_WHOISSERVER</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_WHOISOPERATOR</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_WHOISOPERATOR</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_WHOISIDLE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_WHOISIDLE</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFWHOIS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_ENDOFWHOIS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_WHOISCHANNELS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_WHOISCHANNELS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_WHOWASUSER</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_WHOWASUSER</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFWHOWAS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_ENDOFWHOWAS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_LISTSTART</span> <span class='op'>=></span> <span class='ident'>RPL_LISTSTART</span>, + <span class='kw-2'>&</span><span class='ident'>RPL_LIST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_LIST</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_LISTEND</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_LISTEND</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_UNIQOPIS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_UNIQOPIS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_CHANNELMODEIS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_CHANNELMODEIS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_NOTOPIC</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_NOTOPIC</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_TOPIC</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_TOPIC</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_INVITING</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_INVITING</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_SUMMONING</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_SUMMONING</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_INVITELIST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_INVITELIST</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFINVITELIST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_ENDOFINVITELIST</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_EXCEPTLIST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_EXCEPTLIST</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFEXCEPTLIST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_ENDOFEXCEPTLIST</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_VERSION</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_VERSION</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_WHOREPLY</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_WHOREPLY</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFWHO</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_ENDOFWHO</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_NAMREPLY</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_NAMREPLY</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFNAMES</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_ENDOFNAMES</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_LINKS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_LINKS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFLINKS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_ENDOFLINKS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_BANLIST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_BANLIST</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFBANLIST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_ENDOFBANLIST</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_INFO</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_INFO</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFINFO</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_ENDOFINFO</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_MOTDSTART</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_MOTDSTART</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_MOTD</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_MOTD</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFMOTD</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_ENDOFMOTD</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_YOUREOPER</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_YOUREOPER</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_REHASHING</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_REHASHING</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_YOURESERVICE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_YOURESERVICE</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_TIME</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_TIME</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_USERSSTART</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_USERSSTART</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_USERS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_USERS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFUSERS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_ENDOFUSERS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_NOUSERS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_NOUSERS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACELINK</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_TRACELINK</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACECONNECTING</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_TRACECONNECTING</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACEHANDSHAKE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_TRACEHANDSHAKE</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACEUNKNOWN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_TRACEUNKNOWN</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACEOPERATOR</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_TRACEOPERATOR</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACEUSER</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_TRACEUSER</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACESERVER</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_TRACESERVER</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACESERVICE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_TRACESERVICE</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACENEWTYPE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_TRACENEWTYPE</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACECLASS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_TRACECLASS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACERECONNECT</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_TRACERECONNECT</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACELOG</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_TRACELOG</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_TRACEEND</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_TRACEEND</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_STATSLINKINFO</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_STATSLINKINFO</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_STATSCOMMANDS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_STATSCOMMANDS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_ENDOFSTATS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_ENDOFSTATS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_STATSUPTIME</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_STATSUPTIME</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_STATSOLINE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_STATSOLINE</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_UMODEIS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_UMODEIS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_SERVLIST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_SERVLIST</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_SERVLISTEND</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_SERVLISTEND</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_LUSERCLIENT</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_LUSERCLIENT</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_LUSEROP</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_LUSEROP</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_LUSERUNKNOWN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_LUSERUNKNOWN</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_LUSERCHANNELS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_LUSERCHANNELS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_LUSERME</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_LUSERME</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_ADMINME</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_ADMINME</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_ADMINLOC1</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_ADMINLOC1</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_ADMINLOC2</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_ADMINLOC2</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_ADMINEMAIL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_ADMINEMAIL</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>RPL_TRYAGAIN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>RPL_TRYAGAIN</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NOSUCHNICK</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NOSUCHNICK</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NOSUCHSERVER</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NOSUCHSERVER</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NOSUCHCHANNEL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NOSUCHCHANNEL</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_CANNOTSENDTOCHAN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_CANNOTSENDTOCHAN</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_TOOMANYCHANNELS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_TOOMANYCHANNELS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_WASNOSUCHNICK</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_WASNOSUCHNICK</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_TOOMANYTARGETS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_TOOMANYTARGETS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NOSUCHSERVICE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NOSUCHSERVICE</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NOORIGIN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NOORIGIN</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NORECIPIENT</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NORECIPIENT</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NOTEXTTOSEND</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NOTEXTTOSEND</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NOTOPLEVEL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NOTOPLEVEL</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_WILDTOPLEVEL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_WILDTOPLEVEL</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_BADMASK</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_BADMASK</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_UNKNOWNCOMMAND</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_UNKNOWNCOMMAND</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NOMOTD</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NOMOTD</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NOADMININFO</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NOADMININFO</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_FILEERROR</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_FILEERROR</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NONICKNAMEGIVEN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NONICKNAMEGIVEN</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_ERRONEUSNICKNAME</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_ERRONEUSNICKNAME</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NICKNAMEINUSE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NICKNAMEINUSE</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NICKCOLLISION</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NICKCOLLISION</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_UNAVAILRESOURCE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_UNAVAILRESOURCE</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_USERNOTINCHANNEL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_USERNOTINCHANNEL</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NOTONCHANNEL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NOTONCHANNEL</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_USERONCHANNEL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_USERONCHANNEL</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NOLOGIN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NOLOGIN</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_SUMMONDISABLED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_SUMMONDISABLED</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_USERSDISABLED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_USERSDISABLED</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NOTREGISTERED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NOTREGISTERED</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NEEDMOREPARAMS</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NEEDMOREPARAMS</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_ALREADYREGISTRED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_ALREADYREGISTRED</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NOPERMFORHOST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NOPERMFORHOST</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_PASSWDMISMATCH</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_PASSWDMISMATCH</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_YOUREBANNEDCREEP</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_YOUREBANNEDCREEP</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_YOUWILLBEBANNED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_YOUWILLBEBANNED</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_KEYSET</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_KEYSET</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_CHANNELISFULL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_CHANNELISFULL</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_UNKNOWNMODE</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_UNKNOWNMODE</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_INVITEONLYCHAN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_INVITEONLYCHAN</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_BANNEDFROMCHAN</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_BANNEDFROMCHAN</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_BADCHANNELKEY</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_BADCHANNELKEY</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_BADCHANMASK</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_BADCHANMASK</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NOCHANMODES</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NOCHANMODES</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_BANLISTFULL</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_BANLISTFULL</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NOPRIVILEGES</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NOPRIVILEGES</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_CHANOPRIVSNEEDED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_CHANOPRIVSNEEDED</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_CANTKILLSERVER</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_CANTKILLSERVER</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_RESTRICTED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_RESTRICTED</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_UNIQOPPRIVSNEEDED</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_UNIQOPPRIVSNEEDED</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_NOOPERHOST</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_NOOPERHOST</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_UMODEUNKNOWNFLAG</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_UMODEUNKNOWNFLAG</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + <span class='kw-2'>&</span><span class='ident'>ERR_USERSDONTMATCH</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>ERR_USERSDONTMATCH</span>(<span class='ident'>Cow</span>::<span class='ident'>Owned</span>(<span class='ident'>s</span>.<span class='ident'>clone</span>().<span class='ident'>into_owned</span>())), + } + + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "irsc"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/lazy_static/lib.rs.html b/src/lazy_static/lib.rs.html new file mode 100644 index 0000000..b6e5e1e --- /dev/null +++ b/src/lazy_static/lib.rs.html @@ -0,0 +1,345 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/lazy_static-0.1.11/src/lib.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>lib.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +</pre><pre class='rust '> +<span class='doccomment'>/*! +A macro for declaring lazily evaluated statics. + +Using this macro, it is possible to have `static`s that require code to be +executed at runtime in order to be initialized. +This includes anything requiring heap allocations, like vectors or hash maps, +as well as anything that requires function calls to be computed. + +# Syntax + +```ignore +lazy_static! { + [pub] static ref NAME_1: TYPE_1 = EXPR_1; + [pub] static ref NAME_2: TYPE_2 = EXPR_2; + ... + [pub] static ref NAME_N: TYPE_N = EXPR_N; +} +``` + +# Semantic + +For a given `static ref NAME: TYPE = EXPR;`, the macro generates a +unique type that implements `Deref<TYPE>` and stores it in a static with name `NAME`. + +On first deref, `EXPR` gets evaluated and stored internally, such that all further derefs +can return a reference to the same object. + +Like regular `static mut`s, this macro only works for types that fulfill the `Sync` +trait. + +# Example + +Using the macro: + +```rust +#[macro_use] +extern crate lazy_static; + +use std::collections::HashMap; + +lazy_static! { + static ref HASHMAP: HashMap<u32, &'static str> = { + let mut m = HashMap::new(); + m.insert(0, "foo"); + m.insert(1, "bar"); + m.insert(2, "baz"); + m + }; + static ref COUNT: usize = HASHMAP.len(); + static ref NUMBER: u32 = times_two(21); +} + +fn times_two(n: u32) -> u32 { n * 2 } + +fn main() { + println!("The map has {} entries.", *COUNT); + println!("The entry for `0` is \"{}\".", HASHMAP.get(&0).unwrap()); + println!("A expensive calculation on a static results in: {}.", *NUMBER); +} +``` + +# Implementation details + +The `Deref` implementation uses a hidden `static mut` that is guarded by a atomic check +using the `sync::Once` abstraction. All lazily evaluated values are currently +put in a heap allocated box, due to the Rust language currently not providing any way to +define uninitialized `static mut` values. + +*/</span> + +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>crate_type</span> <span class='op'>=</span> <span class='string'>"dylib"</span>]</span> + +<span class='attribute'>#[<span class='ident'>macro_export</span>]</span> +<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>lazy_static</span> { + (<span class='kw'>static</span> <span class='kw-2'>ref</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>N</span>:<span class='ident'>ident</span> : <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span>:<span class='ident'>ty</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>:<span class='ident'>expr</span>; $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span>:<span class='ident'>tt</span>)<span class='op'>*</span>) <span class='op'>=></span> { + <span class='macro'>lazy_static</span><span class='macro'>!</span>(<span class='ident'>PRIV</span> <span class='kw'>static</span> <span class='kw-2'>ref</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>N</span> : <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>; $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span>)<span class='op'>*</span>); + }; + (<span class='kw'>pub</span> <span class='kw'>static</span> <span class='kw-2'>ref</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>N</span>:<span class='ident'>ident</span> : <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span>:<span class='ident'>ty</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>:<span class='ident'>expr</span>; $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span>:<span class='ident'>tt</span>)<span class='op'>*</span>) <span class='op'>=></span> { + <span class='macro'>lazy_static</span><span class='macro'>!</span>(<span class='ident'>PUB</span> <span class='kw'>static</span> <span class='kw-2'>ref</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>N</span> : <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>; $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span>)<span class='op'>*</span>); + }; + (<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>VIS</span>:<span class='ident'>ident</span> <span class='kw'>static</span> <span class='kw-2'>ref</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>N</span>:<span class='ident'>ident</span> : <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span>:<span class='ident'>ty</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>:<span class='ident'>expr</span>; $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span>:<span class='ident'>tt</span>)<span class='op'>*</span>) <span class='op'>=></span> { + <span class='macro'>lazy_static</span><span class='macro'>!</span>(<span class='ident'>MAKE</span> <span class='ident'>TY</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>VIS</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>N</span>); + <span class='kw'>impl</span> ::<span class='ident'>std</span>::<span class='ident'>ops</span>::<span class='ident'>Deref</span> <span class='kw'>for</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>N</span> { + <span class='kw'>type</span> <span class='ident'>Target</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span>; + <span class='kw'>fn</span> <span class='ident'>deref</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span> { + <span class='attribute'>#[<span class='ident'>inline</span>(<span class='ident'>always</span>)]</span> + <span class='kw'>fn</span> <span class='ident'>__static_ref_initialize</span>() <span class='op'>-></span> <span class='ident'>Box</span><span class='op'><</span><span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span><span class='op'>></span> { <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>e</span>) } + + <span class='kw'>unsafe</span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>sync</span>::{<span class='ident'>Once</span>, <span class='ident'>ONCE_INIT</span>}; + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>mem</span>::<span class='ident'>transmute</span>; + + <span class='attribute'>#[<span class='ident'>inline</span>(<span class='ident'>always</span>)]</span> + <span class='kw'>fn</span> <span class='ident'>require_sync</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>Sync</span><span class='op'>></span>(_: <span class='kw-2'>&</span><span class='ident'>T</span>) { } + + <span class='kw'>static</span> <span class='kw-2'>mut</span> <span class='ident'>DATA</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span> <span class='op'>=</span> <span class='number'>0</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw'>const</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span>; + <span class='kw'>static</span> <span class='kw-2'>mut</span> <span class='ident'>ONCE</span>: <span class='ident'>Once</span> <span class='op'>=</span> <span class='ident'>ONCE_INIT</span>; + <span class='ident'>ONCE</span>.<span class='ident'>call_once</span>(<span class='op'>||</span> { + <span class='ident'>DATA</span> <span class='op'>=</span> <span class='ident'>transmute</span>::<span class='op'><</span><span class='ident'>Box</span><span class='op'><</span><span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span><span class='op'>></span>, <span class='op'>*</span><span class='kw'>const</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>T</span><span class='op'>></span>(<span class='ident'>__static_ref_initialize</span>()); + }); + <span class='kw'>let</span> <span class='ident'>static_ref</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>DATA</span>; + <span class='ident'>require_sync</span>(<span class='ident'>static_ref</span>); + <span class='ident'>static_ref</span> + } + } + } + <span class='macro'>lazy_static</span><span class='macro'>!</span>($(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>t</span>)<span class='op'>*</span>); + }; + (<span class='ident'>MAKE</span> <span class='ident'>TY</span> <span class='ident'>PUB</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>N</span>:<span class='ident'>ident</span>) <span class='op'>=></span> { + <span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>missing_copy_implementations</span>)]</span> + <span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>non_camel_case_types</span>)]</span> + <span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>dead_code</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>N</span> {<span class='ident'>__private_field</span>: ()} + <span class='kw'>pub</span> <span class='kw'>static</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>N</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>N</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>N</span> {<span class='ident'>__private_field</span>: ()}; + }; + (<span class='ident'>MAKE</span> <span class='ident'>TY</span> <span class='ident'>PRIV</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>N</span>:<span class='ident'>ident</span>) <span class='op'>=></span> { + <span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>missing_copy_implementations</span>)]</span> + <span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>non_camel_case_types</span>)]</span> + <span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>dead_code</span>)]</span> + <span class='kw'>struct</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>N</span> {<span class='ident'>__private_field</span>: ()} + <span class='kw'>static</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>N</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>N</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>N</span> {<span class='ident'>__private_field</span>: ()}; + }; + () <span class='op'>=></span> () +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "lazy_static"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/libc/lib.rs.html b/src/libc/lib.rs.html new file mode 100644 index 0000000..ac022cd --- /dev/null +++ b/src/libc/lib.rs.html @@ -0,0 +1,12869 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/libc-0.1.8/rust/src/liblibc/lib.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>lib.rs.html -- source</title> + + <link rel="stylesheet" type="text/css" href="../../main.css"> + + <link rel="shortcut icon" href="https://doc.rust-lang.org/favicon.ico"> + +</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"> + <a href='../../libc/index.html'><img src='http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png' alt='' width='100'></a> + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100"> 100</span> +<span id="101"> 101</span> +<span id="102"> 102</span> +<span id="103"> 103</span> +<span id="104"> 104</span> +<span id="105"> 105</span> +<span id="106"> 106</span> +<span id="107"> 107</span> +<span id="108"> 108</span> +<span id="109"> 109</span> +<span id="110"> 110</span> +<span id="111"> 111</span> +<span id="112"> 112</span> +<span id="113"> 113</span> +<span id="114"> 114</span> +<span id="115"> 115</span> +<span id="116"> 116</span> +<span id="117"> 117</span> +<span id="118"> 118</span> +<span id="119"> 119</span> +<span id="120"> 120</span> +<span id="121"> 121</span> +<span id="122"> 122</span> +<span id="123"> 123</span> +<span id="124"> 124</span> +<span id="125"> 125</span> +<span id="126"> 126</span> +<span id="127"> 127</span> +<span id="128"> 128</span> +<span id="129"> 129</span> +<span id="130"> 130</span> +<span id="131"> 131</span> +<span id="132"> 132</span> +<span id="133"> 133</span> +<span id="134"> 134</span> +<span id="135"> 135</span> +<span id="136"> 136</span> +<span id="137"> 137</span> +<span id="138"> 138</span> +<span id="139"> 139</span> +<span id="140"> 140</span> +<span id="141"> 141</span> +<span id="142"> 142</span> +<span id="143"> 143</span> +<span id="144"> 144</span> +<span id="145"> 145</span> +<span id="146"> 146</span> +<span id="147"> 147</span> +<span id="148"> 148</span> +<span id="149"> 149</span> +<span id="150"> 150</span> +<span id="151"> 151</span> +<span id="152"> 152</span> +<span id="153"> 153</span> +<span id="154"> 154</span> +<span id="155"> 155</span> +<span id="156"> 156</span> +<span id="157"> 157</span> +<span id="158"> 158</span> +<span id="159"> 159</span> +<span id="160"> 160</span> +<span id="161"> 161</span> +<span id="162"> 162</span> +<span id="163"> 163</span> +<span id="164"> 164</span> +<span id="165"> 165</span> +<span id="166"> 166</span> +<span id="167"> 167</span> +<span id="168"> 168</span> +<span id="169"> 169</span> +<span id="170"> 170</span> +<span id="171"> 171</span> +<span id="172"> 172</span> +<span id="173"> 173</span> +<span id="174"> 174</span> +<span id="175"> 175</span> +<span id="176"> 176</span> +<span id="177"> 177</span> +<span id="178"> 178</span> +<span id="179"> 179</span> +<span id="180"> 180</span> +<span id="181"> 181</span> +<span id="182"> 182</span> +<span id="183"> 183</span> +<span id="184"> 184</span> +<span id="185"> 185</span> +<span id="186"> 186</span> +<span id="187"> 187</span> +<span id="188"> 188</span> +<span id="189"> 189</span> +<span id="190"> 190</span> +<span id="191"> 191</span> +<span id="192"> 192</span> +<span id="193"> 193</span> +<span id="194"> 194</span> +<span id="195"> 195</span> +<span id="196"> 196</span> +<span id="197"> 197</span> +<span id="198"> 198</span> +<span id="199"> 199</span> +<span id="200"> 200</span> +<span id="201"> 201</span> +<span id="202"> 202</span> +<span id="203"> 203</span> +<span id="204"> 204</span> +<span id="205"> 205</span> +<span id="206"> 206</span> +<span id="207"> 207</span> +<span id="208"> 208</span> +<span id="209"> 209</span> +<span id="210"> 210</span> +<span id="211"> 211</span> +<span id="212"> 212</span> +<span id="213"> 213</span> +<span id="214"> 214</span> +<span id="215"> 215</span> +<span id="216"> 216</span> +<span id="217"> 217</span> +<span id="218"> 218</span> +<span id="219"> 219</span> +<span id="220"> 220</span> +<span id="221"> 221</span> +<span id="222"> 222</span> +<span id="223"> 223</span> +<span id="224"> 224</span> +<span id="225"> 225</span> +<span id="226"> 226</span> +<span id="227"> 227</span> +<span id="228"> 228</span> +<span id="229"> 229</span> +<span id="230"> 230</span> +<span id="231"> 231</span> +<span id="232"> 232</span> +<span id="233"> 233</span> +<span id="234"> 234</span> +<span id="235"> 235</span> +<span id="236"> 236</span> +<span id="237"> 237</span> +<span id="238"> 238</span> +<span id="239"> 239</span> +<span id="240"> 240</span> +<span id="241"> 241</span> +<span id="242"> 242</span> +<span id="243"> 243</span> +<span id="244"> 244</span> +<span id="245"> 245</span> +<span id="246"> 246</span> +<span id="247"> 247</span> +<span id="248"> 248</span> +<span id="249"> 249</span> +<span id="250"> 250</span> +<span id="251"> 251</span> +<span id="252"> 252</span> +<span id="253"> 253</span> +<span id="254"> 254</span> +<span id="255"> 255</span> +<span id="256"> 256</span> +<span id="257"> 257</span> +<span id="258"> 258</span> +<span id="259"> 259</span> +<span id="260"> 260</span> +<span id="261"> 261</span> +<span id="262"> 262</span> +<span id="263"> 263</span> +<span id="264"> 264</span> +<span id="265"> 265</span> +<span id="266"> 266</span> +<span id="267"> 267</span> +<span id="268"> 268</span> +<span id="269"> 269</span> +<span id="270"> 270</span> +<span id="271"> 271</span> +<span id="272"> 272</span> +<span id="273"> 273</span> +<span id="274"> 274</span> +<span id="275"> 275</span> +<span id="276"> 276</span> +<span id="277"> 277</span> +<span id="278"> 278</span> +<span id="279"> 279</span> +<span id="280"> 280</span> +<span id="281"> 281</span> +<span id="282"> 282</span> +<span id="283"> 283</span> +<span id="284"> 284</span> +<span id="285"> 285</span> +<span id="286"> 286</span> +<span id="287"> 287</span> +<span id="288"> 288</span> +<span id="289"> 289</span> +<span id="290"> 290</span> +<span id="291"> 291</span> +<span id="292"> 292</span> +<span id="293"> 293</span> +<span id="294"> 294</span> +<span id="295"> 295</span> +<span id="296"> 296</span> +<span id="297"> 297</span> +<span id="298"> 298</span> +<span id="299"> 299</span> +<span id="300"> 300</span> +<span id="301"> 301</span> +<span id="302"> 302</span> +<span id="303"> 303</span> +<span id="304"> 304</span> +<span id="305"> 305</span> +<span id="306"> 306</span> +<span id="307"> 307</span> +<span id="308"> 308</span> +<span id="309"> 309</span> +<span id="310"> 310</span> +<span id="311"> 311</span> +<span id="312"> 312</span> +<span id="313"> 313</span> +<span id="314"> 314</span> +<span id="315"> 315</span> +<span id="316"> 316</span> +<span id="317"> 317</span> +<span id="318"> 318</span> +<span id="319"> 319</span> +<span id="320"> 320</span> +<span id="321"> 321</span> +<span id="322"> 322</span> +<span id="323"> 323</span> +<span id="324"> 324</span> +<span id="325"> 325</span> +<span id="326"> 326</span> +<span id="327"> 327</span> +<span id="328"> 328</span> +<span id="329"> 329</span> +<span id="330"> 330</span> +<span id="331"> 331</span> +<span id="332"> 332</span> +<span id="333"> 333</span> +<span id="334"> 334</span> +<span id="335"> 335</span> +<span id="336"> 336</span> +<span id="337"> 337</span> +<span id="338"> 338</span> +<span id="339"> 339</span> +<span id="340"> 340</span> +<span id="341"> 341</span> +<span id="342"> 342</span> +<span id="343"> 343</span> +<span id="344"> 344</span> +<span id="345"> 345</span> +<span id="346"> 346</span> +<span id="347"> 347</span> +<span id="348"> 348</span> +<span id="349"> 349</span> +<span id="350"> 350</span> +<span id="351"> 351</span> +<span id="352"> 352</span> +<span id="353"> 353</span> +<span id="354"> 354</span> +<span id="355"> 355</span> +<span id="356"> 356</span> +<span id="357"> 357</span> +<span id="358"> 358</span> +<span id="359"> 359</span> +<span id="360"> 360</span> +<span id="361"> 361</span> +<span id="362"> 362</span> +<span id="363"> 363</span> +<span id="364"> 364</span> +<span id="365"> 365</span> +<span id="366"> 366</span> +<span id="367"> 367</span> +<span id="368"> 368</span> +<span id="369"> 369</span> +<span id="370"> 370</span> +<span id="371"> 371</span> +<span id="372"> 372</span> +<span id="373"> 373</span> +<span id="374"> 374</span> +<span id="375"> 375</span> +<span id="376"> 376</span> +<span id="377"> 377</span> +<span id="378"> 378</span> +<span id="379"> 379</span> +<span id="380"> 380</span> +<span id="381"> 381</span> +<span id="382"> 382</span> +<span id="383"> 383</span> +<span id="384"> 384</span> +<span id="385"> 385</span> +<span id="386"> 386</span> +<span id="387"> 387</span> +<span id="388"> 388</span> +<span id="389"> 389</span> +<span id="390"> 390</span> +<span id="391"> 391</span> +<span id="392"> 392</span> +<span id="393"> 393</span> +<span id="394"> 394</span> +<span id="395"> 395</span> +<span id="396"> 396</span> +<span id="397"> 397</span> +<span id="398"> 398</span> +<span id="399"> 399</span> +<span id="400"> 400</span> +<span id="401"> 401</span> +<span id="402"> 402</span> +<span id="403"> 403</span> +<span id="404"> 404</span> +<span id="405"> 405</span> +<span id="406"> 406</span> +<span id="407"> 407</span> +<span id="408"> 408</span> +<span id="409"> 409</span> +<span id="410"> 410</span> +<span id="411"> 411</span> +<span id="412"> 412</span> +<span id="413"> 413</span> +<span id="414"> 414</span> +<span id="415"> 415</span> +<span id="416"> 416</span> +<span id="417"> 417</span> +<span id="418"> 418</span> +<span id="419"> 419</span> +<span id="420"> 420</span> +<span id="421"> 421</span> +<span id="422"> 422</span> +<span id="423"> 423</span> +<span id="424"> 424</span> +<span id="425"> 425</span> +<span id="426"> 426</span> +<span id="427"> 427</span> +<span id="428"> 428</span> +<span id="429"> 429</span> +<span id="430"> 430</span> +<span id="431"> 431</span> +<span id="432"> 432</span> +<span id="433"> 433</span> +<span id="434"> 434</span> +<span id="435"> 435</span> +<span id="436"> 436</span> +<span id="437"> 437</span> +<span id="438"> 438</span> +<span id="439"> 439</span> +<span id="440"> 440</span> +<span id="441"> 441</span> +<span id="442"> 442</span> +<span id="443"> 443</span> +<span id="444"> 444</span> +<span id="445"> 445</span> +<span id="446"> 446</span> +<span id="447"> 447</span> +<span id="448"> 448</span> +<span id="449"> 449</span> +<span id="450"> 450</span> +<span id="451"> 451</span> +<span id="452"> 452</span> +<span id="453"> 453</span> +<span id="454"> 454</span> +<span id="455"> 455</span> +<span id="456"> 456</span> +<span id="457"> 457</span> +<span id="458"> 458</span> +<span id="459"> 459</span> +<span id="460"> 460</span> +<span id="461"> 461</span> +<span id="462"> 462</span> +<span id="463"> 463</span> +<span id="464"> 464</span> +<span id="465"> 465</span> +<span id="466"> 466</span> +<span id="467"> 467</span> +<span id="468"> 468</span> +<span id="469"> 469</span> +<span id="470"> 470</span> +<span id="471"> 471</span> +<span id="472"> 472</span> +<span id="473"> 473</span> +<span id="474"> 474</span> +<span id="475"> 475</span> +<span id="476"> 476</span> +<span id="477"> 477</span> +<span id="478"> 478</span> +<span id="479"> 479</span> +<span id="480"> 480</span> +<span id="481"> 481</span> +<span id="482"> 482</span> +<span id="483"> 483</span> +<span id="484"> 484</span> +<span id="485"> 485</span> +<span id="486"> 486</span> +<span id="487"> 487</span> +<span id="488"> 488</span> +<span id="489"> 489</span> +<span id="490"> 490</span> +<span id="491"> 491</span> +<span id="492"> 492</span> +<span id="493"> 493</span> +<span id="494"> 494</span> +<span id="495"> 495</span> +<span id="496"> 496</span> +<span id="497"> 497</span> +<span id="498"> 498</span> +<span id="499"> 499</span> +<span id="500"> 500</span> +<span id="501"> 501</span> +<span id="502"> 502</span> +<span id="503"> 503</span> +<span id="504"> 504</span> +<span id="505"> 505</span> +<span id="506"> 506</span> +<span id="507"> 507</span> +<span id="508"> 508</span> +<span id="509"> 509</span> +<span id="510"> 510</span> +<span id="511"> 511</span> +<span id="512"> 512</span> +<span id="513"> 513</span> +<span id="514"> 514</span> +<span id="515"> 515</span> +<span id="516"> 516</span> +<span id="517"> 517</span> +<span id="518"> 518</span> +<span id="519"> 519</span> +<span id="520"> 520</span> +<span id="521"> 521</span> +<span id="522"> 522</span> +<span id="523"> 523</span> +<span id="524"> 524</span> +<span id="525"> 525</span> +<span id="526"> 526</span> +<span id="527"> 527</span> +<span id="528"> 528</span> +<span id="529"> 529</span> +<span id="530"> 530</span> +<span id="531"> 531</span> +<span id="532"> 532</span> +<span id="533"> 533</span> +<span id="534"> 534</span> +<span id="535"> 535</span> +<span id="536"> 536</span> +<span id="537"> 537</span> +<span id="538"> 538</span> +<span id="539"> 539</span> +<span id="540"> 540</span> +<span id="541"> 541</span> +<span id="542"> 542</span> +<span id="543"> 543</span> +<span id="544"> 544</span> +<span id="545"> 545</span> +<span id="546"> 546</span> +<span id="547"> 547</span> +<span id="548"> 548</span> +<span id="549"> 549</span> +<span id="550"> 550</span> +<span id="551"> 551</span> +<span id="552"> 552</span> +<span id="553"> 553</span> +<span id="554"> 554</span> +<span id="555"> 555</span> +<span id="556"> 556</span> +<span id="557"> 557</span> +<span id="558"> 558</span> +<span id="559"> 559</span> +<span id="560"> 560</span> +<span id="561"> 561</span> +<span id="562"> 562</span> +<span id="563"> 563</span> +<span id="564"> 564</span> +<span id="565"> 565</span> +<span id="566"> 566</span> +<span id="567"> 567</span> +<span id="568"> 568</span> +<span id="569"> 569</span> +<span id="570"> 570</span> +<span id="571"> 571</span> +<span id="572"> 572</span> +<span id="573"> 573</span> +<span id="574"> 574</span> +<span id="575"> 575</span> +<span id="576"> 576</span> +<span id="577"> 577</span> +<span id="578"> 578</span> +<span id="579"> 579</span> +<span id="580"> 580</span> +<span id="581"> 581</span> +<span id="582"> 582</span> +<span id="583"> 583</span> +<span id="584"> 584</span> +<span id="585"> 585</span> +<span id="586"> 586</span> +<span id="587"> 587</span> +<span id="588"> 588</span> +<span id="589"> 589</span> +<span id="590"> 590</span> +<span id="591"> 591</span> +<span id="592"> 592</span> +<span id="593"> 593</span> +<span id="594"> 594</span> +<span id="595"> 595</span> +<span id="596"> 596</span> +<span id="597"> 597</span> +<span id="598"> 598</span> +<span id="599"> 599</span> +<span id="600"> 600</span> +<span id="601"> 601</span> +<span id="602"> 602</span> +<span id="603"> 603</span> +<span id="604"> 604</span> +<span id="605"> 605</span> +<span id="606"> 606</span> +<span id="607"> 607</span> +<span id="608"> 608</span> +<span id="609"> 609</span> +<span id="610"> 610</span> +<span id="611"> 611</span> +<span id="612"> 612</span> +<span id="613"> 613</span> +<span id="614"> 614</span> +<span id="615"> 615</span> +<span id="616"> 616</span> +<span id="617"> 617</span> +<span id="618"> 618</span> +<span id="619"> 619</span> +<span id="620"> 620</span> +<span id="621"> 621</span> +<span id="622"> 622</span> +<span id="623"> 623</span> +<span id="624"> 624</span> +<span id="625"> 625</span> +<span id="626"> 626</span> +<span id="627"> 627</span> +<span id="628"> 628</span> +<span id="629"> 629</span> +<span id="630"> 630</span> +<span id="631"> 631</span> +<span id="632"> 632</span> +<span id="633"> 633</span> +<span id="634"> 634</span> +<span id="635"> 635</span> +<span id="636"> 636</span> +<span id="637"> 637</span> +<span id="638"> 638</span> +<span id="639"> 639</span> +<span id="640"> 640</span> +<span id="641"> 641</span> +<span id="642"> 642</span> +<span id="643"> 643</span> +<span id="644"> 644</span> +<span id="645"> 645</span> +<span id="646"> 646</span> +<span id="647"> 647</span> +<span id="648"> 648</span> +<span id="649"> 649</span> +<span id="650"> 650</span> +<span id="651"> 651</span> +<span id="652"> 652</span> +<span id="653"> 653</span> +<span id="654"> 654</span> +<span id="655"> 655</span> +<span id="656"> 656</span> +<span id="657"> 657</span> +<span id="658"> 658</span> +<span id="659"> 659</span> +<span id="660"> 660</span> +<span id="661"> 661</span> +<span id="662"> 662</span> +<span id="663"> 663</span> +<span id="664"> 664</span> +<span id="665"> 665</span> +<span id="666"> 666</span> +<span id="667"> 667</span> +<span id="668"> 668</span> +<span id="669"> 669</span> +<span id="670"> 670</span> +<span id="671"> 671</span> +<span id="672"> 672</span> +<span id="673"> 673</span> +<span id="674"> 674</span> +<span id="675"> 675</span> +<span id="676"> 676</span> +<span id="677"> 677</span> +<span id="678"> 678</span> +<span id="679"> 679</span> +<span id="680"> 680</span> +<span id="681"> 681</span> +<span id="682"> 682</span> +<span id="683"> 683</span> +<span id="684"> 684</span> +<span id="685"> 685</span> +<span id="686"> 686</span> +<span id="687"> 687</span> +<span id="688"> 688</span> +<span id="689"> 689</span> +<span id="690"> 690</span> +<span id="691"> 691</span> +<span id="692"> 692</span> +<span id="693"> 693</span> +<span id="694"> 694</span> +<span id="695"> 695</span> +<span id="696"> 696</span> +<span id="697"> 697</span> +<span id="698"> 698</span> +<span id="699"> 699</span> +<span id="700"> 700</span> +<span id="701"> 701</span> +<span id="702"> 702</span> +<span id="703"> 703</span> +<span id="704"> 704</span> +<span id="705"> 705</span> +<span id="706"> 706</span> +<span id="707"> 707</span> +<span id="708"> 708</span> +<span id="709"> 709</span> +<span id="710"> 710</span> +<span id="711"> 711</span> +<span id="712"> 712</span> +<span id="713"> 713</span> +<span id="714"> 714</span> +<span id="715"> 715</span> +<span id="716"> 716</span> +<span id="717"> 717</span> +<span id="718"> 718</span> +<span id="719"> 719</span> +<span id="720"> 720</span> +<span id="721"> 721</span> +<span id="722"> 722</span> +<span id="723"> 723</span> +<span id="724"> 724</span> +<span id="725"> 725</span> +<span id="726"> 726</span> +<span id="727"> 727</span> +<span id="728"> 728</span> +<span id="729"> 729</span> +<span id="730"> 730</span> +<span id="731"> 731</span> +<span id="732"> 732</span> +<span id="733"> 733</span> +<span id="734"> 734</span> +<span id="735"> 735</span> +<span id="736"> 736</span> +<span id="737"> 737</span> +<span id="738"> 738</span> +<span id="739"> 739</span> +<span id="740"> 740</span> +<span id="741"> 741</span> +<span id="742"> 742</span> +<span id="743"> 743</span> +<span id="744"> 744</span> +<span id="745"> 745</span> +<span id="746"> 746</span> +<span id="747"> 747</span> +<span id="748"> 748</span> +<span id="749"> 749</span> +<span id="750"> 750</span> +<span id="751"> 751</span> +<span id="752"> 752</span> +<span id="753"> 753</span> +<span id="754"> 754</span> +<span id="755"> 755</span> +<span id="756"> 756</span> +<span id="757"> 757</span> +<span id="758"> 758</span> +<span id="759"> 759</span> +<span id="760"> 760</span> +<span id="761"> 761</span> +<span id="762"> 762</span> +<span id="763"> 763</span> +<span id="764"> 764</span> +<span id="765"> 765</span> +<span id="766"> 766</span> +<span id="767"> 767</span> +<span id="768"> 768</span> +<span id="769"> 769</span> +<span id="770"> 770</span> +<span id="771"> 771</span> +<span id="772"> 772</span> +<span id="773"> 773</span> +<span id="774"> 774</span> +<span id="775"> 775</span> +<span id="776"> 776</span> +<span id="777"> 777</span> +<span id="778"> 778</span> +<span id="779"> 779</span> +<span id="780"> 780</span> +<span id="781"> 781</span> +<span id="782"> 782</span> +<span id="783"> 783</span> +<span id="784"> 784</span> +<span id="785"> 785</span> +<span id="786"> 786</span> +<span id="787"> 787</span> +<span id="788"> 788</span> +<span id="789"> 789</span> +<span id="790"> 790</span> +<span id="791"> 791</span> +<span id="792"> 792</span> +<span id="793"> 793</span> +<span id="794"> 794</span> +<span id="795"> 795</span> +<span id="796"> 796</span> +<span id="797"> 797</span> +<span id="798"> 798</span> +<span id="799"> 799</span> +<span id="800"> 800</span> +<span id="801"> 801</span> +<span id="802"> 802</span> +<span id="803"> 803</span> +<span id="804"> 804</span> +<span id="805"> 805</span> +<span id="806"> 806</span> +<span id="807"> 807</span> +<span id="808"> 808</span> +<span id="809"> 809</span> +<span id="810"> 810</span> +<span id="811"> 811</span> +<span id="812"> 812</span> +<span id="813"> 813</span> +<span id="814"> 814</span> +<span id="815"> 815</span> +<span id="816"> 816</span> +<span id="817"> 817</span> +<span id="818"> 818</span> +<span id="819"> 819</span> +<span id="820"> 820</span> +<span id="821"> 821</span> +<span id="822"> 822</span> +<span id="823"> 823</span> +<span id="824"> 824</span> +<span id="825"> 825</span> +<span id="826"> 826</span> +<span id="827"> 827</span> +<span id="828"> 828</span> +<span id="829"> 829</span> +<span id="830"> 830</span> +<span id="831"> 831</span> +<span id="832"> 832</span> +<span id="833"> 833</span> +<span id="834"> 834</span> +<span id="835"> 835</span> +<span id="836"> 836</span> +<span id="837"> 837</span> +<span id="838"> 838</span> +<span id="839"> 839</span> +<span id="840"> 840</span> +<span id="841"> 841</span> +<span id="842"> 842</span> +<span id="843"> 843</span> +<span id="844"> 844</span> +<span id="845"> 845</span> +<span id="846"> 846</span> +<span id="847"> 847</span> +<span id="848"> 848</span> +<span id="849"> 849</span> +<span id="850"> 850</span> +<span id="851"> 851</span> +<span id="852"> 852</span> +<span id="853"> 853</span> +<span id="854"> 854</span> +<span id="855"> 855</span> +<span id="856"> 856</span> +<span id="857"> 857</span> +<span id="858"> 858</span> +<span id="859"> 859</span> +<span id="860"> 860</span> +<span id="861"> 861</span> +<span id="862"> 862</span> +<span id="863"> 863</span> +<span id="864"> 864</span> +<span id="865"> 865</span> +<span id="866"> 866</span> +<span id="867"> 867</span> +<span id="868"> 868</span> +<span id="869"> 869</span> +<span id="870"> 870</span> +<span id="871"> 871</span> +<span id="872"> 872</span> +<span id="873"> 873</span> +<span id="874"> 874</span> +<span id="875"> 875</span> +<span id="876"> 876</span> +<span id="877"> 877</span> +<span id="878"> 878</span> +<span id="879"> 879</span> +<span id="880"> 880</span> +<span id="881"> 881</span> +<span id="882"> 882</span> +<span id="883"> 883</span> +<span id="884"> 884</span> +<span id="885"> 885</span> +<span id="886"> 886</span> +<span id="887"> 887</span> +<span id="888"> 888</span> +<span id="889"> 889</span> +<span id="890"> 890</span> +<span id="891"> 891</span> +<span id="892"> 892</span> +<span id="893"> 893</span> +<span id="894"> 894</span> +<span id="895"> 895</span> +<span id="896"> 896</span> +<span id="897"> 897</span> +<span id="898"> 898</span> +<span id="899"> 899</span> +<span id="900"> 900</span> +<span id="901"> 901</span> +<span id="902"> 902</span> +<span id="903"> 903</span> +<span id="904"> 904</span> +<span id="905"> 905</span> +<span id="906"> 906</span> +<span id="907"> 907</span> +<span id="908"> 908</span> +<span id="909"> 909</span> +<span id="910"> 910</span> +<span id="911"> 911</span> +<span id="912"> 912</span> +<span id="913"> 913</span> +<span id="914"> 914</span> +<span id="915"> 915</span> +<span id="916"> 916</span> +<span id="917"> 917</span> +<span id="918"> 918</span> +<span id="919"> 919</span> +<span id="920"> 920</span> +<span id="921"> 921</span> +<span id="922"> 922</span> +<span id="923"> 923</span> +<span id="924"> 924</span> +<span id="925"> 925</span> +<span id="926"> 926</span> +<span id="927"> 927</span> +<span id="928"> 928</span> +<span id="929"> 929</span> +<span id="930"> 930</span> +<span id="931"> 931</span> +<span id="932"> 932</span> +<span id="933"> 933</span> +<span id="934"> 934</span> +<span id="935"> 935</span> +<span id="936"> 936</span> +<span id="937"> 937</span> +<span id="938"> 938</span> +<span id="939"> 939</span> +<span id="940"> 940</span> +<span id="941"> 941</span> +<span id="942"> 942</span> +<span id="943"> 943</span> +<span id="944"> 944</span> +<span id="945"> 945</span> +<span id="946"> 946</span> +<span id="947"> 947</span> +<span id="948"> 948</span> +<span id="949"> 949</span> +<span id="950"> 950</span> +<span id="951"> 951</span> +<span id="952"> 952</span> +<span id="953"> 953</span> +<span id="954"> 954</span> +<span id="955"> 955</span> +<span id="956"> 956</span> +<span id="957"> 957</span> +<span id="958"> 958</span> +<span id="959"> 959</span> +<span id="960"> 960</span> +<span id="961"> 961</span> +<span id="962"> 962</span> +<span id="963"> 963</span> +<span id="964"> 964</span> +<span id="965"> 965</span> +<span id="966"> 966</span> +<span id="967"> 967</span> +<span id="968"> 968</span> +<span id="969"> 969</span> +<span id="970"> 970</span> +<span id="971"> 971</span> +<span id="972"> 972</span> +<span id="973"> 973</span> +<span id="974"> 974</span> +<span id="975"> 975</span> +<span id="976"> 976</span> +<span id="977"> 977</span> +<span id="978"> 978</span> +<span id="979"> 979</span> +<span id="980"> 980</span> +<span id="981"> 981</span> +<span id="982"> 982</span> +<span id="983"> 983</span> +<span id="984"> 984</span> +<span id="985"> 985</span> +<span id="986"> 986</span> +<span id="987"> 987</span> +<span id="988"> 988</span> +<span id="989"> 989</span> +<span id="990"> 990</span> +<span id="991"> 991</span> +<span id="992"> 992</span> +<span id="993"> 993</span> +<span id="994"> 994</span> +<span id="995"> 995</span> +<span id="996"> 996</span> +<span id="997"> 997</span> +<span id="998"> 998</span> +<span id="999"> 999</span> +<span id="1000">1000</span> +<span id="1001">1001</span> +<span id="1002">1002</span> +<span id="1003">1003</span> +<span id="1004">1004</span> +<span id="1005">1005</span> +<span id="1006">1006</span> +<span id="1007">1007</span> +<span id="1008">1008</span> +<span id="1009">1009</span> +<span id="1010">1010</span> +<span id="1011">1011</span> +<span id="1012">1012</span> +<span id="1013">1013</span> +<span id="1014">1014</span> +<span id="1015">1015</span> +<span id="1016">1016</span> +<span id="1017">1017</span> +<span id="1018">1018</span> +<span id="1019">1019</span> +<span id="1020">1020</span> +<span id="1021">1021</span> +<span id="1022">1022</span> +<span id="1023">1023</span> +<span id="1024">1024</span> +<span id="1025">1025</span> +<span id="1026">1026</span> +<span id="1027">1027</span> +<span id="1028">1028</span> +<span id="1029">1029</span> +<span id="1030">1030</span> +<span id="1031">1031</span> +<span id="1032">1032</span> +<span id="1033">1033</span> +<span id="1034">1034</span> +<span id="1035">1035</span> +<span id="1036">1036</span> +<span id="1037">1037</span> +<span id="1038">1038</span> +<span id="1039">1039</span> +<span id="1040">1040</span> +<span id="1041">1041</span> +<span id="1042">1042</span> +<span id="1043">1043</span> +<span id="1044">1044</span> +<span id="1045">1045</span> +<span id="1046">1046</span> +<span id="1047">1047</span> +<span id="1048">1048</span> +<span id="1049">1049</span> +<span id="1050">1050</span> +<span id="1051">1051</span> +<span id="1052">1052</span> +<span id="1053">1053</span> +<span id="1054">1054</span> +<span id="1055">1055</span> +<span id="1056">1056</span> +<span id="1057">1057</span> +<span id="1058">1058</span> +<span id="1059">1059</span> +<span id="1060">1060</span> +<span id="1061">1061</span> +<span id="1062">1062</span> +<span id="1063">1063</span> +<span id="1064">1064</span> +<span id="1065">1065</span> +<span id="1066">1066</span> +<span id="1067">1067</span> +<span id="1068">1068</span> +<span id="1069">1069</span> +<span id="1070">1070</span> +<span id="1071">1071</span> +<span id="1072">1072</span> +<span id="1073">1073</span> +<span id="1074">1074</span> +<span id="1075">1075</span> +<span id="1076">1076</span> +<span id="1077">1077</span> +<span id="1078">1078</span> +<span id="1079">1079</span> +<span id="1080">1080</span> +<span id="1081">1081</span> +<span id="1082">1082</span> +<span id="1083">1083</span> +<span id="1084">1084</span> +<span id="1085">1085</span> +<span id="1086">1086</span> +<span id="1087">1087</span> +<span id="1088">1088</span> +<span id="1089">1089</span> +<span id="1090">1090</span> +<span id="1091">1091</span> +<span id="1092">1092</span> +<span id="1093">1093</span> +<span id="1094">1094</span> +<span id="1095">1095</span> +<span id="1096">1096</span> +<span id="1097">1097</span> +<span id="1098">1098</span> +<span id="1099">1099</span> +<span id="1100">1100</span> +<span id="1101">1101</span> +<span id="1102">1102</span> +<span id="1103">1103</span> +<span id="1104">1104</span> +<span id="1105">1105</span> +<span id="1106">1106</span> +<span id="1107">1107</span> +<span id="1108">1108</span> +<span id="1109">1109</span> +<span id="1110">1110</span> +<span id="1111">1111</span> +<span id="1112">1112</span> +<span id="1113">1113</span> +<span id="1114">1114</span> +<span id="1115">1115</span> +<span id="1116">1116</span> +<span id="1117">1117</span> +<span id="1118">1118</span> +<span id="1119">1119</span> +<span id="1120">1120</span> +<span id="1121">1121</span> +<span id="1122">1122</span> +<span id="1123">1123</span> +<span id="1124">1124</span> +<span id="1125">1125</span> +<span id="1126">1126</span> +<span id="1127">1127</span> +<span id="1128">1128</span> +<span id="1129">1129</span> +<span id="1130">1130</span> +<span id="1131">1131</span> +<span id="1132">1132</span> +<span id="1133">1133</span> +<span id="1134">1134</span> +<span id="1135">1135</span> +<span id="1136">1136</span> +<span id="1137">1137</span> +<span id="1138">1138</span> +<span id="1139">1139</span> +<span id="1140">1140</span> +<span id="1141">1141</span> +<span id="1142">1142</span> +<span id="1143">1143</span> +<span id="1144">1144</span> +<span id="1145">1145</span> +<span id="1146">1146</span> +<span id="1147">1147</span> +<span id="1148">1148</span> +<span id="1149">1149</span> +<span id="1150">1150</span> +<span id="1151">1151</span> +<span id="1152">1152</span> +<span id="1153">1153</span> +<span id="1154">1154</span> +<span id="1155">1155</span> +<span id="1156">1156</span> +<span id="1157">1157</span> +<span id="1158">1158</span> +<span id="1159">1159</span> +<span id="1160">1160</span> +<span id="1161">1161</span> +<span id="1162">1162</span> +<span id="1163">1163</span> +<span id="1164">1164</span> +<span id="1165">1165</span> +<span id="1166">1166</span> +<span id="1167">1167</span> +<span id="1168">1168</span> +<span id="1169">1169</span> +<span id="1170">1170</span> +<span id="1171">1171</span> +<span id="1172">1172</span> +<span id="1173">1173</span> +<span id="1174">1174</span> +<span id="1175">1175</span> +<span id="1176">1176</span> +<span id="1177">1177</span> +<span id="1178">1178</span> +<span id="1179">1179</span> +<span id="1180">1180</span> +<span id="1181">1181</span> +<span id="1182">1182</span> +<span id="1183">1183</span> +<span id="1184">1184</span> +<span id="1185">1185</span> +<span id="1186">1186</span> +<span id="1187">1187</span> +<span id="1188">1188</span> +<span id="1189">1189</span> +<span id="1190">1190</span> +<span id="1191">1191</span> +<span id="1192">1192</span> +<span id="1193">1193</span> +<span id="1194">1194</span> +<span id="1195">1195</span> +<span id="1196">1196</span> +<span id="1197">1197</span> +<span id="1198">1198</span> +<span id="1199">1199</span> +<span id="1200">1200</span> +<span id="1201">1201</span> +<span id="1202">1202</span> +<span id="1203">1203</span> +<span id="1204">1204</span> +<span id="1205">1205</span> +<span id="1206">1206</span> +<span id="1207">1207</span> +<span id="1208">1208</span> +<span id="1209">1209</span> +<span id="1210">1210</span> +<span id="1211">1211</span> +<span id="1212">1212</span> +<span id="1213">1213</span> +<span id="1214">1214</span> +<span id="1215">1215</span> +<span id="1216">1216</span> +<span id="1217">1217</span> +<span id="1218">1218</span> +<span id="1219">1219</span> +<span id="1220">1220</span> +<span id="1221">1221</span> +<span id="1222">1222</span> +<span id="1223">1223</span> +<span id="1224">1224</span> +<span id="1225">1225</span> +<span id="1226">1226</span> +<span id="1227">1227</span> +<span id="1228">1228</span> +<span id="1229">1229</span> +<span id="1230">1230</span> +<span id="1231">1231</span> +<span id="1232">1232</span> +<span id="1233">1233</span> +<span id="1234">1234</span> +<span id="1235">1235</span> +<span id="1236">1236</span> +<span id="1237">1237</span> +<span id="1238">1238</span> +<span id="1239">1239</span> +<span id="1240">1240</span> +<span id="1241">1241</span> +<span id="1242">1242</span> +<span id="1243">1243</span> +<span id="1244">1244</span> +<span id="1245">1245</span> +<span id="1246">1246</span> +<span id="1247">1247</span> +<span id="1248">1248</span> +<span id="1249">1249</span> +<span id="1250">1250</span> +<span id="1251">1251</span> +<span id="1252">1252</span> +<span id="1253">1253</span> +<span id="1254">1254</span> +<span id="1255">1255</span> +<span id="1256">1256</span> +<span id="1257">1257</span> +<span id="1258">1258</span> +<span id="1259">1259</span> +<span id="1260">1260</span> +<span id="1261">1261</span> +<span id="1262">1262</span> +<span id="1263">1263</span> +<span id="1264">1264</span> +<span id="1265">1265</span> +<span id="1266">1266</span> +<span id="1267">1267</span> +<span id="1268">1268</span> +<span id="1269">1269</span> +<span id="1270">1270</span> +<span id="1271">1271</span> +<span id="1272">1272</span> +<span id="1273">1273</span> +<span id="1274">1274</span> +<span id="1275">1275</span> +<span id="1276">1276</span> +<span id="1277">1277</span> +<span id="1278">1278</span> +<span id="1279">1279</span> +<span id="1280">1280</span> +<span id="1281">1281</span> +<span id="1282">1282</span> +<span id="1283">1283</span> +<span id="1284">1284</span> +<span id="1285">1285</span> +<span id="1286">1286</span> +<span id="1287">1287</span> +<span id="1288">1288</span> +<span id="1289">1289</span> +<span id="1290">1290</span> +<span id="1291">1291</span> +<span id="1292">1292</span> +<span id="1293">1293</span> +<span id="1294">1294</span> +<span id="1295">1295</span> +<span id="1296">1296</span> +<span id="1297">1297</span> +<span id="1298">1298</span> +<span id="1299">1299</span> +<span id="1300">1300</span> +<span id="1301">1301</span> +<span id="1302">1302</span> +<span id="1303">1303</span> +<span id="1304">1304</span> +<span id="1305">1305</span> +<span id="1306">1306</span> +<span id="1307">1307</span> +<span id="1308">1308</span> +<span id="1309">1309</span> +<span id="1310">1310</span> +<span id="1311">1311</span> +<span id="1312">1312</span> +<span id="1313">1313</span> +<span id="1314">1314</span> +<span id="1315">1315</span> +<span id="1316">1316</span> +<span id="1317">1317</span> +<span id="1318">1318</span> +<span id="1319">1319</span> +<span id="1320">1320</span> +<span id="1321">1321</span> +<span id="1322">1322</span> +<span id="1323">1323</span> +<span id="1324">1324</span> +<span id="1325">1325</span> +<span id="1326">1326</span> +<span id="1327">1327</span> +<span id="1328">1328</span> +<span id="1329">1329</span> +<span id="1330">1330</span> +<span id="1331">1331</span> +<span id="1332">1332</span> +<span id="1333">1333</span> +<span id="1334">1334</span> +<span id="1335">1335</span> +<span id="1336">1336</span> +<span id="1337">1337</span> +<span id="1338">1338</span> +<span id="1339">1339</span> +<span id="1340">1340</span> +<span id="1341">1341</span> +<span id="1342">1342</span> +<span id="1343">1343</span> +<span id="1344">1344</span> +<span id="1345">1345</span> +<span id="1346">1346</span> +<span id="1347">1347</span> +<span id="1348">1348</span> +<span id="1349">1349</span> +<span id="1350">1350</span> +<span id="1351">1351</span> +<span id="1352">1352</span> +<span id="1353">1353</span> +<span id="1354">1354</span> +<span id="1355">1355</span> +<span id="1356">1356</span> +<span id="1357">1357</span> +<span id="1358">1358</span> +<span id="1359">1359</span> +<span id="1360">1360</span> +<span id="1361">1361</span> +<span id="1362">1362</span> +<span id="1363">1363</span> +<span id="1364">1364</span> +<span id="1365">1365</span> +<span id="1366">1366</span> +<span id="1367">1367</span> +<span id="1368">1368</span> +<span id="1369">1369</span> +<span id="1370">1370</span> +<span id="1371">1371</span> +<span id="1372">1372</span> +<span id="1373">1373</span> +<span id="1374">1374</span> +<span id="1375">1375</span> +<span id="1376">1376</span> +<span id="1377">1377</span> +<span id="1378">1378</span> +<span id="1379">1379</span> +<span id="1380">1380</span> +<span id="1381">1381</span> +<span id="1382">1382</span> +<span id="1383">1383</span> +<span id="1384">1384</span> +<span id="1385">1385</span> +<span id="1386">1386</span> +<span id="1387">1387</span> +<span id="1388">1388</span> +<span id="1389">1389</span> +<span id="1390">1390</span> +<span id="1391">1391</span> +<span id="1392">1392</span> +<span id="1393">1393</span> +<span id="1394">1394</span> +<span id="1395">1395</span> +<span id="1396">1396</span> +<span id="1397">1397</span> +<span id="1398">1398</span> +<span id="1399">1399</span> +<span id="1400">1400</span> +<span id="1401">1401</span> +<span id="1402">1402</span> +<span id="1403">1403</span> +<span id="1404">1404</span> +<span id="1405">1405</span> +<span id="1406">1406</span> +<span id="1407">1407</span> +<span id="1408">1408</span> +<span id="1409">1409</span> +<span id="1410">1410</span> +<span id="1411">1411</span> +<span id="1412">1412</span> +<span id="1413">1413</span> +<span id="1414">1414</span> +<span id="1415">1415</span> +<span id="1416">1416</span> +<span id="1417">1417</span> +<span id="1418">1418</span> +<span id="1419">1419</span> +<span id="1420">1420</span> +<span id="1421">1421</span> +<span id="1422">1422</span> +<span id="1423">1423</span> +<span id="1424">1424</span> +<span id="1425">1425</span> +<span id="1426">1426</span> +<span id="1427">1427</span> +<span id="1428">1428</span> +<span id="1429">1429</span> +<span id="1430">1430</span> +<span id="1431">1431</span> +<span id="1432">1432</span> +<span id="1433">1433</span> +<span id="1434">1434</span> +<span id="1435">1435</span> +<span id="1436">1436</span> +<span id="1437">1437</span> +<span id="1438">1438</span> +<span id="1439">1439</span> +<span id="1440">1440</span> +<span id="1441">1441</span> +<span id="1442">1442</span> +<span id="1443">1443</span> +<span id="1444">1444</span> +<span id="1445">1445</span> +<span id="1446">1446</span> +<span id="1447">1447</span> +<span id="1448">1448</span> +<span id="1449">1449</span> +<span id="1450">1450</span> +<span id="1451">1451</span> +<span id="1452">1452</span> +<span id="1453">1453</span> +<span id="1454">1454</span> +<span id="1455">1455</span> +<span id="1456">1456</span> +<span id="1457">1457</span> +<span id="1458">1458</span> +<span id="1459">1459</span> +<span id="1460">1460</span> +<span id="1461">1461</span> +<span id="1462">1462</span> +<span id="1463">1463</span> +<span id="1464">1464</span> +<span id="1465">1465</span> +<span id="1466">1466</span> +<span id="1467">1467</span> +<span id="1468">1468</span> +<span id="1469">1469</span> +<span id="1470">1470</span> +<span id="1471">1471</span> +<span id="1472">1472</span> +<span id="1473">1473</span> +<span id="1474">1474</span> +<span id="1475">1475</span> +<span id="1476">1476</span> +<span id="1477">1477</span> +<span id="1478">1478</span> +<span id="1479">1479</span> +<span id="1480">1480</span> +<span id="1481">1481</span> +<span id="1482">1482</span> +<span id="1483">1483</span> +<span id="1484">1484</span> +<span id="1485">1485</span> +<span id="1486">1486</span> +<span id="1487">1487</span> +<span id="1488">1488</span> +<span id="1489">1489</span> +<span id="1490">1490</span> +<span id="1491">1491</span> +<span id="1492">1492</span> +<span id="1493">1493</span> +<span id="1494">1494</span> +<span id="1495">1495</span> +<span id="1496">1496</span> +<span id="1497">1497</span> +<span id="1498">1498</span> +<span id="1499">1499</span> +<span id="1500">1500</span> +<span id="1501">1501</span> +<span id="1502">1502</span> +<span id="1503">1503</span> +<span id="1504">1504</span> +<span id="1505">1505</span> +<span id="1506">1506</span> +<span id="1507">1507</span> +<span id="1508">1508</span> +<span id="1509">1509</span> +<span id="1510">1510</span> +<span id="1511">1511</span> +<span id="1512">1512</span> +<span id="1513">1513</span> +<span id="1514">1514</span> +<span id="1515">1515</span> +<span id="1516">1516</span> +<span id="1517">1517</span> +<span id="1518">1518</span> +<span id="1519">1519</span> +<span id="1520">1520</span> +<span id="1521">1521</span> +<span id="1522">1522</span> +<span id="1523">1523</span> +<span id="1524">1524</span> +<span id="1525">1525</span> +<span id="1526">1526</span> +<span id="1527">1527</span> +<span id="1528">1528</span> +<span id="1529">1529</span> +<span id="1530">1530</span> +<span id="1531">1531</span> +<span id="1532">1532</span> +<span id="1533">1533</span> +<span id="1534">1534</span> +<span id="1535">1535</span> +<span id="1536">1536</span> +<span id="1537">1537</span> +<span id="1538">1538</span> +<span id="1539">1539</span> +<span id="1540">1540</span> +<span id="1541">1541</span> +<span id="1542">1542</span> +<span id="1543">1543</span> +<span id="1544">1544</span> +<span id="1545">1545</span> +<span id="1546">1546</span> +<span id="1547">1547</span> +<span id="1548">1548</span> +<span id="1549">1549</span> +<span id="1550">1550</span> +<span id="1551">1551</span> +<span id="1552">1552</span> +<span id="1553">1553</span> +<span id="1554">1554</span> +<span id="1555">1555</span> +<span id="1556">1556</span> +<span id="1557">1557</span> +<span id="1558">1558</span> +<span id="1559">1559</span> +<span id="1560">1560</span> +<span id="1561">1561</span> +<span id="1562">1562</span> +<span id="1563">1563</span> +<span id="1564">1564</span> +<span id="1565">1565</span> +<span id="1566">1566</span> +<span id="1567">1567</span> +<span id="1568">1568</span> +<span id="1569">1569</span> +<span id="1570">1570</span> +<span id="1571">1571</span> +<span id="1572">1572</span> +<span id="1573">1573</span> +<span id="1574">1574</span> +<span id="1575">1575</span> +<span id="1576">1576</span> +<span id="1577">1577</span> +<span id="1578">1578</span> +<span id="1579">1579</span> +<span id="1580">1580</span> +<span id="1581">1581</span> +<span id="1582">1582</span> +<span id="1583">1583</span> +<span id="1584">1584</span> +<span id="1585">1585</span> +<span id="1586">1586</span> +<span id="1587">1587</span> +<span id="1588">1588</span> +<span id="1589">1589</span> +<span id="1590">1590</span> +<span id="1591">1591</span> +<span id="1592">1592</span> +<span id="1593">1593</span> +<span id="1594">1594</span> +<span id="1595">1595</span> +<span id="1596">1596</span> +<span id="1597">1597</span> +<span id="1598">1598</span> +<span id="1599">1599</span> +<span id="1600">1600</span> +<span id="1601">1601</span> +<span id="1602">1602</span> +<span id="1603">1603</span> +<span id="1604">1604</span> +<span id="1605">1605</span> +<span id="1606">1606</span> +<span id="1607">1607</span> +<span id="1608">1608</span> +<span id="1609">1609</span> +<span id="1610">1610</span> +<span id="1611">1611</span> +<span id="1612">1612</span> +<span id="1613">1613</span> +<span id="1614">1614</span> +<span id="1615">1615</span> +<span id="1616">1616</span> +<span id="1617">1617</span> +<span id="1618">1618</span> +<span id="1619">1619</span> +<span id="1620">1620</span> +<span id="1621">1621</span> +<span id="1622">1622</span> +<span id="1623">1623</span> +<span id="1624">1624</span> +<span id="1625">1625</span> +<span id="1626">1626</span> +<span id="1627">1627</span> +<span id="1628">1628</span> +<span id="1629">1629</span> +<span id="1630">1630</span> +<span id="1631">1631</span> +<span id="1632">1632</span> +<span id="1633">1633</span> +<span id="1634">1634</span> +<span id="1635">1635</span> +<span id="1636">1636</span> +<span id="1637">1637</span> +<span id="1638">1638</span> +<span id="1639">1639</span> +<span id="1640">1640</span> +<span id="1641">1641</span> +<span id="1642">1642</span> +<span id="1643">1643</span> +<span id="1644">1644</span> +<span id="1645">1645</span> +<span id="1646">1646</span> +<span id="1647">1647</span> +<span id="1648">1648</span> +<span id="1649">1649</span> +<span id="1650">1650</span> +<span id="1651">1651</span> +<span id="1652">1652</span> +<span id="1653">1653</span> +<span id="1654">1654</span> +<span id="1655">1655</span> +<span id="1656">1656</span> +<span id="1657">1657</span> +<span id="1658">1658</span> +<span id="1659">1659</span> +<span id="1660">1660</span> +<span id="1661">1661</span> +<span id="1662">1662</span> +<span id="1663">1663</span> +<span id="1664">1664</span> +<span id="1665">1665</span> +<span id="1666">1666</span> +<span id="1667">1667</span> +<span id="1668">1668</span> +<span id="1669">1669</span> +<span id="1670">1670</span> +<span id="1671">1671</span> +<span id="1672">1672</span> +<span id="1673">1673</span> +<span id="1674">1674</span> +<span id="1675">1675</span> +<span id="1676">1676</span> +<span id="1677">1677</span> +<span id="1678">1678</span> +<span id="1679">1679</span> +<span id="1680">1680</span> +<span id="1681">1681</span> +<span id="1682">1682</span> +<span id="1683">1683</span> +<span id="1684">1684</span> +<span id="1685">1685</span> +<span id="1686">1686</span> +<span id="1687">1687</span> +<span id="1688">1688</span> +<span id="1689">1689</span> +<span id="1690">1690</span> +<span id="1691">1691</span> +<span id="1692">1692</span> +<span id="1693">1693</span> +<span id="1694">1694</span> +<span id="1695">1695</span> +<span id="1696">1696</span> +<span id="1697">1697</span> +<span id="1698">1698</span> +<span id="1699">1699</span> +<span id="1700">1700</span> +<span id="1701">1701</span> +<span id="1702">1702</span> +<span id="1703">1703</span> +<span id="1704">1704</span> +<span id="1705">1705</span> +<span id="1706">1706</span> +<span id="1707">1707</span> +<span id="1708">1708</span> +<span id="1709">1709</span> +<span id="1710">1710</span> +<span id="1711">1711</span> +<span id="1712">1712</span> +<span id="1713">1713</span> +<span id="1714">1714</span> +<span id="1715">1715</span> +<span id="1716">1716</span> +<span id="1717">1717</span> +<span id="1718">1718</span> +<span id="1719">1719</span> +<span id="1720">1720</span> +<span id="1721">1721</span> +<span id="1722">1722</span> +<span id="1723">1723</span> +<span id="1724">1724</span> +<span id="1725">1725</span> +<span id="1726">1726</span> +<span id="1727">1727</span> +<span id="1728">1728</span> +<span id="1729">1729</span> +<span id="1730">1730</span> +<span id="1731">1731</span> +<span id="1732">1732</span> +<span id="1733">1733</span> +<span id="1734">1734</span> +<span id="1735">1735</span> +<span id="1736">1736</span> +<span id="1737">1737</span> +<span id="1738">1738</span> +<span id="1739">1739</span> +<span id="1740">1740</span> +<span id="1741">1741</span> +<span id="1742">1742</span> +<span id="1743">1743</span> +<span id="1744">1744</span> +<span id="1745">1745</span> +<span id="1746">1746</span> +<span id="1747">1747</span> +<span id="1748">1748</span> +<span id="1749">1749</span> +<span id="1750">1750</span> +<span id="1751">1751</span> +<span id="1752">1752</span> +<span id="1753">1753</span> +<span id="1754">1754</span> +<span id="1755">1755</span> +<span id="1756">1756</span> +<span id="1757">1757</span> +<span id="1758">1758</span> +<span id="1759">1759</span> +<span id="1760">1760</span> +<span id="1761">1761</span> +<span id="1762">1762</span> +<span id="1763">1763</span> +<span id="1764">1764</span> +<span id="1765">1765</span> +<span id="1766">1766</span> +<span id="1767">1767</span> +<span id="1768">1768</span> +<span id="1769">1769</span> +<span id="1770">1770</span> +<span id="1771">1771</span> +<span id="1772">1772</span> +<span id="1773">1773</span> +<span id="1774">1774</span> +<span id="1775">1775</span> +<span id="1776">1776</span> +<span id="1777">1777</span> +<span id="1778">1778</span> +<span id="1779">1779</span> +<span id="1780">1780</span> +<span id="1781">1781</span> +<span id="1782">1782</span> +<span id="1783">1783</span> +<span id="1784">1784</span> +<span id="1785">1785</span> +<span id="1786">1786</span> +<span id="1787">1787</span> +<span id="1788">1788</span> +<span id="1789">1789</span> +<span id="1790">1790</span> +<span id="1791">1791</span> +<span id="1792">1792</span> +<span id="1793">1793</span> +<span id="1794">1794</span> +<span id="1795">1795</span> +<span id="1796">1796</span> +<span id="1797">1797</span> +<span id="1798">1798</span> +<span id="1799">1799</span> +<span id="1800">1800</span> +<span id="1801">1801</span> +<span id="1802">1802</span> +<span id="1803">1803</span> +<span id="1804">1804</span> +<span id="1805">1805</span> +<span id="1806">1806</span> +<span id="1807">1807</span> +<span id="1808">1808</span> +<span id="1809">1809</span> +<span id="1810">1810</span> +<span id="1811">1811</span> +<span id="1812">1812</span> +<span id="1813">1813</span> +<span id="1814">1814</span> +<span id="1815">1815</span> +<span id="1816">1816</span> +<span id="1817">1817</span> +<span id="1818">1818</span> +<span id="1819">1819</span> +<span id="1820">1820</span> +<span id="1821">1821</span> +<span id="1822">1822</span> +<span id="1823">1823</span> +<span id="1824">1824</span> +<span id="1825">1825</span> +<span id="1826">1826</span> +<span id="1827">1827</span> +<span id="1828">1828</span> +<span id="1829">1829</span> +<span id="1830">1830</span> +<span id="1831">1831</span> +<span id="1832">1832</span> +<span id="1833">1833</span> +<span id="1834">1834</span> +<span id="1835">1835</span> +<span id="1836">1836</span> +<span id="1837">1837</span> +<span id="1838">1838</span> +<span id="1839">1839</span> +<span id="1840">1840</span> +<span id="1841">1841</span> +<span id="1842">1842</span> +<span id="1843">1843</span> +<span id="1844">1844</span> +<span id="1845">1845</span> +<span id="1846">1846</span> +<span id="1847">1847</span> +<span id="1848">1848</span> +<span id="1849">1849</span> +<span id="1850">1850</span> +<span id="1851">1851</span> +<span id="1852">1852</span> +<span id="1853">1853</span> +<span id="1854">1854</span> +<span id="1855">1855</span> +<span id="1856">1856</span> +<span id="1857">1857</span> +<span id="1858">1858</span> +<span id="1859">1859</span> +<span id="1860">1860</span> +<span id="1861">1861</span> +<span id="1862">1862</span> +<span id="1863">1863</span> +<span id="1864">1864</span> +<span id="1865">1865</span> +<span id="1866">1866</span> +<span id="1867">1867</span> +<span id="1868">1868</span> +<span id="1869">1869</span> +<span id="1870">1870</span> +<span id="1871">1871</span> +<span id="1872">1872</span> +<span id="1873">1873</span> +<span id="1874">1874</span> +<span id="1875">1875</span> +<span id="1876">1876</span> +<span id="1877">1877</span> +<span id="1878">1878</span> +<span id="1879">1879</span> +<span id="1880">1880</span> +<span id="1881">1881</span> +<span id="1882">1882</span> +<span id="1883">1883</span> +<span id="1884">1884</span> +<span id="1885">1885</span> +<span id="1886">1886</span> +<span id="1887">1887</span> +<span id="1888">1888</span> +<span id="1889">1889</span> +<span id="1890">1890</span> +<span id="1891">1891</span> +<span id="1892">1892</span> +<span id="1893">1893</span> +<span id="1894">1894</span> +<span id="1895">1895</span> +<span id="1896">1896</span> +<span id="1897">1897</span> +<span id="1898">1898</span> +<span id="1899">1899</span> +<span id="1900">1900</span> +<span id="1901">1901</span> +<span id="1902">1902</span> +<span id="1903">1903</span> +<span id="1904">1904</span> +<span id="1905">1905</span> +<span id="1906">1906</span> +<span id="1907">1907</span> +<span id="1908">1908</span> +<span id="1909">1909</span> +<span id="1910">1910</span> +<span id="1911">1911</span> +<span id="1912">1912</span> +<span id="1913">1913</span> +<span id="1914">1914</span> +<span id="1915">1915</span> +<span id="1916">1916</span> +<span id="1917">1917</span> +<span id="1918">1918</span> +<span id="1919">1919</span> +<span id="1920">1920</span> +<span id="1921">1921</span> +<span id="1922">1922</span> +<span id="1923">1923</span> +<span id="1924">1924</span> +<span id="1925">1925</span> +<span id="1926">1926</span> +<span id="1927">1927</span> +<span id="1928">1928</span> +<span id="1929">1929</span> +<span id="1930">1930</span> +<span id="1931">1931</span> +<span id="1932">1932</span> +<span id="1933">1933</span> +<span id="1934">1934</span> +<span id="1935">1935</span> +<span id="1936">1936</span> +<span id="1937">1937</span> +<span id="1938">1938</span> +<span id="1939">1939</span> +<span id="1940">1940</span> +<span id="1941">1941</span> +<span id="1942">1942</span> +<span id="1943">1943</span> +<span id="1944">1944</span> +<span id="1945">1945</span> +<span id="1946">1946</span> +<span id="1947">1947</span> +<span id="1948">1948</span> +<span id="1949">1949</span> +<span id="1950">1950</span> +<span id="1951">1951</span> +<span id="1952">1952</span> +<span id="1953">1953</span> +<span id="1954">1954</span> +<span id="1955">1955</span> +<span id="1956">1956</span> +<span id="1957">1957</span> +<span id="1958">1958</span> +<span id="1959">1959</span> +<span id="1960">1960</span> +<span id="1961">1961</span> +<span id="1962">1962</span> +<span id="1963">1963</span> +<span id="1964">1964</span> +<span id="1965">1965</span> +<span id="1966">1966</span> +<span id="1967">1967</span> +<span id="1968">1968</span> +<span id="1969">1969</span> +<span id="1970">1970</span> +<span id="1971">1971</span> +<span id="1972">1972</span> +<span id="1973">1973</span> +<span id="1974">1974</span> +<span id="1975">1975</span> +<span id="1976">1976</span> +<span id="1977">1977</span> +<span id="1978">1978</span> +<span id="1979">1979</span> +<span id="1980">1980</span> +<span id="1981">1981</span> +<span id="1982">1982</span> +<span id="1983">1983</span> +<span id="1984">1984</span> +<span id="1985">1985</span> +<span id="1986">1986</span> +<span id="1987">1987</span> +<span id="1988">1988</span> +<span id="1989">1989</span> +<span id="1990">1990</span> +<span id="1991">1991</span> +<span id="1992">1992</span> +<span id="1993">1993</span> +<span id="1994">1994</span> +<span id="1995">1995</span> +<span id="1996">1996</span> +<span id="1997">1997</span> +<span id="1998">1998</span> +<span id="1999">1999</span> +<span id="2000">2000</span> +<span id="2001">2001</span> +<span id="2002">2002</span> +<span id="2003">2003</span> +<span id="2004">2004</span> +<span id="2005">2005</span> +<span id="2006">2006</span> +<span id="2007">2007</span> +<span id="2008">2008</span> +<span id="2009">2009</span> +<span id="2010">2010</span> +<span id="2011">2011</span> +<span id="2012">2012</span> +<span id="2013">2013</span> +<span id="2014">2014</span> +<span id="2015">2015</span> +<span id="2016">2016</span> +<span id="2017">2017</span> +<span id="2018">2018</span> +<span id="2019">2019</span> +<span id="2020">2020</span> +<span id="2021">2021</span> +<span id="2022">2022</span> +<span id="2023">2023</span> +<span id="2024">2024</span> +<span id="2025">2025</span> +<span id="2026">2026</span> +<span id="2027">2027</span> +<span id="2028">2028</span> +<span id="2029">2029</span> +<span id="2030">2030</span> +<span id="2031">2031</span> +<span id="2032">2032</span> +<span id="2033">2033</span> +<span id="2034">2034</span> +<span id="2035">2035</span> +<span id="2036">2036</span> +<span id="2037">2037</span> +<span id="2038">2038</span> +<span id="2039">2039</span> +<span id="2040">2040</span> +<span id="2041">2041</span> +<span id="2042">2042</span> +<span id="2043">2043</span> +<span id="2044">2044</span> +<span id="2045">2045</span> +<span id="2046">2046</span> +<span id="2047">2047</span> +<span id="2048">2048</span> +<span id="2049">2049</span> +<span id="2050">2050</span> +<span id="2051">2051</span> +<span id="2052">2052</span> +<span id="2053">2053</span> +<span id="2054">2054</span> +<span id="2055">2055</span> +<span id="2056">2056</span> +<span id="2057">2057</span> +<span id="2058">2058</span> +<span id="2059">2059</span> +<span id="2060">2060</span> +<span id="2061">2061</span> +<span id="2062">2062</span> +<span id="2063">2063</span> +<span id="2064">2064</span> +<span id="2065">2065</span> +<span id="2066">2066</span> +<span id="2067">2067</span> +<span id="2068">2068</span> +<span id="2069">2069</span> +<span id="2070">2070</span> +<span id="2071">2071</span> +<span id="2072">2072</span> +<span id="2073">2073</span> +<span id="2074">2074</span> +<span id="2075">2075</span> +<span id="2076">2076</span> +<span id="2077">2077</span> +<span id="2078">2078</span> +<span id="2079">2079</span> +<span id="2080">2080</span> +<span id="2081">2081</span> +<span id="2082">2082</span> +<span id="2083">2083</span> +<span id="2084">2084</span> +<span id="2085">2085</span> +<span id="2086">2086</span> +<span id="2087">2087</span> +<span id="2088">2088</span> +<span id="2089">2089</span> +<span id="2090">2090</span> +<span id="2091">2091</span> +<span id="2092">2092</span> +<span id="2093">2093</span> +<span id="2094">2094</span> +<span id="2095">2095</span> +<span id="2096">2096</span> +<span id="2097">2097</span> +<span id="2098">2098</span> +<span id="2099">2099</span> +<span id="2100">2100</span> +<span id="2101">2101</span> +<span id="2102">2102</span> +<span id="2103">2103</span> +<span id="2104">2104</span> +<span id="2105">2105</span> +<span id="2106">2106</span> +<span id="2107">2107</span> +<span id="2108">2108</span> +<span id="2109">2109</span> +<span id="2110">2110</span> +<span id="2111">2111</span> +<span id="2112">2112</span> +<span id="2113">2113</span> +<span id="2114">2114</span> +<span id="2115">2115</span> +<span id="2116">2116</span> +<span id="2117">2117</span> +<span id="2118">2118</span> +<span id="2119">2119</span> +<span id="2120">2120</span> +<span id="2121">2121</span> +<span id="2122">2122</span> +<span id="2123">2123</span> +<span id="2124">2124</span> +<span id="2125">2125</span> +<span id="2126">2126</span> +<span id="2127">2127</span> +<span id="2128">2128</span> +<span id="2129">2129</span> +<span id="2130">2130</span> +<span id="2131">2131</span> +<span id="2132">2132</span> +<span id="2133">2133</span> +<span id="2134">2134</span> +<span id="2135">2135</span> +<span id="2136">2136</span> +<span id="2137">2137</span> +<span id="2138">2138</span> +<span id="2139">2139</span> +<span id="2140">2140</span> +<span id="2141">2141</span> +<span id="2142">2142</span> +<span id="2143">2143</span> +<span id="2144">2144</span> +<span id="2145">2145</span> +<span id="2146">2146</span> +<span id="2147">2147</span> +<span id="2148">2148</span> +<span id="2149">2149</span> +<span id="2150">2150</span> +<span id="2151">2151</span> +<span id="2152">2152</span> +<span id="2153">2153</span> +<span id="2154">2154</span> +<span id="2155">2155</span> +<span id="2156">2156</span> +<span id="2157">2157</span> +<span id="2158">2158</span> +<span id="2159">2159</span> +<span id="2160">2160</span> +<span id="2161">2161</span> +<span id="2162">2162</span> +<span id="2163">2163</span> +<span id="2164">2164</span> +<span id="2165">2165</span> +<span id="2166">2166</span> +<span id="2167">2167</span> +<span id="2168">2168</span> +<span id="2169">2169</span> +<span id="2170">2170</span> +<span id="2171">2171</span> +<span id="2172">2172</span> +<span id="2173">2173</span> +<span id="2174">2174</span> +<span id="2175">2175</span> +<span id="2176">2176</span> +<span id="2177">2177</span> +<span id="2178">2178</span> +<span id="2179">2179</span> +<span id="2180">2180</span> +<span id="2181">2181</span> +<span id="2182">2182</span> +<span id="2183">2183</span> +<span id="2184">2184</span> +<span id="2185">2185</span> +<span id="2186">2186</span> +<span id="2187">2187</span> +<span id="2188">2188</span> +<span id="2189">2189</span> +<span id="2190">2190</span> +<span id="2191">2191</span> +<span id="2192">2192</span> +<span id="2193">2193</span> +<span id="2194">2194</span> +<span id="2195">2195</span> +<span id="2196">2196</span> +<span id="2197">2197</span> +<span id="2198">2198</span> +<span id="2199">2199</span> +<span id="2200">2200</span> +<span id="2201">2201</span> +<span id="2202">2202</span> +<span id="2203">2203</span> +<span id="2204">2204</span> +<span id="2205">2205</span> +<span id="2206">2206</span> +<span id="2207">2207</span> +<span id="2208">2208</span> +<span id="2209">2209</span> +<span id="2210">2210</span> +<span id="2211">2211</span> +<span id="2212">2212</span> +<span id="2213">2213</span> +<span id="2214">2214</span> +<span id="2215">2215</span> +<span id="2216">2216</span> +<span id="2217">2217</span> +<span id="2218">2218</span> +<span id="2219">2219</span> +<span id="2220">2220</span> +<span id="2221">2221</span> +<span id="2222">2222</span> +<span id="2223">2223</span> +<span id="2224">2224</span> +<span id="2225">2225</span> +<span id="2226">2226</span> +<span id="2227">2227</span> +<span id="2228">2228</span> +<span id="2229">2229</span> +<span id="2230">2230</span> +<span id="2231">2231</span> +<span id="2232">2232</span> +<span id="2233">2233</span> +<span id="2234">2234</span> +<span id="2235">2235</span> +<span id="2236">2236</span> +<span id="2237">2237</span> +<span id="2238">2238</span> +<span id="2239">2239</span> +<span id="2240">2240</span> +<span id="2241">2241</span> +<span id="2242">2242</span> +<span id="2243">2243</span> +<span id="2244">2244</span> +<span id="2245">2245</span> +<span id="2246">2246</span> +<span id="2247">2247</span> +<span id="2248">2248</span> +<span id="2249">2249</span> +<span id="2250">2250</span> +<span id="2251">2251</span> +<span id="2252">2252</span> +<span id="2253">2253</span> +<span id="2254">2254</span> +<span id="2255">2255</span> +<span id="2256">2256</span> +<span id="2257">2257</span> +<span id="2258">2258</span> +<span id="2259">2259</span> +<span id="2260">2260</span> +<span id="2261">2261</span> +<span id="2262">2262</span> +<span id="2263">2263</span> +<span id="2264">2264</span> +<span id="2265">2265</span> +<span id="2266">2266</span> +<span id="2267">2267</span> +<span id="2268">2268</span> +<span id="2269">2269</span> +<span id="2270">2270</span> +<span id="2271">2271</span> +<span id="2272">2272</span> +<span id="2273">2273</span> +<span id="2274">2274</span> +<span id="2275">2275</span> +<span id="2276">2276</span> +<span id="2277">2277</span> +<span id="2278">2278</span> +<span id="2279">2279</span> +<span id="2280">2280</span> +<span id="2281">2281</span> +<span id="2282">2282</span> +<span id="2283">2283</span> +<span id="2284">2284</span> +<span id="2285">2285</span> +<span id="2286">2286</span> +<span id="2287">2287</span> +<span id="2288">2288</span> +<span id="2289">2289</span> +<span id="2290">2290</span> +<span id="2291">2291</span> +<span id="2292">2292</span> +<span id="2293">2293</span> +<span id="2294">2294</span> +<span id="2295">2295</span> +<span id="2296">2296</span> +<span id="2297">2297</span> +<span id="2298">2298</span> +<span id="2299">2299</span> +<span id="2300">2300</span> +<span id="2301">2301</span> +<span id="2302">2302</span> +<span id="2303">2303</span> +<span id="2304">2304</span> +<span id="2305">2305</span> +<span id="2306">2306</span> +<span id="2307">2307</span> +<span id="2308">2308</span> +<span id="2309">2309</span> +<span id="2310">2310</span> +<span id="2311">2311</span> +<span id="2312">2312</span> +<span id="2313">2313</span> +<span id="2314">2314</span> +<span id="2315">2315</span> +<span id="2316">2316</span> +<span id="2317">2317</span> +<span id="2318">2318</span> +<span id="2319">2319</span> +<span id="2320">2320</span> +<span id="2321">2321</span> +<span id="2322">2322</span> +<span id="2323">2323</span> +<span id="2324">2324</span> +<span id="2325">2325</span> +<span id="2326">2326</span> +<span id="2327">2327</span> +<span id="2328">2328</span> +<span id="2329">2329</span> +<span id="2330">2330</span> +<span id="2331">2331</span> +<span id="2332">2332</span> +<span id="2333">2333</span> +<span id="2334">2334</span> +<span id="2335">2335</span> +<span id="2336">2336</span> +<span id="2337">2337</span> +<span id="2338">2338</span> +<span id="2339">2339</span> +<span id="2340">2340</span> +<span id="2341">2341</span> +<span id="2342">2342</span> +<span id="2343">2343</span> +<span id="2344">2344</span> +<span id="2345">2345</span> +<span id="2346">2346</span> +<span id="2347">2347</span> +<span id="2348">2348</span> +<span id="2349">2349</span> +<span id="2350">2350</span> +<span id="2351">2351</span> +<span id="2352">2352</span> +<span id="2353">2353</span> +<span id="2354">2354</span> +<span id="2355">2355</span> +<span id="2356">2356</span> +<span id="2357">2357</span> +<span id="2358">2358</span> +<span id="2359">2359</span> +<span id="2360">2360</span> +<span id="2361">2361</span> +<span id="2362">2362</span> +<span id="2363">2363</span> +<span id="2364">2364</span> +<span id="2365">2365</span> +<span id="2366">2366</span> +<span id="2367">2367</span> +<span id="2368">2368</span> +<span id="2369">2369</span> +<span id="2370">2370</span> +<span id="2371">2371</span> +<span id="2372">2372</span> +<span id="2373">2373</span> +<span id="2374">2374</span> +<span id="2375">2375</span> +<span id="2376">2376</span> +<span id="2377">2377</span> +<span id="2378">2378</span> +<span id="2379">2379</span> +<span id="2380">2380</span> +<span id="2381">2381</span> +<span id="2382">2382</span> +<span id="2383">2383</span> +<span id="2384">2384</span> +<span id="2385">2385</span> +<span id="2386">2386</span> +<span id="2387">2387</span> +<span id="2388">2388</span> +<span id="2389">2389</span> +<span id="2390">2390</span> +<span id="2391">2391</span> +<span id="2392">2392</span> +<span id="2393">2393</span> +<span id="2394">2394</span> +<span id="2395">2395</span> +<span id="2396">2396</span> +<span id="2397">2397</span> +<span id="2398">2398</span> +<span id="2399">2399</span> +<span id="2400">2400</span> +<span id="2401">2401</span> +<span id="2402">2402</span> +<span id="2403">2403</span> +<span id="2404">2404</span> +<span id="2405">2405</span> +<span id="2406">2406</span> +<span id="2407">2407</span> +<span id="2408">2408</span> +<span id="2409">2409</span> +<span id="2410">2410</span> +<span id="2411">2411</span> +<span id="2412">2412</span> +<span id="2413">2413</span> +<span id="2414">2414</span> +<span id="2415">2415</span> +<span id="2416">2416</span> +<span id="2417">2417</span> +<span id="2418">2418</span> +<span id="2419">2419</span> +<span id="2420">2420</span> +<span id="2421">2421</span> +<span id="2422">2422</span> +<span id="2423">2423</span> +<span id="2424">2424</span> +<span id="2425">2425</span> +<span id="2426">2426</span> +<span id="2427">2427</span> +<span id="2428">2428</span> +<span id="2429">2429</span> +<span id="2430">2430</span> +<span id="2431">2431</span> +<span id="2432">2432</span> +<span id="2433">2433</span> +<span id="2434">2434</span> +<span id="2435">2435</span> +<span id="2436">2436</span> +<span id="2437">2437</span> +<span id="2438">2438</span> +<span id="2439">2439</span> +<span id="2440">2440</span> +<span id="2441">2441</span> +<span id="2442">2442</span> +<span id="2443">2443</span> +<span id="2444">2444</span> +<span id="2445">2445</span> +<span id="2446">2446</span> +<span id="2447">2447</span> +<span id="2448">2448</span> +<span id="2449">2449</span> +<span id="2450">2450</span> +<span id="2451">2451</span> +<span id="2452">2452</span> +<span id="2453">2453</span> +<span id="2454">2454</span> +<span id="2455">2455</span> +<span id="2456">2456</span> +<span id="2457">2457</span> +<span id="2458">2458</span> +<span id="2459">2459</span> +<span id="2460">2460</span> +<span id="2461">2461</span> +<span id="2462">2462</span> +<span id="2463">2463</span> +<span id="2464">2464</span> +<span id="2465">2465</span> +<span id="2466">2466</span> +<span id="2467">2467</span> +<span id="2468">2468</span> +<span id="2469">2469</span> +<span id="2470">2470</span> +<span id="2471">2471</span> +<span id="2472">2472</span> +<span id="2473">2473</span> +<span id="2474">2474</span> +<span id="2475">2475</span> +<span id="2476">2476</span> +<span id="2477">2477</span> +<span id="2478">2478</span> +<span id="2479">2479</span> +<span id="2480">2480</span> +<span id="2481">2481</span> +<span id="2482">2482</span> +<span id="2483">2483</span> +<span id="2484">2484</span> +<span id="2485">2485</span> +<span id="2486">2486</span> +<span id="2487">2487</span> +<span id="2488">2488</span> +<span id="2489">2489</span> +<span id="2490">2490</span> +<span id="2491">2491</span> +<span id="2492">2492</span> +<span id="2493">2493</span> +<span id="2494">2494</span> +<span id="2495">2495</span> +<span id="2496">2496</span> +<span id="2497">2497</span> +<span id="2498">2498</span> +<span id="2499">2499</span> +<span id="2500">2500</span> +<span id="2501">2501</span> +<span id="2502">2502</span> +<span id="2503">2503</span> +<span id="2504">2504</span> +<span id="2505">2505</span> +<span id="2506">2506</span> +<span id="2507">2507</span> +<span id="2508">2508</span> +<span id="2509">2509</span> +<span id="2510">2510</span> +<span id="2511">2511</span> +<span id="2512">2512</span> +<span id="2513">2513</span> +<span id="2514">2514</span> +<span id="2515">2515</span> +<span id="2516">2516</span> +<span id="2517">2517</span> +<span id="2518">2518</span> +<span id="2519">2519</span> +<span id="2520">2520</span> +<span id="2521">2521</span> +<span id="2522">2522</span> +<span id="2523">2523</span> +<span id="2524">2524</span> +<span id="2525">2525</span> +<span id="2526">2526</span> +<span id="2527">2527</span> +<span id="2528">2528</span> +<span id="2529">2529</span> +<span id="2530">2530</span> +<span id="2531">2531</span> +<span id="2532">2532</span> +<span id="2533">2533</span> +<span id="2534">2534</span> +<span id="2535">2535</span> +<span id="2536">2536</span> +<span id="2537">2537</span> +<span id="2538">2538</span> +<span id="2539">2539</span> +<span id="2540">2540</span> +<span id="2541">2541</span> +<span id="2542">2542</span> +<span id="2543">2543</span> +<span id="2544">2544</span> +<span id="2545">2545</span> +<span id="2546">2546</span> +<span id="2547">2547</span> +<span id="2548">2548</span> +<span id="2549">2549</span> +<span id="2550">2550</span> +<span id="2551">2551</span> +<span id="2552">2552</span> +<span id="2553">2553</span> +<span id="2554">2554</span> +<span id="2555">2555</span> +<span id="2556">2556</span> +<span id="2557">2557</span> +<span id="2558">2558</span> +<span id="2559">2559</span> +<span id="2560">2560</span> +<span id="2561">2561</span> +<span id="2562">2562</span> +<span id="2563">2563</span> +<span id="2564">2564</span> +<span id="2565">2565</span> +<span id="2566">2566</span> +<span id="2567">2567</span> +<span id="2568">2568</span> +<span id="2569">2569</span> +<span id="2570">2570</span> +<span id="2571">2571</span> +<span id="2572">2572</span> +<span id="2573">2573</span> +<span id="2574">2574</span> +<span id="2575">2575</span> +<span id="2576">2576</span> +<span id="2577">2577</span> +<span id="2578">2578</span> +<span id="2579">2579</span> +<span id="2580">2580</span> +<span id="2581">2581</span> +<span id="2582">2582</span> +<span id="2583">2583</span> +<span id="2584">2584</span> +<span id="2585">2585</span> +<span id="2586">2586</span> +<span id="2587">2587</span> +<span id="2588">2588</span> +<span id="2589">2589</span> +<span id="2590">2590</span> +<span id="2591">2591</span> +<span id="2592">2592</span> +<span id="2593">2593</span> +<span id="2594">2594</span> +<span id="2595">2595</span> +<span id="2596">2596</span> +<span id="2597">2597</span> +<span id="2598">2598</span> +<span id="2599">2599</span> +<span id="2600">2600</span> +<span id="2601">2601</span> +<span id="2602">2602</span> +<span id="2603">2603</span> +<span id="2604">2604</span> +<span id="2605">2605</span> +<span id="2606">2606</span> +<span id="2607">2607</span> +<span id="2608">2608</span> +<span id="2609">2609</span> +<span id="2610">2610</span> +<span id="2611">2611</span> +<span id="2612">2612</span> +<span id="2613">2613</span> +<span id="2614">2614</span> +<span id="2615">2615</span> +<span id="2616">2616</span> +<span id="2617">2617</span> +<span id="2618">2618</span> +<span id="2619">2619</span> +<span id="2620">2620</span> +<span id="2621">2621</span> +<span id="2622">2622</span> +<span id="2623">2623</span> +<span id="2624">2624</span> +<span id="2625">2625</span> +<span id="2626">2626</span> +<span id="2627">2627</span> +<span id="2628">2628</span> +<span id="2629">2629</span> +<span id="2630">2630</span> +<span id="2631">2631</span> +<span id="2632">2632</span> +<span id="2633">2633</span> +<span id="2634">2634</span> +<span id="2635">2635</span> +<span id="2636">2636</span> +<span id="2637">2637</span> +<span id="2638">2638</span> +<span id="2639">2639</span> +<span id="2640">2640</span> +<span id="2641">2641</span> +<span id="2642">2642</span> +<span id="2643">2643</span> +<span id="2644">2644</span> +<span id="2645">2645</span> +<span id="2646">2646</span> +<span id="2647">2647</span> +<span id="2648">2648</span> +<span id="2649">2649</span> +<span id="2650">2650</span> +<span id="2651">2651</span> +<span id="2652">2652</span> +<span id="2653">2653</span> +<span id="2654">2654</span> +<span id="2655">2655</span> +<span id="2656">2656</span> +<span id="2657">2657</span> +<span id="2658">2658</span> +<span id="2659">2659</span> +<span id="2660">2660</span> +<span id="2661">2661</span> +<span id="2662">2662</span> +<span id="2663">2663</span> +<span id="2664">2664</span> +<span id="2665">2665</span> +<span id="2666">2666</span> +<span id="2667">2667</span> +<span id="2668">2668</span> +<span id="2669">2669</span> +<span id="2670">2670</span> +<span id="2671">2671</span> +<span id="2672">2672</span> +<span id="2673">2673</span> +<span id="2674">2674</span> +<span id="2675">2675</span> +<span id="2676">2676</span> +<span id="2677">2677</span> +<span id="2678">2678</span> +<span id="2679">2679</span> +<span id="2680">2680</span> +<span id="2681">2681</span> +<span id="2682">2682</span> +<span id="2683">2683</span> +<span id="2684">2684</span> +<span id="2685">2685</span> +<span id="2686">2686</span> +<span id="2687">2687</span> +<span id="2688">2688</span> +<span id="2689">2689</span> +<span id="2690">2690</span> +<span id="2691">2691</span> +<span id="2692">2692</span> +<span id="2693">2693</span> +<span id="2694">2694</span> +<span id="2695">2695</span> +<span id="2696">2696</span> +<span id="2697">2697</span> +<span id="2698">2698</span> +<span id="2699">2699</span> +<span id="2700">2700</span> +<span id="2701">2701</span> +<span id="2702">2702</span> +<span id="2703">2703</span> +<span id="2704">2704</span> +<span id="2705">2705</span> +<span id="2706">2706</span> +<span id="2707">2707</span> +<span id="2708">2708</span> +<span id="2709">2709</span> +<span id="2710">2710</span> +<span id="2711">2711</span> +<span id="2712">2712</span> +<span id="2713">2713</span> +<span id="2714">2714</span> +<span id="2715">2715</span> +<span id="2716">2716</span> +<span id="2717">2717</span> +<span id="2718">2718</span> +<span id="2719">2719</span> +<span id="2720">2720</span> +<span id="2721">2721</span> +<span id="2722">2722</span> +<span id="2723">2723</span> +<span id="2724">2724</span> +<span id="2725">2725</span> +<span id="2726">2726</span> +<span id="2727">2727</span> +<span id="2728">2728</span> +<span id="2729">2729</span> +<span id="2730">2730</span> +<span id="2731">2731</span> +<span id="2732">2732</span> +<span id="2733">2733</span> +<span id="2734">2734</span> +<span id="2735">2735</span> +<span id="2736">2736</span> +<span id="2737">2737</span> +<span id="2738">2738</span> +<span id="2739">2739</span> +<span id="2740">2740</span> +<span id="2741">2741</span> +<span id="2742">2742</span> +<span id="2743">2743</span> +<span id="2744">2744</span> +<span id="2745">2745</span> +<span id="2746">2746</span> +<span id="2747">2747</span> +<span id="2748">2748</span> +<span id="2749">2749</span> +<span id="2750">2750</span> +<span id="2751">2751</span> +<span id="2752">2752</span> +<span id="2753">2753</span> +<span id="2754">2754</span> +<span id="2755">2755</span> +<span id="2756">2756</span> +<span id="2757">2757</span> +<span id="2758">2758</span> +<span id="2759">2759</span> +<span id="2760">2760</span> +<span id="2761">2761</span> +<span id="2762">2762</span> +<span id="2763">2763</span> +<span id="2764">2764</span> +<span id="2765">2765</span> +<span id="2766">2766</span> +<span id="2767">2767</span> +<span id="2768">2768</span> +<span id="2769">2769</span> +<span id="2770">2770</span> +<span id="2771">2771</span> +<span id="2772">2772</span> +<span id="2773">2773</span> +<span id="2774">2774</span> +<span id="2775">2775</span> +<span id="2776">2776</span> +<span id="2777">2777</span> +<span id="2778">2778</span> +<span id="2779">2779</span> +<span id="2780">2780</span> +<span id="2781">2781</span> +<span id="2782">2782</span> +<span id="2783">2783</span> +<span id="2784">2784</span> +<span id="2785">2785</span> +<span id="2786">2786</span> +<span id="2787">2787</span> +<span id="2788">2788</span> +<span id="2789">2789</span> +<span id="2790">2790</span> +<span id="2791">2791</span> +<span id="2792">2792</span> +<span id="2793">2793</span> +<span id="2794">2794</span> +<span id="2795">2795</span> +<span id="2796">2796</span> +<span id="2797">2797</span> +<span id="2798">2798</span> +<span id="2799">2799</span> +<span id="2800">2800</span> +<span id="2801">2801</span> +<span id="2802">2802</span> +<span id="2803">2803</span> +<span id="2804">2804</span> +<span id="2805">2805</span> +<span id="2806">2806</span> +<span id="2807">2807</span> +<span id="2808">2808</span> +<span id="2809">2809</span> +<span id="2810">2810</span> +<span id="2811">2811</span> +<span id="2812">2812</span> +<span id="2813">2813</span> +<span id="2814">2814</span> +<span id="2815">2815</span> +<span id="2816">2816</span> +<span id="2817">2817</span> +<span id="2818">2818</span> +<span id="2819">2819</span> +<span id="2820">2820</span> +<span id="2821">2821</span> +<span id="2822">2822</span> +<span id="2823">2823</span> +<span id="2824">2824</span> +<span id="2825">2825</span> +<span id="2826">2826</span> +<span id="2827">2827</span> +<span id="2828">2828</span> +<span id="2829">2829</span> +<span id="2830">2830</span> +<span id="2831">2831</span> +<span id="2832">2832</span> +<span id="2833">2833</span> +<span id="2834">2834</span> +<span id="2835">2835</span> +<span id="2836">2836</span> +<span id="2837">2837</span> +<span id="2838">2838</span> +<span id="2839">2839</span> +<span id="2840">2840</span> +<span id="2841">2841</span> +<span id="2842">2842</span> +<span id="2843">2843</span> +<span id="2844">2844</span> +<span id="2845">2845</span> +<span id="2846">2846</span> +<span id="2847">2847</span> +<span id="2848">2848</span> +<span id="2849">2849</span> +<span id="2850">2850</span> +<span id="2851">2851</span> +<span id="2852">2852</span> +<span id="2853">2853</span> +<span id="2854">2854</span> +<span id="2855">2855</span> +<span id="2856">2856</span> +<span id="2857">2857</span> +<span id="2858">2858</span> +<span id="2859">2859</span> +<span id="2860">2860</span> +<span id="2861">2861</span> +<span id="2862">2862</span> +<span id="2863">2863</span> +<span id="2864">2864</span> +<span id="2865">2865</span> +<span id="2866">2866</span> +<span id="2867">2867</span> +<span id="2868">2868</span> +<span id="2869">2869</span> +<span id="2870">2870</span> +<span id="2871">2871</span> +<span id="2872">2872</span> +<span id="2873">2873</span> +<span id="2874">2874</span> +<span id="2875">2875</span> +<span id="2876">2876</span> +<span id="2877">2877</span> +<span id="2878">2878</span> +<span id="2879">2879</span> +<span id="2880">2880</span> +<span id="2881">2881</span> +<span id="2882">2882</span> +<span id="2883">2883</span> +<span id="2884">2884</span> +<span id="2885">2885</span> +<span id="2886">2886</span> +<span id="2887">2887</span> +<span id="2888">2888</span> +<span id="2889">2889</span> +<span id="2890">2890</span> +<span id="2891">2891</span> +<span id="2892">2892</span> +<span id="2893">2893</span> +<span id="2894">2894</span> +<span id="2895">2895</span> +<span id="2896">2896</span> +<span id="2897">2897</span> +<span id="2898">2898</span> +<span id="2899">2899</span> +<span id="2900">2900</span> +<span id="2901">2901</span> +<span id="2902">2902</span> +<span id="2903">2903</span> +<span id="2904">2904</span> +<span id="2905">2905</span> +<span id="2906">2906</span> +<span id="2907">2907</span> +<span id="2908">2908</span> +<span id="2909">2909</span> +<span id="2910">2910</span> +<span id="2911">2911</span> +<span id="2912">2912</span> +<span id="2913">2913</span> +<span id="2914">2914</span> +<span id="2915">2915</span> +<span id="2916">2916</span> +<span id="2917">2917</span> +<span id="2918">2918</span> +<span id="2919">2919</span> +<span id="2920">2920</span> +<span id="2921">2921</span> +<span id="2922">2922</span> +<span id="2923">2923</span> +<span id="2924">2924</span> +<span id="2925">2925</span> +<span id="2926">2926</span> +<span id="2927">2927</span> +<span id="2928">2928</span> +<span id="2929">2929</span> +<span id="2930">2930</span> +<span id="2931">2931</span> +<span id="2932">2932</span> +<span id="2933">2933</span> +<span id="2934">2934</span> +<span id="2935">2935</span> +<span id="2936">2936</span> +<span id="2937">2937</span> +<span id="2938">2938</span> +<span id="2939">2939</span> +<span id="2940">2940</span> +<span id="2941">2941</span> +<span id="2942">2942</span> +<span id="2943">2943</span> +<span id="2944">2944</span> +<span id="2945">2945</span> +<span id="2946">2946</span> +<span id="2947">2947</span> +<span id="2948">2948</span> +<span id="2949">2949</span> +<span id="2950">2950</span> +<span id="2951">2951</span> +<span id="2952">2952</span> +<span id="2953">2953</span> +<span id="2954">2954</span> +<span id="2955">2955</span> +<span id="2956">2956</span> +<span id="2957">2957</span> +<span id="2958">2958</span> +<span id="2959">2959</span> +<span id="2960">2960</span> +<span id="2961">2961</span> +<span id="2962">2962</span> +<span id="2963">2963</span> +<span id="2964">2964</span> +<span id="2965">2965</span> +<span id="2966">2966</span> +<span id="2967">2967</span> +<span id="2968">2968</span> +<span id="2969">2969</span> +<span id="2970">2970</span> +<span id="2971">2971</span> +<span id="2972">2972</span> +<span id="2973">2973</span> +<span id="2974">2974</span> +<span id="2975">2975</span> +<span id="2976">2976</span> +<span id="2977">2977</span> +<span id="2978">2978</span> +<span id="2979">2979</span> +<span id="2980">2980</span> +<span id="2981">2981</span> +<span id="2982">2982</span> +<span id="2983">2983</span> +<span id="2984">2984</span> +<span id="2985">2985</span> +<span id="2986">2986</span> +<span id="2987">2987</span> +<span id="2988">2988</span> +<span id="2989">2989</span> +<span id="2990">2990</span> +<span id="2991">2991</span> +<span id="2992">2992</span> +<span id="2993">2993</span> +<span id="2994">2994</span> +<span id="2995">2995</span> +<span id="2996">2996</span> +<span id="2997">2997</span> +<span id="2998">2998</span> +<span id="2999">2999</span> +<span id="3000">3000</span> +<span id="3001">3001</span> +<span id="3002">3002</span> +<span id="3003">3003</span> +<span id="3004">3004</span> +<span id="3005">3005</span> +<span id="3006">3006</span> +<span id="3007">3007</span> +<span id="3008">3008</span> +<span id="3009">3009</span> +<span id="3010">3010</span> +<span id="3011">3011</span> +<span id="3012">3012</span> +<span id="3013">3013</span> +<span id="3014">3014</span> +<span id="3015">3015</span> +<span id="3016">3016</span> +<span id="3017">3017</span> +<span id="3018">3018</span> +<span id="3019">3019</span> +<span id="3020">3020</span> +<span id="3021">3021</span> +<span id="3022">3022</span> +<span id="3023">3023</span> +<span id="3024">3024</span> +<span id="3025">3025</span> +<span id="3026">3026</span> +<span id="3027">3027</span> +<span id="3028">3028</span> +<span id="3029">3029</span> +<span id="3030">3030</span> +<span id="3031">3031</span> +<span id="3032">3032</span> +<span id="3033">3033</span> +<span id="3034">3034</span> +<span id="3035">3035</span> +<span id="3036">3036</span> +<span id="3037">3037</span> +<span id="3038">3038</span> +<span id="3039">3039</span> +<span id="3040">3040</span> +<span id="3041">3041</span> +<span id="3042">3042</span> +<span id="3043">3043</span> +<span id="3044">3044</span> +<span id="3045">3045</span> +<span id="3046">3046</span> +<span id="3047">3047</span> +<span id="3048">3048</span> +<span id="3049">3049</span> +<span id="3050">3050</span> +<span id="3051">3051</span> +<span id="3052">3052</span> +<span id="3053">3053</span> +<span id="3054">3054</span> +<span id="3055">3055</span> +<span id="3056">3056</span> +<span id="3057">3057</span> +<span id="3058">3058</span> +<span id="3059">3059</span> +<span id="3060">3060</span> +<span id="3061">3061</span> +<span id="3062">3062</span> +<span id="3063">3063</span> +<span id="3064">3064</span> +<span id="3065">3065</span> +<span id="3066">3066</span> +<span id="3067">3067</span> +<span id="3068">3068</span> +<span id="3069">3069</span> +<span id="3070">3070</span> +<span id="3071">3071</span> +<span id="3072">3072</span> +<span id="3073">3073</span> +<span id="3074">3074</span> +<span id="3075">3075</span> +<span id="3076">3076</span> +<span id="3077">3077</span> +<span id="3078">3078</span> +<span id="3079">3079</span> +<span id="3080">3080</span> +<span id="3081">3081</span> +<span id="3082">3082</span> +<span id="3083">3083</span> +<span id="3084">3084</span> +<span id="3085">3085</span> +<span id="3086">3086</span> +<span id="3087">3087</span> +<span id="3088">3088</span> +<span id="3089">3089</span> +<span id="3090">3090</span> +<span id="3091">3091</span> +<span id="3092">3092</span> +<span id="3093">3093</span> +<span id="3094">3094</span> +<span id="3095">3095</span> +<span id="3096">3096</span> +<span id="3097">3097</span> +<span id="3098">3098</span> +<span id="3099">3099</span> +<span id="3100">3100</span> +<span id="3101">3101</span> +<span id="3102">3102</span> +<span id="3103">3103</span> +<span id="3104">3104</span> +<span id="3105">3105</span> +<span id="3106">3106</span> +<span id="3107">3107</span> +<span id="3108">3108</span> +<span id="3109">3109</span> +<span id="3110">3110</span> +<span id="3111">3111</span> +<span id="3112">3112</span> +<span id="3113">3113</span> +<span id="3114">3114</span> +<span id="3115">3115</span> +<span id="3116">3116</span> +<span id="3117">3117</span> +<span id="3118">3118</span> +<span id="3119">3119</span> +<span id="3120">3120</span> +<span id="3121">3121</span> +<span id="3122">3122</span> +<span id="3123">3123</span> +<span id="3124">3124</span> +<span id="3125">3125</span> +<span id="3126">3126</span> +<span id="3127">3127</span> +<span id="3128">3128</span> +<span id="3129">3129</span> +<span id="3130">3130</span> +<span id="3131">3131</span> +<span id="3132">3132</span> +<span id="3133">3133</span> +<span id="3134">3134</span> +<span id="3135">3135</span> +<span id="3136">3136</span> +<span id="3137">3137</span> +<span id="3138">3138</span> +<span id="3139">3139</span> +<span id="3140">3140</span> +<span id="3141">3141</span> +<span id="3142">3142</span> +<span id="3143">3143</span> +<span id="3144">3144</span> +<span id="3145">3145</span> +<span id="3146">3146</span> +<span id="3147">3147</span> +<span id="3148">3148</span> +<span id="3149">3149</span> +<span id="3150">3150</span> +<span id="3151">3151</span> +<span id="3152">3152</span> +<span id="3153">3153</span> +<span id="3154">3154</span> +<span id="3155">3155</span> +<span id="3156">3156</span> +<span id="3157">3157</span> +<span id="3158">3158</span> +<span id="3159">3159</span> +<span id="3160">3160</span> +<span id="3161">3161</span> +<span id="3162">3162</span> +<span id="3163">3163</span> +<span id="3164">3164</span> +<span id="3165">3165</span> +<span id="3166">3166</span> +<span id="3167">3167</span> +<span id="3168">3168</span> +<span id="3169">3169</span> +<span id="3170">3170</span> +<span id="3171">3171</span> +<span id="3172">3172</span> +<span id="3173">3173</span> +<span id="3174">3174</span> +<span id="3175">3175</span> +<span id="3176">3176</span> +<span id="3177">3177</span> +<span id="3178">3178</span> +<span id="3179">3179</span> +<span id="3180">3180</span> +<span id="3181">3181</span> +<span id="3182">3182</span> +<span id="3183">3183</span> +<span id="3184">3184</span> +<span id="3185">3185</span> +<span id="3186">3186</span> +<span id="3187">3187</span> +<span id="3188">3188</span> +<span id="3189">3189</span> +<span id="3190">3190</span> +<span id="3191">3191</span> +<span id="3192">3192</span> +<span id="3193">3193</span> +<span id="3194">3194</span> +<span id="3195">3195</span> +<span id="3196">3196</span> +<span id="3197">3197</span> +<span id="3198">3198</span> +<span id="3199">3199</span> +<span id="3200">3200</span> +<span id="3201">3201</span> +<span id="3202">3202</span> +<span id="3203">3203</span> +<span id="3204">3204</span> +<span id="3205">3205</span> +<span id="3206">3206</span> +<span id="3207">3207</span> +<span id="3208">3208</span> +<span id="3209">3209</span> +<span id="3210">3210</span> +<span id="3211">3211</span> +<span id="3212">3212</span> +<span id="3213">3213</span> +<span id="3214">3214</span> +<span id="3215">3215</span> +<span id="3216">3216</span> +<span id="3217">3217</span> +<span id="3218">3218</span> +<span id="3219">3219</span> +<span id="3220">3220</span> +<span id="3221">3221</span> +<span id="3222">3222</span> +<span id="3223">3223</span> +<span id="3224">3224</span> +<span id="3225">3225</span> +<span id="3226">3226</span> +<span id="3227">3227</span> +<span id="3228">3228</span> +<span id="3229">3229</span> +<span id="3230">3230</span> +<span id="3231">3231</span> +<span id="3232">3232</span> +<span id="3233">3233</span> +<span id="3234">3234</span> +<span id="3235">3235</span> +<span id="3236">3236</span> +<span id="3237">3237</span> +<span id="3238">3238</span> +<span id="3239">3239</span> +<span id="3240">3240</span> +<span id="3241">3241</span> +<span id="3242">3242</span> +<span id="3243">3243</span> +<span id="3244">3244</span> +<span id="3245">3245</span> +<span id="3246">3246</span> +<span id="3247">3247</span> +<span id="3248">3248</span> +<span id="3249">3249</span> +<span id="3250">3250</span> +<span id="3251">3251</span> +<span id="3252">3252</span> +<span id="3253">3253</span> +<span id="3254">3254</span> +<span id="3255">3255</span> +<span id="3256">3256</span> +<span id="3257">3257</span> +<span id="3258">3258</span> +<span id="3259">3259</span> +<span id="3260">3260</span> +<span id="3261">3261</span> +<span id="3262">3262</span> +<span id="3263">3263</span> +<span id="3264">3264</span> +<span id="3265">3265</span> +<span id="3266">3266</span> +<span id="3267">3267</span> +<span id="3268">3268</span> +<span id="3269">3269</span> +<span id="3270">3270</span> +<span id="3271">3271</span> +<span id="3272">3272</span> +<span id="3273">3273</span> +<span id="3274">3274</span> +<span id="3275">3275</span> +<span id="3276">3276</span> +<span id="3277">3277</span> +<span id="3278">3278</span> +<span id="3279">3279</span> +<span id="3280">3280</span> +<span id="3281">3281</span> +<span id="3282">3282</span> +<span id="3283">3283</span> +<span id="3284">3284</span> +<span id="3285">3285</span> +<span id="3286">3286</span> +<span id="3287">3287</span> +<span id="3288">3288</span> +<span id="3289">3289</span> +<span id="3290">3290</span> +<span id="3291">3291</span> +<span id="3292">3292</span> +<span id="3293">3293</span> +<span id="3294">3294</span> +<span id="3295">3295</span> +<span id="3296">3296</span> +<span id="3297">3297</span> +<span id="3298">3298</span> +<span id="3299">3299</span> +<span id="3300">3300</span> +<span id="3301">3301</span> +<span id="3302">3302</span> +<span id="3303">3303</span> +<span id="3304">3304</span> +<span id="3305">3305</span> +<span id="3306">3306</span> +<span id="3307">3307</span> +<span id="3308">3308</span> +<span id="3309">3309</span> +<span id="3310">3310</span> +<span id="3311">3311</span> +<span id="3312">3312</span> +<span id="3313">3313</span> +<span id="3314">3314</span> +<span id="3315">3315</span> +<span id="3316">3316</span> +<span id="3317">3317</span> +<span id="3318">3318</span> +<span id="3319">3319</span> +<span id="3320">3320</span> +<span id="3321">3321</span> +<span id="3322">3322</span> +<span id="3323">3323</span> +<span id="3324">3324</span> +<span id="3325">3325</span> +<span id="3326">3326</span> +<span id="3327">3327</span> +<span id="3328">3328</span> +<span id="3329">3329</span> +<span id="3330">3330</span> +<span id="3331">3331</span> +<span id="3332">3332</span> +<span id="3333">3333</span> +<span id="3334">3334</span> +<span id="3335">3335</span> +<span id="3336">3336</span> +<span id="3337">3337</span> +<span id="3338">3338</span> +<span id="3339">3339</span> +<span id="3340">3340</span> +<span id="3341">3341</span> +<span id="3342">3342</span> +<span id="3343">3343</span> +<span id="3344">3344</span> +<span id="3345">3345</span> +<span id="3346">3346</span> +<span id="3347">3347</span> +<span id="3348">3348</span> +<span id="3349">3349</span> +<span id="3350">3350</span> +<span id="3351">3351</span> +<span id="3352">3352</span> +<span id="3353">3353</span> +<span id="3354">3354</span> +<span id="3355">3355</span> +<span id="3356">3356</span> +<span id="3357">3357</span> +<span id="3358">3358</span> +<span id="3359">3359</span> +<span id="3360">3360</span> +<span id="3361">3361</span> +<span id="3362">3362</span> +<span id="3363">3363</span> +<span id="3364">3364</span> +<span id="3365">3365</span> +<span id="3366">3366</span> +<span id="3367">3367</span> +<span id="3368">3368</span> +<span id="3369">3369</span> +<span id="3370">3370</span> +<span id="3371">3371</span> +<span id="3372">3372</span> +<span id="3373">3373</span> +<span id="3374">3374</span> +<span id="3375">3375</span> +<span id="3376">3376</span> +<span id="3377">3377</span> +<span id="3378">3378</span> +<span id="3379">3379</span> +<span id="3380">3380</span> +<span id="3381">3381</span> +<span id="3382">3382</span> +<span id="3383">3383</span> +<span id="3384">3384</span> +<span id="3385">3385</span> +<span id="3386">3386</span> +<span id="3387">3387</span> +<span id="3388">3388</span> +<span id="3389">3389</span> +<span id="3390">3390</span> +<span id="3391">3391</span> +<span id="3392">3392</span> +<span id="3393">3393</span> +<span id="3394">3394</span> +<span id="3395">3395</span> +<span id="3396">3396</span> +<span id="3397">3397</span> +<span id="3398">3398</span> +<span id="3399">3399</span> +<span id="3400">3400</span> +<span id="3401">3401</span> +<span id="3402">3402</span> +<span id="3403">3403</span> +<span id="3404">3404</span> +<span id="3405">3405</span> +<span id="3406">3406</span> +<span id="3407">3407</span> +<span id="3408">3408</span> +<span id="3409">3409</span> +<span id="3410">3410</span> +<span id="3411">3411</span> +<span id="3412">3412</span> +<span id="3413">3413</span> +<span id="3414">3414</span> +<span id="3415">3415</span> +<span id="3416">3416</span> +<span id="3417">3417</span> +<span id="3418">3418</span> +<span id="3419">3419</span> +<span id="3420">3420</span> +<span id="3421">3421</span> +<span id="3422">3422</span> +<span id="3423">3423</span> +<span id="3424">3424</span> +<span id="3425">3425</span> +<span id="3426">3426</span> +<span id="3427">3427</span> +<span id="3428">3428</span> +<span id="3429">3429</span> +<span id="3430">3430</span> +<span id="3431">3431</span> +<span id="3432">3432</span> +<span id="3433">3433</span> +<span id="3434">3434</span> +<span id="3435">3435</span> +<span id="3436">3436</span> +<span id="3437">3437</span> +<span id="3438">3438</span> +<span id="3439">3439</span> +<span id="3440">3440</span> +<span id="3441">3441</span> +<span id="3442">3442</span> +<span id="3443">3443</span> +<span id="3444">3444</span> +<span id="3445">3445</span> +<span id="3446">3446</span> +<span id="3447">3447</span> +<span id="3448">3448</span> +<span id="3449">3449</span> +<span id="3450">3450</span> +<span id="3451">3451</span> +<span id="3452">3452</span> +<span id="3453">3453</span> +<span id="3454">3454</span> +<span id="3455">3455</span> +<span id="3456">3456</span> +<span id="3457">3457</span> +<span id="3458">3458</span> +<span id="3459">3459</span> +<span id="3460">3460</span> +<span id="3461">3461</span> +<span id="3462">3462</span> +<span id="3463">3463</span> +<span id="3464">3464</span> +<span id="3465">3465</span> +<span id="3466">3466</span> +<span id="3467">3467</span> +<span id="3468">3468</span> +<span id="3469">3469</span> +<span id="3470">3470</span> +<span id="3471">3471</span> +<span id="3472">3472</span> +<span id="3473">3473</span> +<span id="3474">3474</span> +<span id="3475">3475</span> +<span id="3476">3476</span> +<span id="3477">3477</span> +<span id="3478">3478</span> +<span id="3479">3479</span> +<span id="3480">3480</span> +<span id="3481">3481</span> +<span id="3482">3482</span> +<span id="3483">3483</span> +<span id="3484">3484</span> +<span id="3485">3485</span> +<span id="3486">3486</span> +<span id="3487">3487</span> +<span id="3488">3488</span> +<span id="3489">3489</span> +<span id="3490">3490</span> +<span id="3491">3491</span> +<span id="3492">3492</span> +<span id="3493">3493</span> +<span id="3494">3494</span> +<span id="3495">3495</span> +<span id="3496">3496</span> +<span id="3497">3497</span> +<span id="3498">3498</span> +<span id="3499">3499</span> +<span id="3500">3500</span> +<span id="3501">3501</span> +<span id="3502">3502</span> +<span id="3503">3503</span> +<span id="3504">3504</span> +<span id="3505">3505</span> +<span id="3506">3506</span> +<span id="3507">3507</span> +<span id="3508">3508</span> +<span id="3509">3509</span> +<span id="3510">3510</span> +<span id="3511">3511</span> +<span id="3512">3512</span> +<span id="3513">3513</span> +<span id="3514">3514</span> +<span id="3515">3515</span> +<span id="3516">3516</span> +<span id="3517">3517</span> +<span id="3518">3518</span> +<span id="3519">3519</span> +<span id="3520">3520</span> +<span id="3521">3521</span> +<span id="3522">3522</span> +<span id="3523">3523</span> +<span id="3524">3524</span> +<span id="3525">3525</span> +<span id="3526">3526</span> +<span id="3527">3527</span> +<span id="3528">3528</span> +<span id="3529">3529</span> +<span id="3530">3530</span> +<span id="3531">3531</span> +<span id="3532">3532</span> +<span id="3533">3533</span> +<span id="3534">3534</span> +<span id="3535">3535</span> +<span id="3536">3536</span> +<span id="3537">3537</span> +<span id="3538">3538</span> +<span id="3539">3539</span> +<span id="3540">3540</span> +<span id="3541">3541</span> +<span id="3542">3542</span> +<span id="3543">3543</span> +<span id="3544">3544</span> +<span id="3545">3545</span> +<span id="3546">3546</span> +<span id="3547">3547</span> +<span id="3548">3548</span> +<span id="3549">3549</span> +<span id="3550">3550</span> +<span id="3551">3551</span> +<span id="3552">3552</span> +<span id="3553">3553</span> +<span id="3554">3554</span> +<span id="3555">3555</span> +<span id="3556">3556</span> +<span id="3557">3557</span> +<span id="3558">3558</span> +<span id="3559">3559</span> +<span id="3560">3560</span> +<span id="3561">3561</span> +<span id="3562">3562</span> +<span id="3563">3563</span> +<span id="3564">3564</span> +<span id="3565">3565</span> +<span id="3566">3566</span> +<span id="3567">3567</span> +<span id="3568">3568</span> +<span id="3569">3569</span> +<span id="3570">3570</span> +<span id="3571">3571</span> +<span id="3572">3572</span> +<span id="3573">3573</span> +<span id="3574">3574</span> +<span id="3575">3575</span> +<span id="3576">3576</span> +<span id="3577">3577</span> +<span id="3578">3578</span> +<span id="3579">3579</span> +<span id="3580">3580</span> +<span id="3581">3581</span> +<span id="3582">3582</span> +<span id="3583">3583</span> +<span id="3584">3584</span> +<span id="3585">3585</span> +<span id="3586">3586</span> +<span id="3587">3587</span> +<span id="3588">3588</span> +<span id="3589">3589</span> +<span id="3590">3590</span> +<span id="3591">3591</span> +<span id="3592">3592</span> +<span id="3593">3593</span> +<span id="3594">3594</span> +<span id="3595">3595</span> +<span id="3596">3596</span> +<span id="3597">3597</span> +<span id="3598">3598</span> +<span id="3599">3599</span> +<span id="3600">3600</span> +<span id="3601">3601</span> +<span id="3602">3602</span> +<span id="3603">3603</span> +<span id="3604">3604</span> +<span id="3605">3605</span> +<span id="3606">3606</span> +<span id="3607">3607</span> +<span id="3608">3608</span> +<span id="3609">3609</span> +<span id="3610">3610</span> +<span id="3611">3611</span> +<span id="3612">3612</span> +<span id="3613">3613</span> +<span id="3614">3614</span> +<span id="3615">3615</span> +<span id="3616">3616</span> +<span id="3617">3617</span> +<span id="3618">3618</span> +<span id="3619">3619</span> +<span id="3620">3620</span> +<span id="3621">3621</span> +<span id="3622">3622</span> +<span id="3623">3623</span> +<span id="3624">3624</span> +<span id="3625">3625</span> +<span id="3626">3626</span> +<span id="3627">3627</span> +<span id="3628">3628</span> +<span id="3629">3629</span> +<span id="3630">3630</span> +<span id="3631">3631</span> +<span id="3632">3632</span> +<span id="3633">3633</span> +<span id="3634">3634</span> +<span id="3635">3635</span> +<span id="3636">3636</span> +<span id="3637">3637</span> +<span id="3638">3638</span> +<span id="3639">3639</span> +<span id="3640">3640</span> +<span id="3641">3641</span> +<span id="3642">3642</span> +<span id="3643">3643</span> +<span id="3644">3644</span> +<span id="3645">3645</span> +<span id="3646">3646</span> +<span id="3647">3647</span> +<span id="3648">3648</span> +<span id="3649">3649</span> +<span id="3650">3650</span> +<span id="3651">3651</span> +<span id="3652">3652</span> +<span id="3653">3653</span> +<span id="3654">3654</span> +<span id="3655">3655</span> +<span id="3656">3656</span> +<span id="3657">3657</span> +<span id="3658">3658</span> +<span id="3659">3659</span> +<span id="3660">3660</span> +<span id="3661">3661</span> +<span id="3662">3662</span> +<span id="3663">3663</span> +<span id="3664">3664</span> +<span id="3665">3665</span> +<span id="3666">3666</span> +<span id="3667">3667</span> +<span id="3668">3668</span> +<span id="3669">3669</span> +<span id="3670">3670</span> +<span id="3671">3671</span> +<span id="3672">3672</span> +<span id="3673">3673</span> +<span id="3674">3674</span> +<span id="3675">3675</span> +<span id="3676">3676</span> +<span id="3677">3677</span> +<span id="3678">3678</span> +<span id="3679">3679</span> +<span id="3680">3680</span> +<span id="3681">3681</span> +<span id="3682">3682</span> +<span id="3683">3683</span> +<span id="3684">3684</span> +<span id="3685">3685</span> +<span id="3686">3686</span> +<span id="3687">3687</span> +<span id="3688">3688</span> +<span id="3689">3689</span> +<span id="3690">3690</span> +<span id="3691">3691</span> +<span id="3692">3692</span> +<span id="3693">3693</span> +<span id="3694">3694</span> +<span id="3695">3695</span> +<span id="3696">3696</span> +<span id="3697">3697</span> +<span id="3698">3698</span> +<span id="3699">3699</span> +<span id="3700">3700</span> +<span id="3701">3701</span> +<span id="3702">3702</span> +<span id="3703">3703</span> +<span id="3704">3704</span> +<span id="3705">3705</span> +<span id="3706">3706</span> +<span id="3707">3707</span> +<span id="3708">3708</span> +<span id="3709">3709</span> +<span id="3710">3710</span> +<span id="3711">3711</span> +<span id="3712">3712</span> +<span id="3713">3713</span> +<span id="3714">3714</span> +<span id="3715">3715</span> +<span id="3716">3716</span> +<span id="3717">3717</span> +<span id="3718">3718</span> +<span id="3719">3719</span> +<span id="3720">3720</span> +<span id="3721">3721</span> +<span id="3722">3722</span> +<span id="3723">3723</span> +<span id="3724">3724</span> +<span id="3725">3725</span> +<span id="3726">3726</span> +<span id="3727">3727</span> +<span id="3728">3728</span> +<span id="3729">3729</span> +<span id="3730">3730</span> +<span id="3731">3731</span> +<span id="3732">3732</span> +<span id="3733">3733</span> +<span id="3734">3734</span> +<span id="3735">3735</span> +<span id="3736">3736</span> +<span id="3737">3737</span> +<span id="3738">3738</span> +<span id="3739">3739</span> +<span id="3740">3740</span> +<span id="3741">3741</span> +<span id="3742">3742</span> +<span id="3743">3743</span> +<span id="3744">3744</span> +<span id="3745">3745</span> +<span id="3746">3746</span> +<span id="3747">3747</span> +<span id="3748">3748</span> +<span id="3749">3749</span> +<span id="3750">3750</span> +<span id="3751">3751</span> +<span id="3752">3752</span> +<span id="3753">3753</span> +<span id="3754">3754</span> +<span id="3755">3755</span> +<span id="3756">3756</span> +<span id="3757">3757</span> +<span id="3758">3758</span> +<span id="3759">3759</span> +<span id="3760">3760</span> +<span id="3761">3761</span> +<span id="3762">3762</span> +<span id="3763">3763</span> +<span id="3764">3764</span> +<span id="3765">3765</span> +<span id="3766">3766</span> +<span id="3767">3767</span> +<span id="3768">3768</span> +<span id="3769">3769</span> +<span id="3770">3770</span> +<span id="3771">3771</span> +<span id="3772">3772</span> +<span id="3773">3773</span> +<span id="3774">3774</span> +<span id="3775">3775</span> +<span id="3776">3776</span> +<span id="3777">3777</span> +<span id="3778">3778</span> +<span id="3779">3779</span> +<span id="3780">3780</span> +<span id="3781">3781</span> +<span id="3782">3782</span> +<span id="3783">3783</span> +<span id="3784">3784</span> +<span id="3785">3785</span> +<span id="3786">3786</span> +<span id="3787">3787</span> +<span id="3788">3788</span> +<span id="3789">3789</span> +<span id="3790">3790</span> +<span id="3791">3791</span> +<span id="3792">3792</span> +<span id="3793">3793</span> +<span id="3794">3794</span> +<span id="3795">3795</span> +<span id="3796">3796</span> +<span id="3797">3797</span> +<span id="3798">3798</span> +<span id="3799">3799</span> +<span id="3800">3800</span> +<span id="3801">3801</span> +<span id="3802">3802</span> +<span id="3803">3803</span> +<span id="3804">3804</span> +<span id="3805">3805</span> +<span id="3806">3806</span> +<span id="3807">3807</span> +<span id="3808">3808</span> +<span id="3809">3809</span> +<span id="3810">3810</span> +<span id="3811">3811</span> +<span id="3812">3812</span> +<span id="3813">3813</span> +<span id="3814">3814</span> +<span id="3815">3815</span> +<span id="3816">3816</span> +<span id="3817">3817</span> +<span id="3818">3818</span> +<span id="3819">3819</span> +<span id="3820">3820</span> +<span id="3821">3821</span> +<span id="3822">3822</span> +<span id="3823">3823</span> +<span id="3824">3824</span> +<span id="3825">3825</span> +<span id="3826">3826</span> +<span id="3827">3827</span> +<span id="3828">3828</span> +<span id="3829">3829</span> +<span id="3830">3830</span> +<span id="3831">3831</span> +<span id="3832">3832</span> +<span id="3833">3833</span> +<span id="3834">3834</span> +<span id="3835">3835</span> +<span id="3836">3836</span> +<span id="3837">3837</span> +<span id="3838">3838</span> +<span id="3839">3839</span> +<span id="3840">3840</span> +<span id="3841">3841</span> +<span id="3842">3842</span> +<span id="3843">3843</span> +<span id="3844">3844</span> +<span id="3845">3845</span> +<span id="3846">3846</span> +<span id="3847">3847</span> +<span id="3848">3848</span> +<span id="3849">3849</span> +<span id="3850">3850</span> +<span id="3851">3851</span> +<span id="3852">3852</span> +<span id="3853">3853</span> +<span id="3854">3854</span> +<span id="3855">3855</span> +<span id="3856">3856</span> +<span id="3857">3857</span> +<span id="3858">3858</span> +<span id="3859">3859</span> +<span id="3860">3860</span> +<span id="3861">3861</span> +<span id="3862">3862</span> +<span id="3863">3863</span> +<span id="3864">3864</span> +<span id="3865">3865</span> +<span id="3866">3866</span> +<span id="3867">3867</span> +<span id="3868">3868</span> +<span id="3869">3869</span> +<span id="3870">3870</span> +<span id="3871">3871</span> +<span id="3872">3872</span> +<span id="3873">3873</span> +<span id="3874">3874</span> +<span id="3875">3875</span> +<span id="3876">3876</span> +<span id="3877">3877</span> +<span id="3878">3878</span> +<span id="3879">3879</span> +<span id="3880">3880</span> +<span id="3881">3881</span> +<span id="3882">3882</span> +<span id="3883">3883</span> +<span id="3884">3884</span> +<span id="3885">3885</span> +<span id="3886">3886</span> +<span id="3887">3887</span> +<span id="3888">3888</span> +<span id="3889">3889</span> +<span id="3890">3890</span> +<span id="3891">3891</span> +<span id="3892">3892</span> +<span id="3893">3893</span> +<span id="3894">3894</span> +<span id="3895">3895</span> +<span id="3896">3896</span> +<span id="3897">3897</span> +<span id="3898">3898</span> +<span id="3899">3899</span> +<span id="3900">3900</span> +<span id="3901">3901</span> +<span id="3902">3902</span> +<span id="3903">3903</span> +<span id="3904">3904</span> +<span id="3905">3905</span> +<span id="3906">3906</span> +<span id="3907">3907</span> +<span id="3908">3908</span> +<span id="3909">3909</span> +<span id="3910">3910</span> +<span id="3911">3911</span> +<span id="3912">3912</span> +<span id="3913">3913</span> +<span id="3914">3914</span> +<span id="3915">3915</span> +<span id="3916">3916</span> +<span id="3917">3917</span> +<span id="3918">3918</span> +<span id="3919">3919</span> +<span id="3920">3920</span> +<span id="3921">3921</span> +<span id="3922">3922</span> +<span id="3923">3923</span> +<span id="3924">3924</span> +<span id="3925">3925</span> +<span id="3926">3926</span> +<span id="3927">3927</span> +<span id="3928">3928</span> +<span id="3929">3929</span> +<span id="3930">3930</span> +<span id="3931">3931</span> +<span id="3932">3932</span> +<span id="3933">3933</span> +<span id="3934">3934</span> +<span id="3935">3935</span> +<span id="3936">3936</span> +<span id="3937">3937</span> +<span id="3938">3938</span> +<span id="3939">3939</span> +<span id="3940">3940</span> +<span id="3941">3941</span> +<span id="3942">3942</span> +<span id="3943">3943</span> +<span id="3944">3944</span> +<span id="3945">3945</span> +<span id="3946">3946</span> +<span id="3947">3947</span> +<span id="3948">3948</span> +<span id="3949">3949</span> +<span id="3950">3950</span> +<span id="3951">3951</span> +<span id="3952">3952</span> +<span id="3953">3953</span> +<span id="3954">3954</span> +<span id="3955">3955</span> +<span id="3956">3956</span> +<span id="3957">3957</span> +<span id="3958">3958</span> +<span id="3959">3959</span> +<span id="3960">3960</span> +<span id="3961">3961</span> +<span id="3962">3962</span> +<span id="3963">3963</span> +<span id="3964">3964</span> +<span id="3965">3965</span> +<span id="3966">3966</span> +<span id="3967">3967</span> +<span id="3968">3968</span> +<span id="3969">3969</span> +<span id="3970">3970</span> +<span id="3971">3971</span> +<span id="3972">3972</span> +<span id="3973">3973</span> +<span id="3974">3974</span> +<span id="3975">3975</span> +<span id="3976">3976</span> +<span id="3977">3977</span> +<span id="3978">3978</span> +<span id="3979">3979</span> +<span id="3980">3980</span> +<span id="3981">3981</span> +<span id="3982">3982</span> +<span id="3983">3983</span> +<span id="3984">3984</span> +<span id="3985">3985</span> +<span id="3986">3986</span> +<span id="3987">3987</span> +<span id="3988">3988</span> +<span id="3989">3989</span> +<span id="3990">3990</span> +<span id="3991">3991</span> +<span id="3992">3992</span> +<span id="3993">3993</span> +<span id="3994">3994</span> +<span id="3995">3995</span> +<span id="3996">3996</span> +<span id="3997">3997</span> +<span id="3998">3998</span> +<span id="3999">3999</span> +<span id="4000">4000</span> +<span id="4001">4001</span> +<span id="4002">4002</span> +<span id="4003">4003</span> +<span id="4004">4004</span> +<span id="4005">4005</span> +<span id="4006">4006</span> +<span id="4007">4007</span> +<span id="4008">4008</span> +<span id="4009">4009</span> +<span id="4010">4010</span> +<span id="4011">4011</span> +<span id="4012">4012</span> +<span id="4013">4013</span> +<span id="4014">4014</span> +<span id="4015">4015</span> +<span id="4016">4016</span> +<span id="4017">4017</span> +<span id="4018">4018</span> +<span id="4019">4019</span> +<span id="4020">4020</span> +<span id="4021">4021</span> +<span id="4022">4022</span> +<span id="4023">4023</span> +<span id="4024">4024</span> +<span id="4025">4025</span> +<span id="4026">4026</span> +<span id="4027">4027</span> +<span id="4028">4028</span> +<span id="4029">4029</span> +<span id="4030">4030</span> +<span id="4031">4031</span> +<span id="4032">4032</span> +<span id="4033">4033</span> +<span id="4034">4034</span> +<span id="4035">4035</span> +<span id="4036">4036</span> +<span id="4037">4037</span> +<span id="4038">4038</span> +<span id="4039">4039</span> +<span id="4040">4040</span> +<span id="4041">4041</span> +<span id="4042">4042</span> +<span id="4043">4043</span> +<span id="4044">4044</span> +<span id="4045">4045</span> +<span id="4046">4046</span> +<span id="4047">4047</span> +<span id="4048">4048</span> +<span id="4049">4049</span> +<span id="4050">4050</span> +<span id="4051">4051</span> +<span id="4052">4052</span> +<span id="4053">4053</span> +<span id="4054">4054</span> +<span id="4055">4055</span> +<span id="4056">4056</span> +<span id="4057">4057</span> +<span id="4058">4058</span> +<span id="4059">4059</span> +<span id="4060">4060</span> +<span id="4061">4061</span> +<span id="4062">4062</span> +<span id="4063">4063</span> +<span id="4064">4064</span> +<span id="4065">4065</span> +<span id="4066">4066</span> +<span id="4067">4067</span> +<span id="4068">4068</span> +<span id="4069">4069</span> +<span id="4070">4070</span> +<span id="4071">4071</span> +<span id="4072">4072</span> +<span id="4073">4073</span> +<span id="4074">4074</span> +<span id="4075">4075</span> +<span id="4076">4076</span> +<span id="4077">4077</span> +<span id="4078">4078</span> +<span id="4079">4079</span> +<span id="4080">4080</span> +<span id="4081">4081</span> +<span id="4082">4082</span> +<span id="4083">4083</span> +<span id="4084">4084</span> +<span id="4085">4085</span> +<span id="4086">4086</span> +<span id="4087">4087</span> +<span id="4088">4088</span> +<span id="4089">4089</span> +<span id="4090">4090</span> +<span id="4091">4091</span> +<span id="4092">4092</span> +<span id="4093">4093</span> +<span id="4094">4094</span> +<span id="4095">4095</span> +<span id="4096">4096</span> +<span id="4097">4097</span> +<span id="4098">4098</span> +<span id="4099">4099</span> +<span id="4100">4100</span> +<span id="4101">4101</span> +<span id="4102">4102</span> +<span id="4103">4103</span> +<span id="4104">4104</span> +<span id="4105">4105</span> +<span id="4106">4106</span> +<span id="4107">4107</span> +<span id="4108">4108</span> +<span id="4109">4109</span> +<span id="4110">4110</span> +<span id="4111">4111</span> +<span id="4112">4112</span> +<span id="4113">4113</span> +<span id="4114">4114</span> +<span id="4115">4115</span> +<span id="4116">4116</span> +<span id="4117">4117</span> +<span id="4118">4118</span> +<span id="4119">4119</span> +<span id="4120">4120</span> +<span id="4121">4121</span> +<span id="4122">4122</span> +<span id="4123">4123</span> +<span id="4124">4124</span> +<span id="4125">4125</span> +<span id="4126">4126</span> +<span id="4127">4127</span> +<span id="4128">4128</span> +<span id="4129">4129</span> +<span id="4130">4130</span> +<span id="4131">4131</span> +<span id="4132">4132</span> +<span id="4133">4133</span> +<span id="4134">4134</span> +<span id="4135">4135</span> +<span id="4136">4136</span> +<span id="4137">4137</span> +<span id="4138">4138</span> +<span id="4139">4139</span> +<span id="4140">4140</span> +<span id="4141">4141</span> +<span id="4142">4142</span> +<span id="4143">4143</span> +<span id="4144">4144</span> +<span id="4145">4145</span> +<span id="4146">4146</span> +<span id="4147">4147</span> +<span id="4148">4148</span> +<span id="4149">4149</span> +<span id="4150">4150</span> +<span id="4151">4151</span> +<span id="4152">4152</span> +<span id="4153">4153</span> +<span id="4154">4154</span> +<span id="4155">4155</span> +<span id="4156">4156</span> +<span id="4157">4157</span> +<span id="4158">4158</span> +<span id="4159">4159</span> +<span id="4160">4160</span> +<span id="4161">4161</span> +<span id="4162">4162</span> +<span id="4163">4163</span> +<span id="4164">4164</span> +<span id="4165">4165</span> +<span id="4166">4166</span> +<span id="4167">4167</span> +<span id="4168">4168</span> +<span id="4169">4169</span> +<span id="4170">4170</span> +<span id="4171">4171</span> +<span id="4172">4172</span> +<span id="4173">4173</span> +<span id="4174">4174</span> +<span id="4175">4175</span> +<span id="4176">4176</span> +<span id="4177">4177</span> +<span id="4178">4178</span> +<span id="4179">4179</span> +<span id="4180">4180</span> +<span id="4181">4181</span> +<span id="4182">4182</span> +<span id="4183">4183</span> +<span id="4184">4184</span> +<span id="4185">4185</span> +<span id="4186">4186</span> +<span id="4187">4187</span> +<span id="4188">4188</span> +<span id="4189">4189</span> +<span id="4190">4190</span> +<span id="4191">4191</span> +<span id="4192">4192</span> +<span id="4193">4193</span> +<span id="4194">4194</span> +<span id="4195">4195</span> +<span id="4196">4196</span> +<span id="4197">4197</span> +<span id="4198">4198</span> +<span id="4199">4199</span> +<span id="4200">4200</span> +<span id="4201">4201</span> +<span id="4202">4202</span> +<span id="4203">4203</span> +<span id="4204">4204</span> +<span id="4205">4205</span> +<span id="4206">4206</span> +<span id="4207">4207</span> +<span id="4208">4208</span> +<span id="4209">4209</span> +<span id="4210">4210</span> +<span id="4211">4211</span> +<span id="4212">4212</span> +<span id="4213">4213</span> +<span id="4214">4214</span> +<span id="4215">4215</span> +<span id="4216">4216</span> +<span id="4217">4217</span> +<span id="4218">4218</span> +<span id="4219">4219</span> +<span id="4220">4220</span> +<span id="4221">4221</span> +<span id="4222">4222</span> +<span id="4223">4223</span> +<span id="4224">4224</span> +<span id="4225">4225</span> +<span id="4226">4226</span> +<span id="4227">4227</span> +<span id="4228">4228</span> +<span id="4229">4229</span> +<span id="4230">4230</span> +<span id="4231">4231</span> +<span id="4232">4232</span> +<span id="4233">4233</span> +<span id="4234">4234</span> +<span id="4235">4235</span> +<span id="4236">4236</span> +<span id="4237">4237</span> +<span id="4238">4238</span> +<span id="4239">4239</span> +<span id="4240">4240</span> +<span id="4241">4241</span> +<span id="4242">4242</span> +<span id="4243">4243</span> +<span id="4244">4244</span> +<span id="4245">4245</span> +<span id="4246">4246</span> +<span id="4247">4247</span> +<span id="4248">4248</span> +<span id="4249">4249</span> +<span id="4250">4250</span> +<span id="4251">4251</span> +<span id="4252">4252</span> +<span id="4253">4253</span> +<span id="4254">4254</span> +<span id="4255">4255</span> +<span id="4256">4256</span> +<span id="4257">4257</span> +<span id="4258">4258</span> +<span id="4259">4259</span> +<span id="4260">4260</span> +<span id="4261">4261</span> +<span id="4262">4262</span> +<span id="4263">4263</span> +<span id="4264">4264</span> +<span id="4265">4265</span> +<span id="4266">4266</span> +<span id="4267">4267</span> +<span id="4268">4268</span> +<span id="4269">4269</span> +<span id="4270">4270</span> +<span id="4271">4271</span> +<span id="4272">4272</span> +<span id="4273">4273</span> +<span id="4274">4274</span> +<span id="4275">4275</span> +<span id="4276">4276</span> +<span id="4277">4277</span> +<span id="4278">4278</span> +<span id="4279">4279</span> +<span id="4280">4280</span> +<span id="4281">4281</span> +<span id="4282">4282</span> +<span id="4283">4283</span> +<span id="4284">4284</span> +<span id="4285">4285</span> +<span id="4286">4286</span> +<span id="4287">4287</span> +<span id="4288">4288</span> +<span id="4289">4289</span> +<span id="4290">4290</span> +<span id="4291">4291</span> +<span id="4292">4292</span> +<span id="4293">4293</span> +<span id="4294">4294</span> +<span id="4295">4295</span> +<span id="4296">4296</span> +<span id="4297">4297</span> +<span id="4298">4298</span> +<span id="4299">4299</span> +<span id="4300">4300</span> +<span id="4301">4301</span> +<span id="4302">4302</span> +<span id="4303">4303</span> +<span id="4304">4304</span> +<span id="4305">4305</span> +<span id="4306">4306</span> +<span id="4307">4307</span> +<span id="4308">4308</span> +<span id="4309">4309</span> +<span id="4310">4310</span> +<span id="4311">4311</span> +<span id="4312">4312</span> +<span id="4313">4313</span> +<span id="4314">4314</span> +<span id="4315">4315</span> +<span id="4316">4316</span> +<span id="4317">4317</span> +<span id="4318">4318</span> +<span id="4319">4319</span> +<span id="4320">4320</span> +<span id="4321">4321</span> +<span id="4322">4322</span> +<span id="4323">4323</span> +<span id="4324">4324</span> +<span id="4325">4325</span> +<span id="4326">4326</span> +<span id="4327">4327</span> +<span id="4328">4328</span> +<span id="4329">4329</span> +<span id="4330">4330</span> +<span id="4331">4331</span> +<span id="4332">4332</span> +<span id="4333">4333</span> +<span id="4334">4334</span> +<span id="4335">4335</span> +<span id="4336">4336</span> +<span id="4337">4337</span> +<span id="4338">4338</span> +<span id="4339">4339</span> +<span id="4340">4340</span> +<span id="4341">4341</span> +<span id="4342">4342</span> +<span id="4343">4343</span> +<span id="4344">4344</span> +<span id="4345">4345</span> +<span id="4346">4346</span> +<span id="4347">4347</span> +<span id="4348">4348</span> +<span id="4349">4349</span> +<span id="4350">4350</span> +<span id="4351">4351</span> +<span id="4352">4352</span> +<span id="4353">4353</span> +<span id="4354">4354</span> +<span id="4355">4355</span> +<span id="4356">4356</span> +<span id="4357">4357</span> +<span id="4358">4358</span> +<span id="4359">4359</span> +<span id="4360">4360</span> +<span id="4361">4361</span> +<span id="4362">4362</span> +<span id="4363">4363</span> +<span id="4364">4364</span> +<span id="4365">4365</span> +<span id="4366">4366</span> +<span id="4367">4367</span> +<span id="4368">4368</span> +<span id="4369">4369</span> +<span id="4370">4370</span> +<span id="4371">4371</span> +<span id="4372">4372</span> +<span id="4373">4373</span> +<span id="4374">4374</span> +<span id="4375">4375</span> +<span id="4376">4376</span> +<span id="4377">4377</span> +<span id="4378">4378</span> +<span id="4379">4379</span> +<span id="4380">4380</span> +<span id="4381">4381</span> +<span id="4382">4382</span> +<span id="4383">4383</span> +<span id="4384">4384</span> +<span id="4385">4385</span> +<span id="4386">4386</span> +<span id="4387">4387</span> +<span id="4388">4388</span> +<span id="4389">4389</span> +<span id="4390">4390</span> +<span id="4391">4391</span> +<span id="4392">4392</span> +<span id="4393">4393</span> +<span id="4394">4394</span> +<span id="4395">4395</span> +<span id="4396">4396</span> +<span id="4397">4397</span> +<span id="4398">4398</span> +<span id="4399">4399</span> +<span id="4400">4400</span> +<span id="4401">4401</span> +<span id="4402">4402</span> +<span id="4403">4403</span> +<span id="4404">4404</span> +<span id="4405">4405</span> +<span id="4406">4406</span> +<span id="4407">4407</span> +<span id="4408">4408</span> +<span id="4409">4409</span> +<span id="4410">4410</span> +<span id="4411">4411</span> +<span id="4412">4412</span> +<span id="4413">4413</span> +<span id="4414">4414</span> +<span id="4415">4415</span> +<span id="4416">4416</span> +<span id="4417">4417</span> +<span id="4418">4418</span> +<span id="4419">4419</span> +<span id="4420">4420</span> +<span id="4421">4421</span> +<span id="4422">4422</span> +<span id="4423">4423</span> +<span id="4424">4424</span> +<span id="4425">4425</span> +<span id="4426">4426</span> +<span id="4427">4427</span> +<span id="4428">4428</span> +<span id="4429">4429</span> +<span id="4430">4430</span> +<span id="4431">4431</span> +<span id="4432">4432</span> +<span id="4433">4433</span> +<span id="4434">4434</span> +<span id="4435">4435</span> +<span id="4436">4436</span> +<span id="4437">4437</span> +<span id="4438">4438</span> +<span id="4439">4439</span> +<span id="4440">4440</span> +<span id="4441">4441</span> +<span id="4442">4442</span> +<span id="4443">4443</span> +<span id="4444">4444</span> +<span id="4445">4445</span> +<span id="4446">4446</span> +<span id="4447">4447</span> +<span id="4448">4448</span> +<span id="4449">4449</span> +<span id="4450">4450</span> +<span id="4451">4451</span> +<span id="4452">4452</span> +<span id="4453">4453</span> +<span id="4454">4454</span> +<span id="4455">4455</span> +<span id="4456">4456</span> +<span id="4457">4457</span> +<span id="4458">4458</span> +<span id="4459">4459</span> +<span id="4460">4460</span> +<span id="4461">4461</span> +<span id="4462">4462</span> +<span id="4463">4463</span> +<span id="4464">4464</span> +<span id="4465">4465</span> +<span id="4466">4466</span> +<span id="4467">4467</span> +<span id="4468">4468</span> +<span id="4469">4469</span> +<span id="4470">4470</span> +<span id="4471">4471</span> +<span id="4472">4472</span> +<span id="4473">4473</span> +<span id="4474">4474</span> +<span id="4475">4475</span> +<span id="4476">4476</span> +<span id="4477">4477</span> +<span id="4478">4478</span> +<span id="4479">4479</span> +<span id="4480">4480</span> +<span id="4481">4481</span> +<span id="4482">4482</span> +<span id="4483">4483</span> +<span id="4484">4484</span> +<span id="4485">4485</span> +<span id="4486">4486</span> +<span id="4487">4487</span> +<span id="4488">4488</span> +<span id="4489">4489</span> +<span id="4490">4490</span> +<span id="4491">4491</span> +<span id="4492">4492</span> +<span id="4493">4493</span> +<span id="4494">4494</span> +<span id="4495">4495</span> +<span id="4496">4496</span> +<span id="4497">4497</span> +<span id="4498">4498</span> +<span id="4499">4499</span> +<span id="4500">4500</span> +<span id="4501">4501</span> +<span id="4502">4502</span> +<span id="4503">4503</span> +<span id="4504">4504</span> +<span id="4505">4505</span> +<span id="4506">4506</span> +<span id="4507">4507</span> +<span id="4508">4508</span> +<span id="4509">4509</span> +<span id="4510">4510</span> +<span id="4511">4511</span> +<span id="4512">4512</span> +<span id="4513">4513</span> +<span id="4514">4514</span> +<span id="4515">4515</span> +<span id="4516">4516</span> +<span id="4517">4517</span> +<span id="4518">4518</span> +<span id="4519">4519</span> +<span id="4520">4520</span> +<span id="4521">4521</span> +<span id="4522">4522</span> +<span id="4523">4523</span> +<span id="4524">4524</span> +<span id="4525">4525</span> +<span id="4526">4526</span> +<span id="4527">4527</span> +<span id="4528">4528</span> +<span id="4529">4529</span> +<span id="4530">4530</span> +<span id="4531">4531</span> +<span id="4532">4532</span> +<span id="4533">4533</span> +<span id="4534">4534</span> +<span id="4535">4535</span> +<span id="4536">4536</span> +<span id="4537">4537</span> +<span id="4538">4538</span> +<span id="4539">4539</span> +<span id="4540">4540</span> +<span id="4541">4541</span> +<span id="4542">4542</span> +<span id="4543">4543</span> +<span id="4544">4544</span> +<span id="4545">4545</span> +<span id="4546">4546</span> +<span id="4547">4547</span> +<span id="4548">4548</span> +<span id="4549">4549</span> +<span id="4550">4550</span> +<span id="4551">4551</span> +<span id="4552">4552</span> +<span id="4553">4553</span> +<span id="4554">4554</span> +<span id="4555">4555</span> +<span id="4556">4556</span> +<span id="4557">4557</span> +<span id="4558">4558</span> +<span id="4559">4559</span> +<span id="4560">4560</span> +<span id="4561">4561</span> +<span id="4562">4562</span> +<span id="4563">4563</span> +<span id="4564">4564</span> +<span id="4565">4565</span> +<span id="4566">4566</span> +<span id="4567">4567</span> +<span id="4568">4568</span> +<span id="4569">4569</span> +<span id="4570">4570</span> +<span id="4571">4571</span> +<span id="4572">4572</span> +<span id="4573">4573</span> +<span id="4574">4574</span> +<span id="4575">4575</span> +<span id="4576">4576</span> +<span id="4577">4577</span> +<span id="4578">4578</span> +<span id="4579">4579</span> +<span id="4580">4580</span> +<span id="4581">4581</span> +<span id="4582">4582</span> +<span id="4583">4583</span> +<span id="4584">4584</span> +<span id="4585">4585</span> +<span id="4586">4586</span> +<span id="4587">4587</span> +<span id="4588">4588</span> +<span id="4589">4589</span> +<span id="4590">4590</span> +<span id="4591">4591</span> +<span id="4592">4592</span> +<span id="4593">4593</span> +<span id="4594">4594</span> +<span id="4595">4595</span> +<span id="4596">4596</span> +<span id="4597">4597</span> +<span id="4598">4598</span> +<span id="4599">4599</span> +<span id="4600">4600</span> +<span id="4601">4601</span> +<span id="4602">4602</span> +<span id="4603">4603</span> +<span id="4604">4604</span> +<span id="4605">4605</span> +<span id="4606">4606</span> +<span id="4607">4607</span> +<span id="4608">4608</span> +<span id="4609">4609</span> +<span id="4610">4610</span> +<span id="4611">4611</span> +<span id="4612">4612</span> +<span id="4613">4613</span> +<span id="4614">4614</span> +<span id="4615">4615</span> +<span id="4616">4616</span> +<span id="4617">4617</span> +<span id="4618">4618</span> +<span id="4619">4619</span> +<span id="4620">4620</span> +<span id="4621">4621</span> +<span id="4622">4622</span> +<span id="4623">4623</span> +<span id="4624">4624</span> +<span id="4625">4625</span> +<span id="4626">4626</span> +<span id="4627">4627</span> +<span id="4628">4628</span> +<span id="4629">4629</span> +<span id="4630">4630</span> +<span id="4631">4631</span> +<span id="4632">4632</span> +<span id="4633">4633</span> +<span id="4634">4634</span> +<span id="4635">4635</span> +<span id="4636">4636</span> +<span id="4637">4637</span> +<span id="4638">4638</span> +<span id="4639">4639</span> +<span id="4640">4640</span> +<span id="4641">4641</span> +<span id="4642">4642</span> +<span id="4643">4643</span> +<span id="4644">4644</span> +<span id="4645">4645</span> +<span id="4646">4646</span> +<span id="4647">4647</span> +<span id="4648">4648</span> +<span id="4649">4649</span> +<span id="4650">4650</span> +<span id="4651">4651</span> +<span id="4652">4652</span> +<span id="4653">4653</span> +<span id="4654">4654</span> +<span id="4655">4655</span> +<span id="4656">4656</span> +<span id="4657">4657</span> +<span id="4658">4658</span> +<span id="4659">4659</span> +<span id="4660">4660</span> +<span id="4661">4661</span> +<span id="4662">4662</span> +<span id="4663">4663</span> +<span id="4664">4664</span> +<span id="4665">4665</span> +<span id="4666">4666</span> +<span id="4667">4667</span> +<span id="4668">4668</span> +<span id="4669">4669</span> +<span id="4670">4670</span> +<span id="4671">4671</span> +<span id="4672">4672</span> +<span id="4673">4673</span> +<span id="4674">4674</span> +<span id="4675">4675</span> +<span id="4676">4676</span> +<span id="4677">4677</span> +<span id="4678">4678</span> +<span id="4679">4679</span> +<span id="4680">4680</span> +<span id="4681">4681</span> +<span id="4682">4682</span> +<span id="4683">4683</span> +<span id="4684">4684</span> +<span id="4685">4685</span> +<span id="4686">4686</span> +<span id="4687">4687</span> +<span id="4688">4688</span> +<span id="4689">4689</span> +<span id="4690">4690</span> +<span id="4691">4691</span> +<span id="4692">4692</span> +<span id="4693">4693</span> +<span id="4694">4694</span> +<span id="4695">4695</span> +<span id="4696">4696</span> +<span id="4697">4697</span> +<span id="4698">4698</span> +<span id="4699">4699</span> +<span id="4700">4700</span> +<span id="4701">4701</span> +<span id="4702">4702</span> +<span id="4703">4703</span> +<span id="4704">4704</span> +<span id="4705">4705</span> +<span id="4706">4706</span> +<span id="4707">4707</span> +<span id="4708">4708</span> +<span id="4709">4709</span> +<span id="4710">4710</span> +<span id="4711">4711</span> +<span id="4712">4712</span> +<span id="4713">4713</span> +<span id="4714">4714</span> +<span id="4715">4715</span> +<span id="4716">4716</span> +<span id="4717">4717</span> +<span id="4718">4718</span> +<span id="4719">4719</span> +<span id="4720">4720</span> +<span id="4721">4721</span> +<span id="4722">4722</span> +<span id="4723">4723</span> +<span id="4724">4724</span> +<span id="4725">4725</span> +<span id="4726">4726</span> +<span id="4727">4727</span> +<span id="4728">4728</span> +<span id="4729">4729</span> +<span id="4730">4730</span> +<span id="4731">4731</span> +<span id="4732">4732</span> +<span id="4733">4733</span> +<span id="4734">4734</span> +<span id="4735">4735</span> +<span id="4736">4736</span> +<span id="4737">4737</span> +<span id="4738">4738</span> +<span id="4739">4739</span> +<span id="4740">4740</span> +<span id="4741">4741</span> +<span id="4742">4742</span> +<span id="4743">4743</span> +<span id="4744">4744</span> +<span id="4745">4745</span> +<span id="4746">4746</span> +<span id="4747">4747</span> +<span id="4748">4748</span> +<span id="4749">4749</span> +<span id="4750">4750</span> +<span id="4751">4751</span> +<span id="4752">4752</span> +<span id="4753">4753</span> +<span id="4754">4754</span> +<span id="4755">4755</span> +<span id="4756">4756</span> +<span id="4757">4757</span> +<span id="4758">4758</span> +<span id="4759">4759</span> +<span id="4760">4760</span> +<span id="4761">4761</span> +<span id="4762">4762</span> +<span id="4763">4763</span> +<span id="4764">4764</span> +<span id="4765">4765</span> +<span id="4766">4766</span> +<span id="4767">4767</span> +<span id="4768">4768</span> +<span id="4769">4769</span> +<span id="4770">4770</span> +<span id="4771">4771</span> +<span id="4772">4772</span> +<span id="4773">4773</span> +<span id="4774">4774</span> +<span id="4775">4775</span> +<span id="4776">4776</span> +<span id="4777">4777</span> +<span id="4778">4778</span> +<span id="4779">4779</span> +<span id="4780">4780</span> +<span id="4781">4781</span> +<span id="4782">4782</span> +<span id="4783">4783</span> +<span id="4784">4784</span> +<span id="4785">4785</span> +<span id="4786">4786</span> +<span id="4787">4787</span> +<span id="4788">4788</span> +<span id="4789">4789</span> +<span id="4790">4790</span> +<span id="4791">4791</span> +<span id="4792">4792</span> +<span id="4793">4793</span> +<span id="4794">4794</span> +<span id="4795">4795</span> +<span id="4796">4796</span> +<span id="4797">4797</span> +<span id="4798">4798</span> +<span id="4799">4799</span> +<span id="4800">4800</span> +<span id="4801">4801</span> +<span id="4802">4802</span> +<span id="4803">4803</span> +<span id="4804">4804</span> +<span id="4805">4805</span> +<span id="4806">4806</span> +<span id="4807">4807</span> +<span id="4808">4808</span> +<span id="4809">4809</span> +<span id="4810">4810</span> +<span id="4811">4811</span> +<span id="4812">4812</span> +<span id="4813">4813</span> +<span id="4814">4814</span> +<span id="4815">4815</span> +<span id="4816">4816</span> +<span id="4817">4817</span> +<span id="4818">4818</span> +<span id="4819">4819</span> +<span id="4820">4820</span> +<span id="4821">4821</span> +<span id="4822">4822</span> +<span id="4823">4823</span> +<span id="4824">4824</span> +<span id="4825">4825</span> +<span id="4826">4826</span> +<span id="4827">4827</span> +<span id="4828">4828</span> +<span id="4829">4829</span> +<span id="4830">4830</span> +<span id="4831">4831</span> +<span id="4832">4832</span> +<span id="4833">4833</span> +<span id="4834">4834</span> +<span id="4835">4835</span> +<span id="4836">4836</span> +<span id="4837">4837</span> +<span id="4838">4838</span> +<span id="4839">4839</span> +<span id="4840">4840</span> +<span id="4841">4841</span> +<span id="4842">4842</span> +<span id="4843">4843</span> +<span id="4844">4844</span> +<span id="4845">4845</span> +<span id="4846">4846</span> +<span id="4847">4847</span> +<span id="4848">4848</span> +<span id="4849">4849</span> +<span id="4850">4850</span> +<span id="4851">4851</span> +<span id="4852">4852</span> +<span id="4853">4853</span> +<span id="4854">4854</span> +<span id="4855">4855</span> +<span id="4856">4856</span> +<span id="4857">4857</span> +<span id="4858">4858</span> +<span id="4859">4859</span> +<span id="4860">4860</span> +<span id="4861">4861</span> +<span id="4862">4862</span> +<span id="4863">4863</span> +<span id="4864">4864</span> +<span id="4865">4865</span> +<span id="4866">4866</span> +<span id="4867">4867</span> +<span id="4868">4868</span> +<span id="4869">4869</span> +<span id="4870">4870</span> +<span id="4871">4871</span> +<span id="4872">4872</span> +<span id="4873">4873</span> +<span id="4874">4874</span> +<span id="4875">4875</span> +<span id="4876">4876</span> +<span id="4877">4877</span> +<span id="4878">4878</span> +<span id="4879">4879</span> +<span id="4880">4880</span> +<span id="4881">4881</span> +<span id="4882">4882</span> +<span id="4883">4883</span> +<span id="4884">4884</span> +<span id="4885">4885</span> +<span id="4886">4886</span> +<span id="4887">4887</span> +<span id="4888">4888</span> +<span id="4889">4889</span> +<span id="4890">4890</span> +<span id="4891">4891</span> +<span id="4892">4892</span> +<span id="4893">4893</span> +<span id="4894">4894</span> +<span id="4895">4895</span> +<span id="4896">4896</span> +<span id="4897">4897</span> +<span id="4898">4898</span> +<span id="4899">4899</span> +<span id="4900">4900</span> +<span id="4901">4901</span> +<span id="4902">4902</span> +<span id="4903">4903</span> +<span id="4904">4904</span> +<span id="4905">4905</span> +<span id="4906">4906</span> +<span id="4907">4907</span> +<span id="4908">4908</span> +<span id="4909">4909</span> +<span id="4910">4910</span> +<span id="4911">4911</span> +<span id="4912">4912</span> +<span id="4913">4913</span> +<span id="4914">4914</span> +<span id="4915">4915</span> +<span id="4916">4916</span> +<span id="4917">4917</span> +<span id="4918">4918</span> +<span id="4919">4919</span> +<span id="4920">4920</span> +<span id="4921">4921</span> +<span id="4922">4922</span> +<span id="4923">4923</span> +<span id="4924">4924</span> +<span id="4925">4925</span> +<span id="4926">4926</span> +<span id="4927">4927</span> +<span id="4928">4928</span> +<span id="4929">4929</span> +<span id="4930">4930</span> +<span id="4931">4931</span> +<span id="4932">4932</span> +<span id="4933">4933</span> +<span id="4934">4934</span> +<span id="4935">4935</span> +<span id="4936">4936</span> +<span id="4937">4937</span> +<span id="4938">4938</span> +<span id="4939">4939</span> +<span id="4940">4940</span> +<span id="4941">4941</span> +<span id="4942">4942</span> +<span id="4943">4943</span> +<span id="4944">4944</span> +<span id="4945">4945</span> +<span id="4946">4946</span> +<span id="4947">4947</span> +<span id="4948">4948</span> +<span id="4949">4949</span> +<span id="4950">4950</span> +<span id="4951">4951</span> +<span id="4952">4952</span> +<span id="4953">4953</span> +<span id="4954">4954</span> +<span id="4955">4955</span> +<span id="4956">4956</span> +<span id="4957">4957</span> +<span id="4958">4958</span> +<span id="4959">4959</span> +<span id="4960">4960</span> +<span id="4961">4961</span> +<span id="4962">4962</span> +<span id="4963">4963</span> +<span id="4964">4964</span> +<span id="4965">4965</span> +<span id="4966">4966</span> +<span id="4967">4967</span> +<span id="4968">4968</span> +<span id="4969">4969</span> +<span id="4970">4970</span> +<span id="4971">4971</span> +<span id="4972">4972</span> +<span id="4973">4973</span> +<span id="4974">4974</span> +<span id="4975">4975</span> +<span id="4976">4976</span> +<span id="4977">4977</span> +<span id="4978">4978</span> +<span id="4979">4979</span> +<span id="4980">4980</span> +<span id="4981">4981</span> +<span id="4982">4982</span> +<span id="4983">4983</span> +<span id="4984">4984</span> +<span id="4985">4985</span> +<span id="4986">4986</span> +<span id="4987">4987</span> +<span id="4988">4988</span> +<span id="4989">4989</span> +<span id="4990">4990</span> +<span id="4991">4991</span> +<span id="4992">4992</span> +<span id="4993">4993</span> +<span id="4994">4994</span> +<span id="4995">4995</span> +<span id="4996">4996</span> +<span id="4997">4997</span> +<span id="4998">4998</span> +<span id="4999">4999</span> +<span id="5000">5000</span> +<span id="5001">5001</span> +<span id="5002">5002</span> +<span id="5003">5003</span> +<span id="5004">5004</span> +<span id="5005">5005</span> +<span id="5006">5006</span> +<span id="5007">5007</span> +<span id="5008">5008</span> +<span id="5009">5009</span> +<span id="5010">5010</span> +<span id="5011">5011</span> +<span id="5012">5012</span> +<span id="5013">5013</span> +<span id="5014">5014</span> +<span id="5015">5015</span> +<span id="5016">5016</span> +<span id="5017">5017</span> +<span id="5018">5018</span> +<span id="5019">5019</span> +<span id="5020">5020</span> +<span id="5021">5021</span> +<span id="5022">5022</span> +<span id="5023">5023</span> +<span id="5024">5024</span> +<span id="5025">5025</span> +<span id="5026">5026</span> +<span id="5027">5027</span> +<span id="5028">5028</span> +<span id="5029">5029</span> +<span id="5030">5030</span> +<span id="5031">5031</span> +<span id="5032">5032</span> +<span id="5033">5033</span> +<span id="5034">5034</span> +<span id="5035">5035</span> +<span id="5036">5036</span> +<span id="5037">5037</span> +<span id="5038">5038</span> +<span id="5039">5039</span> +<span id="5040">5040</span> +<span id="5041">5041</span> +<span id="5042">5042</span> +<span id="5043">5043</span> +<span id="5044">5044</span> +<span id="5045">5045</span> +<span id="5046">5046</span> +<span id="5047">5047</span> +<span id="5048">5048</span> +<span id="5049">5049</span> +<span id="5050">5050</span> +<span id="5051">5051</span> +<span id="5052">5052</span> +<span id="5053">5053</span> +<span id="5054">5054</span> +<span id="5055">5055</span> +<span id="5056">5056</span> +<span id="5057">5057</span> +<span id="5058">5058</span> +<span id="5059">5059</span> +<span id="5060">5060</span> +<span id="5061">5061</span> +<span id="5062">5062</span> +<span id="5063">5063</span> +<span id="5064">5064</span> +<span id="5065">5065</span> +<span id="5066">5066</span> +<span id="5067">5067</span> +<span id="5068">5068</span> +<span id="5069">5069</span> +<span id="5070">5070</span> +<span id="5071">5071</span> +<span id="5072">5072</span> +<span id="5073">5073</span> +<span id="5074">5074</span> +<span id="5075">5075</span> +<span id="5076">5076</span> +<span id="5077">5077</span> +<span id="5078">5078</span> +<span id="5079">5079</span> +<span id="5080">5080</span> +<span id="5081">5081</span> +<span id="5082">5082</span> +<span id="5083">5083</span> +<span id="5084">5084</span> +<span id="5085">5085</span> +<span id="5086">5086</span> +<span id="5087">5087</span> +<span id="5088">5088</span> +<span id="5089">5089</span> +<span id="5090">5090</span> +<span id="5091">5091</span> +<span id="5092">5092</span> +<span id="5093">5093</span> +<span id="5094">5094</span> +<span id="5095">5095</span> +<span id="5096">5096</span> +<span id="5097">5097</span> +<span id="5098">5098</span> +<span id="5099">5099</span> +<span id="5100">5100</span> +<span id="5101">5101</span> +<span id="5102">5102</span> +<span id="5103">5103</span> +<span id="5104">5104</span> +<span id="5105">5105</span> +<span id="5106">5106</span> +<span id="5107">5107</span> +<span id="5108">5108</span> +<span id="5109">5109</span> +<span id="5110">5110</span> +<span id="5111">5111</span> +<span id="5112">5112</span> +<span id="5113">5113</span> +<span id="5114">5114</span> +<span id="5115">5115</span> +<span id="5116">5116</span> +<span id="5117">5117</span> +<span id="5118">5118</span> +<span id="5119">5119</span> +<span id="5120">5120</span> +<span id="5121">5121</span> +<span id="5122">5122</span> +<span id="5123">5123</span> +<span id="5124">5124</span> +<span id="5125">5125</span> +<span id="5126">5126</span> +<span id="5127">5127</span> +<span id="5128">5128</span> +<span id="5129">5129</span> +<span id="5130">5130</span> +<span id="5131">5131</span> +<span id="5132">5132</span> +<span id="5133">5133</span> +<span id="5134">5134</span> +<span id="5135">5135</span> +<span id="5136">5136</span> +<span id="5137">5137</span> +<span id="5138">5138</span> +<span id="5139">5139</span> +<span id="5140">5140</span> +<span id="5141">5141</span> +<span id="5142">5142</span> +<span id="5143">5143</span> +<span id="5144">5144</span> +<span id="5145">5145</span> +<span id="5146">5146</span> +<span id="5147">5147</span> +<span id="5148">5148</span> +<span id="5149">5149</span> +<span id="5150">5150</span> +<span id="5151">5151</span> +<span id="5152">5152</span> +<span id="5153">5153</span> +<span id="5154">5154</span> +<span id="5155">5155</span> +<span id="5156">5156</span> +<span id="5157">5157</span> +<span id="5158">5158</span> +<span id="5159">5159</span> +<span id="5160">5160</span> +<span id="5161">5161</span> +<span id="5162">5162</span> +<span id="5163">5163</span> +<span id="5164">5164</span> +<span id="5165">5165</span> +<span id="5166">5166</span> +<span id="5167">5167</span> +<span id="5168">5168</span> +<span id="5169">5169</span> +<span id="5170">5170</span> +<span id="5171">5171</span> +<span id="5172">5172</span> +<span id="5173">5173</span> +<span id="5174">5174</span> +<span id="5175">5175</span> +<span id="5176">5176</span> +<span id="5177">5177</span> +<span id="5178">5178</span> +<span id="5179">5179</span> +<span id="5180">5180</span> +<span id="5181">5181</span> +<span id="5182">5182</span> +<span id="5183">5183</span> +<span id="5184">5184</span> +<span id="5185">5185</span> +<span id="5186">5186</span> +<span id="5187">5187</span> +<span id="5188">5188</span> +<span id="5189">5189</span> +<span id="5190">5190</span> +<span id="5191">5191</span> +<span id="5192">5192</span> +<span id="5193">5193</span> +<span id="5194">5194</span> +<span id="5195">5195</span> +<span id="5196">5196</span> +<span id="5197">5197</span> +<span id="5198">5198</span> +<span id="5199">5199</span> +<span id="5200">5200</span> +<span id="5201">5201</span> +<span id="5202">5202</span> +<span id="5203">5203</span> +<span id="5204">5204</span> +<span id="5205">5205</span> +<span id="5206">5206</span> +<span id="5207">5207</span> +<span id="5208">5208</span> +<span id="5209">5209</span> +<span id="5210">5210</span> +<span id="5211">5211</span> +<span id="5212">5212</span> +<span id="5213">5213</span> +<span id="5214">5214</span> +<span id="5215">5215</span> +<span id="5216">5216</span> +<span id="5217">5217</span> +<span id="5218">5218</span> +<span id="5219">5219</span> +<span id="5220">5220</span> +<span id="5221">5221</span> +<span id="5222">5222</span> +<span id="5223">5223</span> +<span id="5224">5224</span> +<span id="5225">5225</span> +<span id="5226">5226</span> +<span id="5227">5227</span> +<span id="5228">5228</span> +<span id="5229">5229</span> +<span id="5230">5230</span> +<span id="5231">5231</span> +<span id="5232">5232</span> +<span id="5233">5233</span> +<span id="5234">5234</span> +<span id="5235">5235</span> +<span id="5236">5236</span> +<span id="5237">5237</span> +<span id="5238">5238</span> +<span id="5239">5239</span> +<span id="5240">5240</span> +<span id="5241">5241</span> +<span id="5242">5242</span> +<span id="5243">5243</span> +<span id="5244">5244</span> +<span id="5245">5245</span> +<span id="5246">5246</span> +<span id="5247">5247</span> +<span id="5248">5248</span> +<span id="5249">5249</span> +<span id="5250">5250</span> +<span id="5251">5251</span> +<span id="5252">5252</span> +<span id="5253">5253</span> +<span id="5254">5254</span> +<span id="5255">5255</span> +<span id="5256">5256</span> +<span id="5257">5257</span> +<span id="5258">5258</span> +<span id="5259">5259</span> +<span id="5260">5260</span> +<span id="5261">5261</span> +<span id="5262">5262</span> +<span id="5263">5263</span> +<span id="5264">5264</span> +<span id="5265">5265</span> +<span id="5266">5266</span> +<span id="5267">5267</span> +<span id="5268">5268</span> +<span id="5269">5269</span> +<span id="5270">5270</span> +<span id="5271">5271</span> +<span id="5272">5272</span> +<span id="5273">5273</span> +<span id="5274">5274</span> +<span id="5275">5275</span> +<span id="5276">5276</span> +<span id="5277">5277</span> +<span id="5278">5278</span> +<span id="5279">5279</span> +<span id="5280">5280</span> +<span id="5281">5281</span> +<span id="5282">5282</span> +<span id="5283">5283</span> +<span id="5284">5284</span> +<span id="5285">5285</span> +<span id="5286">5286</span> +<span id="5287">5287</span> +<span id="5288">5288</span> +<span id="5289">5289</span> +<span id="5290">5290</span> +<span id="5291">5291</span> +<span id="5292">5292</span> +<span id="5293">5293</span> +<span id="5294">5294</span> +<span id="5295">5295</span> +<span id="5296">5296</span> +<span id="5297">5297</span> +<span id="5298">5298</span> +<span id="5299">5299</span> +<span id="5300">5300</span> +<span id="5301">5301</span> +<span id="5302">5302</span> +<span id="5303">5303</span> +<span id="5304">5304</span> +<span id="5305">5305</span> +<span id="5306">5306</span> +<span id="5307">5307</span> +<span id="5308">5308</span> +<span id="5309">5309</span> +<span id="5310">5310</span> +<span id="5311">5311</span> +<span id="5312">5312</span> +<span id="5313">5313</span> +<span id="5314">5314</span> +<span id="5315">5315</span> +<span id="5316">5316</span> +<span id="5317">5317</span> +<span id="5318">5318</span> +<span id="5319">5319</span> +<span id="5320">5320</span> +<span id="5321">5321</span> +<span id="5322">5322</span> +<span id="5323">5323</span> +<span id="5324">5324</span> +<span id="5325">5325</span> +<span id="5326">5326</span> +<span id="5327">5327</span> +<span id="5328">5328</span> +<span id="5329">5329</span> +<span id="5330">5330</span> +<span id="5331">5331</span> +<span id="5332">5332</span> +<span id="5333">5333</span> +<span id="5334">5334</span> +<span id="5335">5335</span> +<span id="5336">5336</span> +<span id="5337">5337</span> +<span id="5338">5338</span> +<span id="5339">5339</span> +<span id="5340">5340</span> +<span id="5341">5341</span> +<span id="5342">5342</span> +<span id="5343">5343</span> +<span id="5344">5344</span> +<span id="5345">5345</span> +<span id="5346">5346</span> +<span id="5347">5347</span> +<span id="5348">5348</span> +<span id="5349">5349</span> +<span id="5350">5350</span> +<span id="5351">5351</span> +<span id="5352">5352</span> +<span id="5353">5353</span> +<span id="5354">5354</span> +<span id="5355">5355</span> +<span id="5356">5356</span> +<span id="5357">5357</span> +<span id="5358">5358</span> +<span id="5359">5359</span> +<span id="5360">5360</span> +<span id="5361">5361</span> +<span id="5362">5362</span> +<span id="5363">5363</span> +<span id="5364">5364</span> +<span id="5365">5365</span> +<span id="5366">5366</span> +<span id="5367">5367</span> +<span id="5368">5368</span> +<span id="5369">5369</span> +<span id="5370">5370</span> +<span id="5371">5371</span> +<span id="5372">5372</span> +<span id="5373">5373</span> +<span id="5374">5374</span> +<span id="5375">5375</span> +<span id="5376">5376</span> +<span id="5377">5377</span> +<span id="5378">5378</span> +<span id="5379">5379</span> +<span id="5380">5380</span> +<span id="5381">5381</span> +<span id="5382">5382</span> +<span id="5383">5383</span> +<span id="5384">5384</span> +<span id="5385">5385</span> +<span id="5386">5386</span> +<span id="5387">5387</span> +<span id="5388">5388</span> +<span id="5389">5389</span> +<span id="5390">5390</span> +<span id="5391">5391</span> +<span id="5392">5392</span> +<span id="5393">5393</span> +<span id="5394">5394</span> +<span id="5395">5395</span> +<span id="5396">5396</span> +<span id="5397">5397</span> +<span id="5398">5398</span> +<span id="5399">5399</span> +<span id="5400">5400</span> +<span id="5401">5401</span> +<span id="5402">5402</span> +<span id="5403">5403</span> +<span id="5404">5404</span> +<span id="5405">5405</span> +<span id="5406">5406</span> +<span id="5407">5407</span> +<span id="5408">5408</span> +<span id="5409">5409</span> +<span id="5410">5410</span> +<span id="5411">5411</span> +<span id="5412">5412</span> +<span id="5413">5413</span> +<span id="5414">5414</span> +<span id="5415">5415</span> +<span id="5416">5416</span> +<span id="5417">5417</span> +<span id="5418">5418</span> +<span id="5419">5419</span> +<span id="5420">5420</span> +<span id="5421">5421</span> +<span id="5422">5422</span> +<span id="5423">5423</span> +<span id="5424">5424</span> +<span id="5425">5425</span> +<span id="5426">5426</span> +<span id="5427">5427</span> +<span id="5428">5428</span> +<span id="5429">5429</span> +<span id="5430">5430</span> +<span id="5431">5431</span> +<span id="5432">5432</span> +<span id="5433">5433</span> +<span id="5434">5434</span> +<span id="5435">5435</span> +<span id="5436">5436</span> +<span id="5437">5437</span> +<span id="5438">5438</span> +<span id="5439">5439</span> +<span id="5440">5440</span> +<span id="5441">5441</span> +<span id="5442">5442</span> +<span id="5443">5443</span> +<span id="5444">5444</span> +<span id="5445">5445</span> +<span id="5446">5446</span> +<span id="5447">5447</span> +<span id="5448">5448</span> +<span id="5449">5449</span> +<span id="5450">5450</span> +<span id="5451">5451</span> +<span id="5452">5452</span> +<span id="5453">5453</span> +<span id="5454">5454</span> +<span id="5455">5455</span> +<span id="5456">5456</span> +<span id="5457">5457</span> +<span id="5458">5458</span> +<span id="5459">5459</span> +<span id="5460">5460</span> +<span id="5461">5461</span> +<span id="5462">5462</span> +<span id="5463">5463</span> +<span id="5464">5464</span> +<span id="5465">5465</span> +<span id="5466">5466</span> +<span id="5467">5467</span> +<span id="5468">5468</span> +<span id="5469">5469</span> +<span id="5470">5470</span> +<span id="5471">5471</span> +<span id="5472">5472</span> +<span id="5473">5473</span> +<span id="5474">5474</span> +<span id="5475">5475</span> +<span id="5476">5476</span> +<span id="5477">5477</span> +<span id="5478">5478</span> +<span id="5479">5479</span> +<span id="5480">5480</span> +<span id="5481">5481</span> +<span id="5482">5482</span> +<span id="5483">5483</span> +<span id="5484">5484</span> +<span id="5485">5485</span> +<span id="5486">5486</span> +<span id="5487">5487</span> +<span id="5488">5488</span> +<span id="5489">5489</span> +<span id="5490">5490</span> +<span id="5491">5491</span> +<span id="5492">5492</span> +<span id="5493">5493</span> +<span id="5494">5494</span> +<span id="5495">5495</span> +<span id="5496">5496</span> +<span id="5497">5497</span> +<span id="5498">5498</span> +<span id="5499">5499</span> +<span id="5500">5500</span> +<span id="5501">5501</span> +<span id="5502">5502</span> +<span id="5503">5503</span> +<span id="5504">5504</span> +<span id="5505">5505</span> +<span id="5506">5506</span> +<span id="5507">5507</span> +<span id="5508">5508</span> +<span id="5509">5509</span> +<span id="5510">5510</span> +<span id="5511">5511</span> +<span id="5512">5512</span> +<span id="5513">5513</span> +<span id="5514">5514</span> +<span id="5515">5515</span> +<span id="5516">5516</span> +<span id="5517">5517</span> +<span id="5518">5518</span> +<span id="5519">5519</span> +<span id="5520">5520</span> +<span id="5521">5521</span> +<span id="5522">5522</span> +<span id="5523">5523</span> +<span id="5524">5524</span> +<span id="5525">5525</span> +<span id="5526">5526</span> +<span id="5527">5527</span> +<span id="5528">5528</span> +<span id="5529">5529</span> +<span id="5530">5530</span> +<span id="5531">5531</span> +<span id="5532">5532</span> +<span id="5533">5533</span> +<span id="5534">5534</span> +<span id="5535">5535</span> +<span id="5536">5536</span> +<span id="5537">5537</span> +<span id="5538">5538</span> +<span id="5539">5539</span> +<span id="5540">5540</span> +<span id="5541">5541</span> +<span id="5542">5542</span> +<span id="5543">5543</span> +<span id="5544">5544</span> +<span id="5545">5545</span> +<span id="5546">5546</span> +<span id="5547">5547</span> +<span id="5548">5548</span> +<span id="5549">5549</span> +<span id="5550">5550</span> +<span id="5551">5551</span> +<span id="5552">5552</span> +<span id="5553">5553</span> +<span id="5554">5554</span> +<span id="5555">5555</span> +<span id="5556">5556</span> +<span id="5557">5557</span> +<span id="5558">5558</span> +<span id="5559">5559</span> +<span id="5560">5560</span> +<span id="5561">5561</span> +<span id="5562">5562</span> +<span id="5563">5563</span> +<span id="5564">5564</span> +<span id="5565">5565</span> +<span id="5566">5566</span> +<span id="5567">5567</span> +<span id="5568">5568</span> +<span id="5569">5569</span> +<span id="5570">5570</span> +<span id="5571">5571</span> +<span id="5572">5572</span> +<span id="5573">5573</span> +<span id="5574">5574</span> +<span id="5575">5575</span> +<span id="5576">5576</span> +<span id="5577">5577</span> +<span id="5578">5578</span> +<span id="5579">5579</span> +<span id="5580">5580</span> +<span id="5581">5581</span> +<span id="5582">5582</span> +<span id="5583">5583</span> +<span id="5584">5584</span> +<span id="5585">5585</span> +<span id="5586">5586</span> +<span id="5587">5587</span> +<span id="5588">5588</span> +<span id="5589">5589</span> +<span id="5590">5590</span> +<span id="5591">5591</span> +<span id="5592">5592</span> +<span id="5593">5593</span> +<span id="5594">5594</span> +<span id="5595">5595</span> +<span id="5596">5596</span> +<span id="5597">5597</span> +<span id="5598">5598</span> +<span id="5599">5599</span> +<span id="5600">5600</span> +<span id="5601">5601</span> +<span id="5602">5602</span> +<span id="5603">5603</span> +<span id="5604">5604</span> +<span id="5605">5605</span> +<span id="5606">5606</span> +<span id="5607">5607</span> +<span id="5608">5608</span> +<span id="5609">5609</span> +<span id="5610">5610</span> +<span id="5611">5611</span> +<span id="5612">5612</span> +<span id="5613">5613</span> +<span id="5614">5614</span> +<span id="5615">5615</span> +<span id="5616">5616</span> +<span id="5617">5617</span> +<span id="5618">5618</span> +<span id="5619">5619</span> +<span id="5620">5620</span> +<span id="5621">5621</span> +<span id="5622">5622</span> +<span id="5623">5623</span> +<span id="5624">5624</span> +<span id="5625">5625</span> +<span id="5626">5626</span> +<span id="5627">5627</span> +<span id="5628">5628</span> +<span id="5629">5629</span> +<span id="5630">5630</span> +<span id="5631">5631</span> +<span id="5632">5632</span> +<span id="5633">5633</span> +<span id="5634">5634</span> +<span id="5635">5635</span> +<span id="5636">5636</span> +<span id="5637">5637</span> +<span id="5638">5638</span> +<span id="5639">5639</span> +<span id="5640">5640</span> +<span id="5641">5641</span> +<span id="5642">5642</span> +<span id="5643">5643</span> +<span id="5644">5644</span> +<span id="5645">5645</span> +<span id="5646">5646</span> +<span id="5647">5647</span> +<span id="5648">5648</span> +<span id="5649">5649</span> +<span id="5650">5650</span> +<span id="5651">5651</span> +<span id="5652">5652</span> +<span id="5653">5653</span> +<span id="5654">5654</span> +<span id="5655">5655</span> +<span id="5656">5656</span> +<span id="5657">5657</span> +<span id="5658">5658</span> +<span id="5659">5659</span> +<span id="5660">5660</span> +<span id="5661">5661</span> +<span id="5662">5662</span> +<span id="5663">5663</span> +<span id="5664">5664</span> +<span id="5665">5665</span> +<span id="5666">5666</span> +<span id="5667">5667</span> +<span id="5668">5668</span> +<span id="5669">5669</span> +<span id="5670">5670</span> +<span id="5671">5671</span> +<span id="5672">5672</span> +<span id="5673">5673</span> +<span id="5674">5674</span> +<span id="5675">5675</span> +<span id="5676">5676</span> +<span id="5677">5677</span> +<span id="5678">5678</span> +<span id="5679">5679</span> +<span id="5680">5680</span> +<span id="5681">5681</span> +<span id="5682">5682</span> +<span id="5683">5683</span> +<span id="5684">5684</span> +<span id="5685">5685</span> +<span id="5686">5686</span> +<span id="5687">5687</span> +<span id="5688">5688</span> +<span id="5689">5689</span> +<span id="5690">5690</span> +<span id="5691">5691</span> +<span id="5692">5692</span> +<span id="5693">5693</span> +<span id="5694">5694</span> +<span id="5695">5695</span> +<span id="5696">5696</span> +<span id="5697">5697</span> +<span id="5698">5698</span> +<span id="5699">5699</span> +<span id="5700">5700</span> +<span id="5701">5701</span> +<span id="5702">5702</span> +<span id="5703">5703</span> +<span id="5704">5704</span> +<span id="5705">5705</span> +<span id="5706">5706</span> +<span id="5707">5707</span> +<span id="5708">5708</span> +<span id="5709">5709</span> +<span id="5710">5710</span> +<span id="5711">5711</span> +<span id="5712">5712</span> +<span id="5713">5713</span> +<span id="5714">5714</span> +<span id="5715">5715</span> +<span id="5716">5716</span> +<span id="5717">5717</span> +<span id="5718">5718</span> +<span id="5719">5719</span> +<span id="5720">5720</span> +<span id="5721">5721</span> +<span id="5722">5722</span> +<span id="5723">5723</span> +<span id="5724">5724</span> +<span id="5725">5725</span> +<span id="5726">5726</span> +<span id="5727">5727</span> +<span id="5728">5728</span> +<span id="5729">5729</span> +<span id="5730">5730</span> +<span id="5731">5731</span> +<span id="5732">5732</span> +<span id="5733">5733</span> +<span id="5734">5734</span> +<span id="5735">5735</span> +<span id="5736">5736</span> +<span id="5737">5737</span> +<span id="5738">5738</span> +<span id="5739">5739</span> +<span id="5740">5740</span> +<span id="5741">5741</span> +<span id="5742">5742</span> +<span id="5743">5743</span> +<span id="5744">5744</span> +<span id="5745">5745</span> +<span id="5746">5746</span> +<span id="5747">5747</span> +<span id="5748">5748</span> +<span id="5749">5749</span> +<span id="5750">5750</span> +<span id="5751">5751</span> +<span id="5752">5752</span> +<span id="5753">5753</span> +<span id="5754">5754</span> +<span id="5755">5755</span> +<span id="5756">5756</span> +<span id="5757">5757</span> +<span id="5758">5758</span> +<span id="5759">5759</span> +<span id="5760">5760</span> +<span id="5761">5761</span> +<span id="5762">5762</span> +<span id="5763">5763</span> +<span id="5764">5764</span> +<span id="5765">5765</span> +<span id="5766">5766</span> +<span id="5767">5767</span> +<span id="5768">5768</span> +<span id="5769">5769</span> +<span id="5770">5770</span> +<span id="5771">5771</span> +<span id="5772">5772</span> +<span id="5773">5773</span> +<span id="5774">5774</span> +<span id="5775">5775</span> +<span id="5776">5776</span> +<span id="5777">5777</span> +<span id="5778">5778</span> +<span id="5779">5779</span> +<span id="5780">5780</span> +<span id="5781">5781</span> +<span id="5782">5782</span> +<span id="5783">5783</span> +<span id="5784">5784</span> +<span id="5785">5785</span> +<span id="5786">5786</span> +<span id="5787">5787</span> +<span id="5788">5788</span> +<span id="5789">5789</span> +<span id="5790">5790</span> +<span id="5791">5791</span> +<span id="5792">5792</span> +<span id="5793">5793</span> +<span id="5794">5794</span> +<span id="5795">5795</span> +<span id="5796">5796</span> +<span id="5797">5797</span> +<span id="5798">5798</span> +<span id="5799">5799</span> +<span id="5800">5800</span> +<span id="5801">5801</span> +<span id="5802">5802</span> +<span id="5803">5803</span> +<span id="5804">5804</span> +<span id="5805">5805</span> +<span id="5806">5806</span> +<span id="5807">5807</span> +<span id="5808">5808</span> +<span id="5809">5809</span> +<span id="5810">5810</span> +<span id="5811">5811</span> +<span id="5812">5812</span> +<span id="5813">5813</span> +<span id="5814">5814</span> +<span id="5815">5815</span> +<span id="5816">5816</span> +<span id="5817">5817</span> +<span id="5818">5818</span> +<span id="5819">5819</span> +<span id="5820">5820</span> +<span id="5821">5821</span> +<span id="5822">5822</span> +<span id="5823">5823</span> +<span id="5824">5824</span> +<span id="5825">5825</span> +<span id="5826">5826</span> +<span id="5827">5827</span> +<span id="5828">5828</span> +<span id="5829">5829</span> +<span id="5830">5830</span> +<span id="5831">5831</span> +<span id="5832">5832</span> +<span id="5833">5833</span> +<span id="5834">5834</span> +<span id="5835">5835</span> +<span id="5836">5836</span> +<span id="5837">5837</span> +<span id="5838">5838</span> +<span id="5839">5839</span> +<span id="5840">5840</span> +<span id="5841">5841</span> +<span id="5842">5842</span> +<span id="5843">5843</span> +<span id="5844">5844</span> +<span id="5845">5845</span> +<span id="5846">5846</span> +<span id="5847">5847</span> +<span id="5848">5848</span> +<span id="5849">5849</span> +<span id="5850">5850</span> +<span id="5851">5851</span> +<span id="5852">5852</span> +<span id="5853">5853</span> +<span id="5854">5854</span> +<span id="5855">5855</span> +<span id="5856">5856</span> +<span id="5857">5857</span> +<span id="5858">5858</span> +<span id="5859">5859</span> +<span id="5860">5860</span> +<span id="5861">5861</span> +<span id="5862">5862</span> +<span id="5863">5863</span> +<span id="5864">5864</span> +<span id="5865">5865</span> +<span id="5866">5866</span> +<span id="5867">5867</span> +<span id="5868">5868</span> +<span id="5869">5869</span> +<span id="5870">5870</span> +<span id="5871">5871</span> +<span id="5872">5872</span> +<span id="5873">5873</span> +<span id="5874">5874</span> +<span id="5875">5875</span> +<span id="5876">5876</span> +<span id="5877">5877</span> +<span id="5878">5878</span> +<span id="5879">5879</span> +<span id="5880">5880</span> +<span id="5881">5881</span> +<span id="5882">5882</span> +<span id="5883">5883</span> +<span id="5884">5884</span> +<span id="5885">5885</span> +<span id="5886">5886</span> +<span id="5887">5887</span> +<span id="5888">5888</span> +<span id="5889">5889</span> +<span id="5890">5890</span> +<span id="5891">5891</span> +<span id="5892">5892</span> +<span id="5893">5893</span> +<span id="5894">5894</span> +<span id="5895">5895</span> +<span id="5896">5896</span> +<span id="5897">5897</span> +<span id="5898">5898</span> +<span id="5899">5899</span> +<span id="5900">5900</span> +<span id="5901">5901</span> +<span id="5902">5902</span> +<span id="5903">5903</span> +<span id="5904">5904</span> +<span id="5905">5905</span> +<span id="5906">5906</span> +<span id="5907">5907</span> +<span id="5908">5908</span> +<span id="5909">5909</span> +<span id="5910">5910</span> +<span id="5911">5911</span> +<span id="5912">5912</span> +<span id="5913">5913</span> +<span id="5914">5914</span> +<span id="5915">5915</span> +<span id="5916">5916</span> +<span id="5917">5917</span> +<span id="5918">5918</span> +<span id="5919">5919</span> +<span id="5920">5920</span> +<span id="5921">5921</span> +<span id="5922">5922</span> +<span id="5923">5923</span> +<span id="5924">5924</span> +<span id="5925">5925</span> +<span id="5926">5926</span> +<span id="5927">5927</span> +<span id="5928">5928</span> +<span id="5929">5929</span> +<span id="5930">5930</span> +<span id="5931">5931</span> +<span id="5932">5932</span> +<span id="5933">5933</span> +<span id="5934">5934</span> +<span id="5935">5935</span> +<span id="5936">5936</span> +<span id="5937">5937</span> +<span id="5938">5938</span> +<span id="5939">5939</span> +<span id="5940">5940</span> +<span id="5941">5941</span> +<span id="5942">5942</span> +<span id="5943">5943</span> +<span id="5944">5944</span> +<span id="5945">5945</span> +<span id="5946">5946</span> +<span id="5947">5947</span> +<span id="5948">5948</span> +<span id="5949">5949</span> +<span id="5950">5950</span> +<span id="5951">5951</span> +<span id="5952">5952</span> +<span id="5953">5953</span> +<span id="5954">5954</span> +<span id="5955">5955</span> +<span id="5956">5956</span> +<span id="5957">5957</span> +<span id="5958">5958</span> +<span id="5959">5959</span> +<span id="5960">5960</span> +<span id="5961">5961</span> +<span id="5962">5962</span> +<span id="5963">5963</span> +<span id="5964">5964</span> +<span id="5965">5965</span> +<span id="5966">5966</span> +<span id="5967">5967</span> +<span id="5968">5968</span> +<span id="5969">5969</span> +<span id="5970">5970</span> +<span id="5971">5971</span> +<span id="5972">5972</span> +<span id="5973">5973</span> +<span id="5974">5974</span> +<span id="5975">5975</span> +<span id="5976">5976</span> +<span id="5977">5977</span> +<span id="5978">5978</span> +<span id="5979">5979</span> +<span id="5980">5980</span> +<span id="5981">5981</span> +<span id="5982">5982</span> +<span id="5983">5983</span> +<span id="5984">5984</span> +<span id="5985">5985</span> +<span id="5986">5986</span> +<span id="5987">5987</span> +<span id="5988">5988</span> +<span id="5989">5989</span> +<span id="5990">5990</span> +<span id="5991">5991</span> +<span id="5992">5992</span> +<span id="5993">5993</span> +<span id="5994">5994</span> +<span id="5995">5995</span> +<span id="5996">5996</span> +<span id="5997">5997</span> +<span id="5998">5998</span> +<span id="5999">5999</span> +<span id="6000">6000</span> +<span id="6001">6001</span> +<span id="6002">6002</span> +<span id="6003">6003</span> +<span id="6004">6004</span> +<span id="6005">6005</span> +<span id="6006">6006</span> +<span id="6007">6007</span> +<span id="6008">6008</span> +<span id="6009">6009</span> +<span id="6010">6010</span> +<span id="6011">6011</span> +<span id="6012">6012</span> +<span id="6013">6013</span> +<span id="6014">6014</span> +<span id="6015">6015</span> +<span id="6016">6016</span> +<span id="6017">6017</span> +<span id="6018">6018</span> +<span id="6019">6019</span> +<span id="6020">6020</span> +<span id="6021">6021</span> +<span id="6022">6022</span> +<span id="6023">6023</span> +<span id="6024">6024</span> +<span id="6025">6025</span> +<span id="6026">6026</span> +<span id="6027">6027</span> +<span id="6028">6028</span> +<span id="6029">6029</span> +<span id="6030">6030</span> +<span id="6031">6031</span> +<span id="6032">6032</span> +<span id="6033">6033</span> +<span id="6034">6034</span> +<span id="6035">6035</span> +<span id="6036">6036</span> +<span id="6037">6037</span> +<span id="6038">6038</span> +<span id="6039">6039</span> +<span id="6040">6040</span> +<span id="6041">6041</span> +<span id="6042">6042</span> +<span id="6043">6043</span> +<span id="6044">6044</span> +<span id="6045">6045</span> +<span id="6046">6046</span> +<span id="6047">6047</span> +<span id="6048">6048</span> +<span id="6049">6049</span> +<span id="6050">6050</span> +<span id="6051">6051</span> +<span id="6052">6052</span> +<span id="6053">6053</span> +<span id="6054">6054</span> +<span id="6055">6055</span> +<span id="6056">6056</span> +<span id="6057">6057</span> +<span id="6058">6058</span> +<span id="6059">6059</span> +<span id="6060">6060</span> +<span id="6061">6061</span> +<span id="6062">6062</span> +<span id="6063">6063</span> +<span id="6064">6064</span> +<span id="6065">6065</span> +<span id="6066">6066</span> +<span id="6067">6067</span> +<span id="6068">6068</span> +<span id="6069">6069</span> +<span id="6070">6070</span> +<span id="6071">6071</span> +<span id="6072">6072</span> +<span id="6073">6073</span> +<span id="6074">6074</span> +<span id="6075">6075</span> +<span id="6076">6076</span> +<span id="6077">6077</span> +<span id="6078">6078</span> +<span id="6079">6079</span> +<span id="6080">6080</span> +<span id="6081">6081</span> +<span id="6082">6082</span> +<span id="6083">6083</span> +<span id="6084">6084</span> +<span id="6085">6085</span> +<span id="6086">6086</span> +<span id="6087">6087</span> +<span id="6088">6088</span> +<span id="6089">6089</span> +<span id="6090">6090</span> +<span id="6091">6091</span> +<span id="6092">6092</span> +<span id="6093">6093</span> +<span id="6094">6094</span> +<span id="6095">6095</span> +<span id="6096">6096</span> +<span id="6097">6097</span> +<span id="6098">6098</span> +<span id="6099">6099</span> +<span id="6100">6100</span> +<span id="6101">6101</span> +<span id="6102">6102</span> +<span id="6103">6103</span> +<span id="6104">6104</span> +<span id="6105">6105</span> +<span id="6106">6106</span> +<span id="6107">6107</span> +<span id="6108">6108</span> +<span id="6109">6109</span> +<span id="6110">6110</span> +<span id="6111">6111</span> +<span id="6112">6112</span> +<span id="6113">6113</span> +<span id="6114">6114</span> +<span id="6115">6115</span> +<span id="6116">6116</span> +<span id="6117">6117</span> +<span id="6118">6118</span> +<span id="6119">6119</span> +<span id="6120">6120</span> +<span id="6121">6121</span> +<span id="6122">6122</span> +<span id="6123">6123</span> +<span id="6124">6124</span> +<span id="6125">6125</span> +<span id="6126">6126</span> +<span id="6127">6127</span> +<span id="6128">6128</span> +<span id="6129">6129</span> +<span id="6130">6130</span> +<span id="6131">6131</span> +<span id="6132">6132</span> +<span id="6133">6133</span> +<span id="6134">6134</span> +<span id="6135">6135</span> +<span id="6136">6136</span> +<span id="6137">6137</span> +<span id="6138">6138</span> +<span id="6139">6139</span> +<span id="6140">6140</span> +<span id="6141">6141</span> +<span id="6142">6142</span> +<span id="6143">6143</span> +<span id="6144">6144</span> +<span id="6145">6145</span> +<span id="6146">6146</span> +<span id="6147">6147</span> +<span id="6148">6148</span> +<span id="6149">6149</span> +<span id="6150">6150</span> +<span id="6151">6151</span> +<span id="6152">6152</span> +<span id="6153">6153</span> +<span id="6154">6154</span> +<span id="6155">6155</span> +<span id="6156">6156</span> +<span id="6157">6157</span> +<span id="6158">6158</span> +<span id="6159">6159</span> +<span id="6160">6160</span> +<span id="6161">6161</span> +<span id="6162">6162</span> +<span id="6163">6163</span> +<span id="6164">6164</span> +<span id="6165">6165</span> +<span id="6166">6166</span> +<span id="6167">6167</span> +<span id="6168">6168</span> +<span id="6169">6169</span> +<span id="6170">6170</span> +<span id="6171">6171</span> +<span id="6172">6172</span> +<span id="6173">6173</span> +<span id="6174">6174</span> +<span id="6175">6175</span> +<span id="6176">6176</span> +<span id="6177">6177</span> +<span id="6178">6178</span> +<span id="6179">6179</span> +<span id="6180">6180</span> +<span id="6181">6181</span> +<span id="6182">6182</span> +<span id="6183">6183</span> +<span id="6184">6184</span> +<span id="6185">6185</span> +<span id="6186">6186</span> +<span id="6187">6187</span> +<span id="6188">6188</span> +<span id="6189">6189</span> +<span id="6190">6190</span> +<span id="6191">6191</span> +<span id="6192">6192</span> +<span id="6193">6193</span> +<span id="6194">6194</span> +<span id="6195">6195</span> +<span id="6196">6196</span> +<span id="6197">6197</span> +<span id="6198">6198</span> +<span id="6199">6199</span> +<span id="6200">6200</span> +<span id="6201">6201</span> +<span id="6202">6202</span> +<span id="6203">6203</span> +<span id="6204">6204</span> +<span id="6205">6205</span> +<span id="6206">6206</span> +<span id="6207">6207</span> +<span id="6208">6208</span> +<span id="6209">6209</span> +<span id="6210">6210</span> +<span id="6211">6211</span> +<span id="6212">6212</span> +<span id="6213">6213</span> +<span id="6214">6214</span> +<span id="6215">6215</span> +<span id="6216">6216</span> +<span id="6217">6217</span> +<span id="6218">6218</span> +<span id="6219">6219</span> +<span id="6220">6220</span> +<span id="6221">6221</span> +<span id="6222">6222</span> +<span id="6223">6223</span> +<span id="6224">6224</span> +<span id="6225">6225</span> +<span id="6226">6226</span> +<span id="6227">6227</span> +<span id="6228">6228</span> +<span id="6229">6229</span> +<span id="6230">6230</span> +<span id="6231">6231</span> +<span id="6232">6232</span> +<span id="6233">6233</span> +<span id="6234">6234</span> +<span id="6235">6235</span> +<span id="6236">6236</span> +<span id="6237">6237</span> +<span id="6238">6238</span> +<span id="6239">6239</span> +<span id="6240">6240</span> +<span id="6241">6241</span> +<span id="6242">6242</span> +<span id="6243">6243</span> +<span id="6244">6244</span> +<span id="6245">6245</span> +<span id="6246">6246</span> +<span id="6247">6247</span> +<span id="6248">6248</span> +<span id="6249">6249</span> +<span id="6250">6250</span> +<span id="6251">6251</span> +<span id="6252">6252</span> +<span id="6253">6253</span> +<span id="6254">6254</span> +<span id="6255">6255</span> +<span id="6256">6256</span> +<span id="6257">6257</span> +<span id="6258">6258</span> +<span id="6259">6259</span> +<span id="6260">6260</span> +<span id="6261">6261</span> +<span id="6262">6262</span> +<span id="6263">6263</span> +<span id="6264">6264</span> +<span id="6265">6265</span> +<span id="6266">6266</span> +<span id="6267">6267</span> +<span id="6268">6268</span> +<span id="6269">6269</span> +<span id="6270">6270</span> +<span id="6271">6271</span> +<span id="6272">6272</span> +<span id="6273">6273</span> +<span id="6274">6274</span> +<span id="6275">6275</span> +<span id="6276">6276</span> +<span id="6277">6277</span> +<span id="6278">6278</span> +<span id="6279">6279</span> +<span id="6280">6280</span> +<span id="6281">6281</span> +<span id="6282">6282</span> +<span id="6283">6283</span> +<span id="6284">6284</span> +<span id="6285">6285</span> +<span id="6286">6286</span> +<span id="6287">6287</span> +<span id="6288">6288</span> +<span id="6289">6289</span> +<span id="6290">6290</span> +<span id="6291">6291</span> +<span id="6292">6292</span> +<span id="6293">6293</span> +<span id="6294">6294</span> +<span id="6295">6295</span> +<span id="6296">6296</span> +<span id="6297">6297</span> +<span id="6298">6298</span> +<span id="6299">6299</span> +<span id="6300">6300</span> +<span id="6301">6301</span> +<span id="6302">6302</span> +<span id="6303">6303</span> +<span id="6304">6304</span> +<span id="6305">6305</span> +<span id="6306">6306</span> +<span id="6307">6307</span> +<span id="6308">6308</span> +<span id="6309">6309</span> +<span id="6310">6310</span> +<span id="6311">6311</span> +<span id="6312">6312</span> +<span id="6313">6313</span> +<span id="6314">6314</span> +<span id="6315">6315</span> +<span id="6316">6316</span> +<span id="6317">6317</span> +<span id="6318">6318</span> +<span id="6319">6319</span> +<span id="6320">6320</span> +<span id="6321">6321</span> +<span id="6322">6322</span> +<span id="6323">6323</span> +<span id="6324">6324</span> +<span id="6325">6325</span> +<span id="6326">6326</span> +<span id="6327">6327</span> +<span id="6328">6328</span> +<span id="6329">6329</span> +<span id="6330">6330</span> +<span id="6331">6331</span> +<span id="6332">6332</span> +<span id="6333">6333</span> +<span id="6334">6334</span> +<span id="6335">6335</span> +<span id="6336">6336</span> +<span id="6337">6337</span> +<span id="6338">6338</span> +<span id="6339">6339</span> +<span id="6340">6340</span> +<span id="6341">6341</span> +<span id="6342">6342</span> +<span id="6343">6343</span> +<span id="6344">6344</span> +<span id="6345">6345</span> +<span id="6346">6346</span> +<span id="6347">6347</span> +<span id="6348">6348</span> +<span id="6349">6349</span> +<span id="6350">6350</span> +<span id="6351">6351</span> +<span id="6352">6352</span> +<span id="6353">6353</span> +<span id="6354">6354</span> +<span id="6355">6355</span> +<span id="6356">6356</span> +<span id="6357">6357</span> +<span id="6358">6358</span> +<span id="6359">6359</span> +<span id="6360">6360</span> +<span id="6361">6361</span> +<span id="6362">6362</span> +<span id="6363">6363</span> +<span id="6364">6364</span> +<span id="6365">6365</span> +<span id="6366">6366</span> +<span id="6367">6367</span> +<span id="6368">6368</span> +<span id="6369">6369</span> +<span id="6370">6370</span> +<span id="6371">6371</span> +<span id="6372">6372</span> +<span id="6373">6373</span> +<span id="6374">6374</span> +<span id="6375">6375</span> +<span id="6376">6376</span> +<span id="6377">6377</span> +<span id="6378">6378</span> +<span id="6379">6379</span> +<span id="6380">6380</span> +<span id="6381">6381</span> +<span id="6382">6382</span> +<span id="6383">6383</span> +<span id="6384">6384</span> +<span id="6385">6385</span> +<span id="6386">6386</span> +</pre><pre class='rust '> +<span class='comment'>// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT</span> +<span class='comment'>// file at the top-level directory of this distribution and at</span> +<span class='comment'>// http://rust-lang.org/COPYRIGHT.</span> +<span class='comment'>//</span> +<span class='comment'>// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or</span> +<span class='comment'>// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license</span> +<span class='comment'>// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your</span> +<span class='comment'>// option. This file may not be copied, modified, or distributed</span> +<span class='comment'>// except according to those terms.</span> + +<span class='comment'>// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364)</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>cfg_attr</span>(<span class='ident'>stage0</span>, <span class='ident'>feature</span>(<span class='ident'>custom_attribute</span>))]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>crate_name</span> <span class='op'>=</span> <span class='string'>"libc"</span>]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>crate_type</span> <span class='op'>=</span> <span class='string'>"rlib"</span>]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>cfg_attr</span>(<span class='ident'>not</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"cargo-build"</span>), <span class='ident'>unstable</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"libc"</span>, + <span class='ident'>reason</span> <span class='op'>=</span> <span class='string'>"use `libc` from crates.io"</span>))]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>cfg_attr</span>(<span class='ident'>not</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"cargo-build"</span>), <span class='ident'>feature</span>(<span class='ident'>staged_api</span>, <span class='ident'>core</span>, <span class='ident'>no_std</span>))]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>cfg_attr</span>(<span class='ident'>not</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"cargo-build"</span>), <span class='ident'>staged_api</span>)]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>cfg_attr</span>(<span class='ident'>not</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"cargo-build"</span>), <span class='ident'>no_std</span>)]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>doc</span>(<span class='ident'>html_logo_url</span> <span class='op'>=</span> <span class='string'>"http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png"</span>, + <span class='ident'>html_favicon_url</span> <span class='op'>=</span> <span class='string'>"https://doc.rust-lang.org/favicon.ico"</span>, + <span class='ident'>html_root_url</span> <span class='op'>=</span> <span class='string'>"http://doc.rust-lang.org/nightly/"</span>, + <span class='ident'>html_playground_url</span> <span class='op'>=</span> <span class='string'>"http://play.rust-lang.org/"</span>)]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>cfg_attr</span>(<span class='ident'>test</span>, <span class='ident'>feature</span>(<span class='ident'>test</span>))]</span> + +<span class='doccomment'>//! Bindings for the C standard library and other platform libraries</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! **NOTE:** These are *architecture and libc* specific. On Linux, these</span> +<span class='doccomment'>//! bindings are only correct for glibc.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! This module contains bindings to the C standard library, organized into</span> +<span class='doccomment'>//! modules by their defining standard. Additionally, it contains some assorted</span> +<span class='doccomment'>//! platform-specific definitions. For convenience, most functions and types</span> +<span class='doccomment'>//! are reexported, so `use libc::*` will import the available C bindings as</span> +<span class='doccomment'>//! appropriate for the target platform. The exact set of functions available</span> +<span class='doccomment'>//! are platform specific.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! *Note:* Because these definitions are platform-specific, some may not appear</span> +<span class='doccomment'>//! in the generated documentation.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! We consider the following specs reasonably normative with respect to</span> +<span class='doccomment'>//! interoperating with the C standard library (libc/msvcrt):</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! * ISO 9899:1990 ('C95', 'ANSI C', 'Standard C'), NA1, 1995.</span> +<span class='doccomment'>//! * ISO 9899:1999 ('C99' or 'C9x').</span> +<span class='doccomment'>//! * ISO 9945:1988 / IEEE 1003.1-1988 ('POSIX.1').</span> +<span class='doccomment'>//! * ISO 9945:2001 / IEEE 1003.1-2001 ('POSIX:2001', 'SUSv3').</span> +<span class='doccomment'>//! * ISO 9945:2008 / IEEE 1003.1-2008 ('POSIX:2008', 'SUSv4').</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Note that any reference to the 1996 revision of POSIX, or any revs between</span> +<span class='doccomment'>//! 1990 (when '88 was approved at ISO) and 2001 (when the next actual</span> +<span class='doccomment'>//! revision-revision happened), are merely additions of other chapters (1b and</span> +<span class='doccomment'>//! 1c) outside the core interfaces.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Despite having several names each, these are *reasonably* coherent</span> +<span class='doccomment'>//! point-in-time, list-of-definition sorts of specs. You can get each under a</span> +<span class='doccomment'>//! variety of names but will wind up with the same definition in each case.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! See standards(7) in linux-manpages for more details.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Our interface to these libraries is complicated by the non-universality of</span> +<span class='doccomment'>//! conformance to any of them. About the only thing universally supported is</span> +<span class='doccomment'>//! the first (C95), beyond that definitions quickly become absent on various</span> +<span class='doccomment'>//! platforms.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! We therefore wind up dividing our module-space up (mostly for the sake of</span> +<span class='doccomment'>//! sanity while editing, filling-in-details and eliminating duplication) into</span> +<span class='doccomment'>//! definitions common-to-all (held in modules named c95, c99, posix88, posix01</span> +<span class='doccomment'>//! and posix08) and definitions that appear only on *some* platforms (named</span> +<span class='doccomment'>//! 'extra'). This would be things like significant OSX foundation kit, or Windows</span> +<span class='doccomment'>//! library kernel32.dll, or various fancy glibc, Linux or BSD extensions.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! In addition to the per-platform 'extra' modules, we define a module of</span> +<span class='doccomment'>//! 'common BSD' libc routines that never quite made it into POSIX but show up</span> +<span class='doccomment'>//! in multiple derived systems. This is the 4.4BSD r2 / 1995 release, the final</span> +<span class='doccomment'>//! one from Berkeley after the lawsuits died down and the CSRG dissolved.</span> + +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>allow</span>(<span class='ident'>bad_style</span>, <span class='ident'>raw_pointer_derive</span>)]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>cfg_attr</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>, <span class='ident'>allow</span>(<span class='ident'>unused_imports</span>))]</span> +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"cargo-build"</span>)]</span> <span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>std</span> <span class='kw'>as</span> <span class='ident'>core</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"cargo-build"</span>))]</span> <span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>core</span>; + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> <span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>std</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> <span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>test</span>; + +<span class='comment'>// Explicit export lists for the intersection (provided here) mean that</span> +<span class='comment'>// you can write more-platform-agnostic code if you stick to just these</span> +<span class='comment'>// symbols.</span> + +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c99</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>posix88</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>posix01</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>bsd44</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c99</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix01</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>extra</span>::<span class='op'>*</span>; + +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>consts</span>::<span class='ident'>os</span>::<span class='ident'>c95</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>consts</span>::<span class='ident'>os</span>::<span class='ident'>posix88</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>consts</span>::<span class='ident'>os</span>::<span class='ident'>posix01</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>consts</span>::<span class='ident'>os</span>::<span class='ident'>bsd44</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>consts</span>::<span class='ident'>os</span>::<span class='ident'>extra</span>::<span class='op'>*</span>; + +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>c95</span>::<span class='ident'>ctype</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>c95</span>::<span class='ident'>stdio</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>c95</span>::<span class='ident'>stdlib</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>c95</span>::<span class='ident'>string</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>posix88</span>::<span class='ident'>fcntl</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>posix88</span>::<span class='ident'>stat_</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>posix88</span>::<span class='ident'>stdio</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>posix88</span>::<span class='ident'>unistd</span>::<span class='op'>*</span>; + +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>bsd43</span>::<span class='op'>*</span>; + +<span class='comment'>// But we also reexport most everything</span> +<span class='comment'>// if you're interested in writing platform-specific code.</span> + +<span class='comment'>// FIXME: This is a mess, but the design of this entire module needs to be</span> +<span class='comment'>// reconsidered, so I'm not inclined to do better right now. As part of</span> +<span class='comment'>// #11870 I removed all the pub globs here, leaving explicit reexports</span> +<span class='comment'>// of everything that is actually used in-tree.</span> +<span class='comment'>//</span> +<span class='comment'>// So the following exports don't follow any particular plan.</span> + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>unix</span>)]</span> <span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>consts</span>::<span class='ident'>os</span>::<span class='ident'>sysconf</span>::<span class='op'>*</span>; + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>unix</span>)]</span> <span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>posix88</span>::<span class='ident'>mman</span>::<span class='op'>*</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>unix</span>)]</span> <span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>posix88</span>::<span class='ident'>dirent</span>::<span class='op'>*</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>unix</span>)]</span> <span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>posix88</span>::<span class='ident'>net</span>::<span class='op'>*</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>unix</span>)]</span> <span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>posix01</span>::<span class='ident'>stat_</span>::<span class='op'>*</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>unix</span>)]</span> <span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>posix01</span>::<span class='ident'>unistd</span>::<span class='op'>*</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>unix</span>)]</span> <span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>posix01</span>::<span class='ident'>resource</span>::<span class='op'>*</span>; + + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>windows</span>)]</span> <span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>extra</span>::<span class='ident'>kernel32</span>::<span class='op'>*</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>windows</span>)]</span> <span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>extra</span>::<span class='ident'>winsock</span>::<span class='op'>*</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>windows</span>)]</span> <span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>funcs</span>::<span class='ident'>extra</span>::<span class='ident'>msvcrt</span>::<span class='op'>*</span>; + +<span class='comment'>// On NaCl, these libraries are static. Thus it would be a Bad Idea to link them</span> +<span class='comment'>// in when creating a test crate.</span> +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>any</span>(<span class='ident'>windows</span>, <span class='ident'>target_env</span> <span class='op'>=</span> <span class='string'>"musl"</span>, <span class='ident'>all</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>, <span class='ident'>test</span>))))]</span> +<span class='attribute'>#[<span class='ident'>link</span>(<span class='ident'>name</span> <span class='op'>=</span> <span class='string'>"c"</span>)]</span> +<span class='attribute'>#[<span class='ident'>link</span>(<span class='ident'>name</span> <span class='op'>=</span> <span class='string'>"m"</span>)]</span> +<span class='kw'>extern</span> {} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>all</span>(<span class='ident'>target_env</span> <span class='op'>=</span> <span class='string'>"musl"</span>, <span class='ident'>not</span>(<span class='ident'>test</span>)))]</span> +<span class='attribute'>#[<span class='ident'>link</span>(<span class='ident'>name</span> <span class='op'>=</span> <span class='string'>"c"</span>, <span class='ident'>kind</span> <span class='op'>=</span> <span class='string'>"static"</span>)]</span> +<span class='kw'>extern</span> {} + +<span class='comment'>// libnacl provides functions that require a trip through the IRT to work.</span> +<span class='comment'>// ie: _exit, mmap, nanosleep, etc. Anything that would otherwise require a trip</span> +<span class='comment'>// to the kernel.</span> +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>all</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>, <span class='ident'>not</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"cargo-build"</span>), <span class='ident'>not</span>(<span class='ident'>test</span>)))]</span> +<span class='attribute'>#[<span class='ident'>link</span>(<span class='ident'>name</span> <span class='op'>=</span> <span class='string'>"nacl"</span>, <span class='ident'>kind</span> <span class='op'>=</span> <span class='string'>"static"</span>)]</span> +<span class='kw'>extern</span> {} + +<span class='comment'>// pnaclmm provides a number of functions that the toolchain's Clang emits calls</span> +<span class='comment'>// to when codegening atomic ops. All the functions within wrap various atomic</span> +<span class='comment'>// operations.</span> +<span class='comment'>// Yes, it could be linked by rustc explicitly, however by linking it here</span> +<span class='comment'>// instead we save a bit of time where bins are involved (by not running the</span> +<span class='comment'>// optimizations on the whole pnaclmm foreach binary built).</span> +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>all</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>, <span class='ident'>not</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"cargo-build"</span>), <span class='ident'>not</span>(<span class='ident'>test</span>)))]</span> +<span class='attribute'>#[<span class='ident'>link</span>(<span class='ident'>name</span> <span class='op'>=</span> <span class='string'>"pnaclmm"</span>, <span class='ident'>kind</span> <span class='op'>=</span> <span class='string'>"static"</span>)]</span> +<span class='kw'>extern</span> {} + +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>types</span> { + + <span class='comment'>// Types tend to vary *per architecture* so we pull their definitions out</span> + <span class='comment'>// into this module.</span> + + <span class='comment'>// Standard types that are opaque or common, so are not per-target.</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>common</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c95</span> { + <span class='doccomment'>/// Type used to construct void pointers for use with C.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This type is only useful as a pointer target. Do not use it as a</span> + <span class='doccomment'>/// return type for FFI functions which have the `void` return type in</span> + <span class='doccomment'>/// C. Use the unit type `()` or omit the return type instead.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// For LLVM to recognize the void pointer type and by extension</span> + <span class='doccomment'>/// functions like malloc(), we need to have it represented as i8* in</span> + <span class='doccomment'>/// LLVM bitcode. The enum used here ensures this and prevents misuse</span> + <span class='doccomment'>/// of the "raw" type by only having private variants.. We need two</span> + <span class='doccomment'>/// variants, because the compiler complains about the repr attribute</span> + <span class='doccomment'>/// otherwise.</span> + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>u8</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>c_void</span> { + <span class='ident'>__variant1</span>, + <span class='ident'>__variant2</span>, + } + + <span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>FILE</span> {} + <span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>fpos_t</span> {} + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c99</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>int8_t</span> <span class='op'>=</span> <span class='ident'>i8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>int16_t</span> <span class='op'>=</span> <span class='ident'>i16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>int32_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>int64_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uint8_t</span> <span class='op'>=</span> <span class='ident'>u8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uint16_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uint32_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uint64_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>DIR</span> {} + <span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>dirent_t</span> {} + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> {} + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix08</span> {} + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> {} + } + + <span class='comment'>// Standard types that are scalar but vary by OS and arch.</span> + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"linux"</span>, <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>, <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>os</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>common</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_ulong</span>, <span class='ident'>size_t</span>, + <span class='ident'>time_t</span>, <span class='ident'>suseconds_t</span>, <span class='ident'>c_long</span>}; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pthread_t</span> <span class='op'>=</span> <span class='ident'>c_ulong</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pthread_t</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>rlim_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>glob_t</span> { + <span class='kw'>pub</span> <span class='ident'>gl_pathc</span>: <span class='ident'>size_t</span>, + <span class='kw'>pub</span> <span class='ident'>gl_pathv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + <span class='kw'>pub</span> <span class='ident'>gl_offs</span>: <span class='ident'>size_t</span>, + + <span class='kw'>pub</span> <span class='ident'>__unused1</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused2</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused3</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused4</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused5</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>timeval</span> { + <span class='kw'>pub</span> <span class='ident'>tv_sec</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>tv_usec</span>: <span class='ident'>suseconds_t</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>timespec</span> { + <span class='kw'>pub</span> <span class='ident'>tv_sec</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>tv_nsec</span>: <span class='ident'>c_long</span>, + } + + <span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>timezone</span> {} + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>sighandler_t</span> <span class='op'>=</span> <span class='ident'>size_t</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>rlimit</span> { + <span class='kw'>pub</span> <span class='ident'>rlim_cur</span>: <span class='ident'>rlim_t</span>, + <span class='kw'>pub</span> <span class='ident'>rlim_max</span>: <span class='ident'>rlim_t</span>, + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd43</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>posix01</span>::<span class='ident'>timeval</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_long</span>; + <span class='comment'>// This is also specified in POSIX 2001, but only has two fields. All implementors</span> + <span class='comment'>// implement BSD 4.3 version.</span> + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>rusage</span> { + <span class='kw'>pub</span> <span class='ident'>ru_utime</span>: <span class='ident'>timeval</span>, + <span class='kw'>pub</span> <span class='ident'>ru_stime</span>: <span class='ident'>timeval</span>, + <span class='kw'>pub</span> <span class='ident'>ru_maxrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_ixrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_idrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_isrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_minflt</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_majflt</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nswap</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_inblock</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_oublock</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_msgsnd</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_msgrcv</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nsignals</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nvcsw</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nivcsw</span>: <span class='ident'>c_long</span> + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>, <span class='ident'>c_uint</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>socklen_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>sa_family_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>in_port_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>in_addr_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr</span> { + <span class='kw'>pub</span> <span class='ident'>sa_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sa_data</span>: [<span class='ident'>u8</span>; <span class='number'>14</span>], + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_storage</span> { + <span class='kw'>pub</span> <span class='ident'>ss_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>__ss_align</span>: <span class='ident'>isize</span>, + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_pointer_width</span> <span class='op'>=</span> <span class='string'>"32"</span>)]</span> + <span class='kw'>pub</span> <span class='ident'>__ss_pad2</span>: [<span class='ident'>u8</span>; <span class='number'>128</span> <span class='op'>-</span> <span class='number'>2</span> <span class='op'>*</span> <span class='number'>4</span>], + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_pointer_width</span> <span class='op'>=</span> <span class='string'>"64"</span>)]</span> + <span class='kw'>pub</span> <span class='ident'>__ss_pad2</span>: [<span class='ident'>u8</span>; <span class='number'>128</span> <span class='op'>-</span> <span class='number'>2</span> <span class='op'>*</span> <span class='number'>8</span>], + } + <span class='kw'>impl</span> ::<span class='ident'>core</span>::<span class='ident'>clone</span>::<span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>sockaddr_storage</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>sockaddr_storage</span> { <span class='op'>*</span><span class='self'>self</span> } + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_in</span> { + <span class='kw'>pub</span> <span class='ident'>sin_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin_port</span>: <span class='ident'>in_port_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin_addr</span>: <span class='ident'>in_addr</span>, + <span class='kw'>pub</span> <span class='ident'>sin_zero</span>: [<span class='ident'>u8</span>; <span class='number'>8</span>], + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>in_addr</span> { + <span class='kw'>pub</span> <span class='ident'>s_addr</span>: <span class='ident'>in_addr_t</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_in6</span> { + <span class='kw'>pub</span> <span class='ident'>sin6_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_port</span>: <span class='ident'>in_port_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_flowinfo</span>: <span class='ident'>u32</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_addr</span>: <span class='ident'>in6_addr</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_scope_id</span>: <span class='ident'>u32</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>in6_addr</span> { + <span class='kw'>pub</span> <span class='ident'>s6_addr</span>: [<span class='ident'>u16</span>; <span class='number'>8</span>] + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ip_mreq</span> { + <span class='kw'>pub</span> <span class='ident'>imr_multiaddr</span>: <span class='ident'>in_addr</span>, + <span class='kw'>pub</span> <span class='ident'>imr_interface</span>: <span class='ident'>in_addr</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ip6_mreq</span> { + <span class='kw'>pub</span> <span class='ident'>ipv6mr_multiaddr</span>: <span class='ident'>in6_addr</span>, + <span class='kw'>pub</span> <span class='ident'>ipv6mr_interface</span>: <span class='ident'>c_uint</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>addrinfo</span> { + <span class='kw'>pub</span> <span class='ident'>ai_flags</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_family</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_socktype</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_protocol</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_addrlen</span>: <span class='ident'>socklen_t</span>, + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"linux"</span>)]</span> + <span class='kw'>pub</span> <span class='ident'>ai_addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"linux"</span>)]</span> + <span class='kw'>pub</span> <span class='ident'>ai_canonname</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>, <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>))]</span> + <span class='kw'>pub</span> <span class='ident'>ai_canonname</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>, <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>))]</span> + <span class='kw'>pub</span> <span class='ident'>ai_addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + + <span class='kw'>pub</span> <span class='ident'>ai_next</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>addrinfo</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_un</span> { + <span class='kw'>pub</span> <span class='ident'>sun_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sun_path</span>: [<span class='ident'>c_char</span>; <span class='number'>108</span>] + } + <span class='kw'>impl</span> ::<span class='ident'>core</span>::<span class='ident'>clone</span>::<span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>sockaddr_un</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>sockaddr_un</span> { <span class='op'>*</span><span class='self'>self</span> } + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ifaddrs</span> { + <span class='kw'>pub</span> <span class='ident'>ifa_next</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ifaddrs</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_name</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_flags</span>: <span class='ident'>c_uint</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_netmask</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_ifu</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, <span class='comment'>// FIXME This should be a union</span> + <span class='kw'>pub</span> <span class='ident'>ifa_data</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span> + } + + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"arm"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"mips"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"mipsel"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"powerpc"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"le32"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>arch</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c95</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_char</span> <span class='op'>=</span> <span class='ident'>i8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_schar</span> <span class='op'>=</span> <span class='ident'>i8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_uchar</span> <span class='op'>=</span> <span class='ident'>u8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_short</span> <span class='op'>=</span> <span class='ident'>i16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ushort</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_long</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ulong</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_float</span> <span class='op'>=</span> <span class='ident'>f32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_double</span> <span class='op'>=</span> <span class='ident'>f64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>size_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ptrdiff_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>clock_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>time_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>suseconds_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>wchar_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c99</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_longlong</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ulonglong</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>intptr_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uintptr_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>intmax_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uintmax_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + } + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"mips"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"mipsel"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"powerpc"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"le32"</span>, + <span class='ident'>all</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"arm"</span>, <span class='ident'>not</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>))))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>off_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>dev_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ino_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pid_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uid_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>gid_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>useconds_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ssize_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + } + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>all</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"arm"</span>, <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>off_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>dev_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ino_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pid_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uid_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>gid_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>useconds_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ssize_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + } + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"le32"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"powerpc"</span>, + <span class='ident'>all</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"arm"</span>, <span class='ident'>not</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>))))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_short</span>, <span class='ident'>c_long</span>, <span class='ident'>time_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>dev_t</span>, <span class='ident'>gid_t</span>, <span class='ident'>ino_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>mode_t</span>, <span class='ident'>off_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>uid_t</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>nlink_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blksize_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blkcnt_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>stat</span> { + <span class='kw'>pub</span> <span class='ident'>st_dev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>__pad1</span>: <span class='ident'>c_short</span>, + <span class='kw'>pub</span> <span class='ident'>st_ino</span>: <span class='ident'>ino_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mode</span>: <span class='ident'>mode_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_nlink</span>: <span class='ident'>nlink_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_uid</span>: <span class='ident'>uid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_gid</span>: <span class='ident'>gid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_rdev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>__pad2</span>: <span class='ident'>c_short</span>, + <span class='kw'>pub</span> <span class='ident'>st_size</span>: <span class='ident'>off_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_blksize</span>: <span class='ident'>blksize_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_blocks</span>: <span class='ident'>blkcnt_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>__unused4</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>__unused5</span>: <span class='ident'>c_long</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>utimbuf</span> { + <span class='kw'>pub</span> <span class='ident'>actime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>modtime</span>: <span class='ident'>time_t</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>pthread_attr_t</span> { + <span class='kw'>pub</span> <span class='ident'>__size</span>: [<span class='ident'>u32</span>; <span class='number'>9</span>] + } + } + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>all</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"arm"</span>, <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_uchar</span>, <span class='ident'>c_uint</span>, <span class='ident'>c_ulong</span>, <span class='ident'>time_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c99</span>::{<span class='ident'>c_longlong</span>, <span class='ident'>c_ulonglong</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>uid_t</span>, <span class='ident'>gid_t</span>, <span class='ident'>ino_t</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>nlink_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blksize_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blkcnt_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>stat</span> { + <span class='kw'>pub</span> <span class='ident'>st_dev</span>: <span class='ident'>c_ulonglong</span>, + <span class='kw'>pub</span> <span class='ident'>__pad0</span>: [<span class='ident'>c_uchar</span>; <span class='number'>4</span>], + <span class='kw'>pub</span> <span class='ident'>__st_ino</span>: <span class='ident'>ino_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mode</span>: <span class='ident'>c_uint</span>, + <span class='kw'>pub</span> <span class='ident'>st_nlink</span>: <span class='ident'>c_uint</span>, + <span class='kw'>pub</span> <span class='ident'>st_uid</span>: <span class='ident'>uid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_gid</span>: <span class='ident'>gid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_rdev</span>: <span class='ident'>c_ulonglong</span>, + <span class='kw'>pub</span> <span class='ident'>__pad3</span>: [<span class='ident'>c_uchar</span>; <span class='number'>4</span>], + <span class='kw'>pub</span> <span class='ident'>st_size</span>: <span class='ident'>c_longlong</span>, + <span class='kw'>pub</span> <span class='ident'>st_blksize</span>: <span class='ident'>blksize_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_blocks</span>: <span class='ident'>c_ulonglong</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime_nsec</span>: <span class='ident'>c_ulong</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime_nsec</span>: <span class='ident'>c_ulong</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime_nsec</span>: <span class='ident'>c_ulong</span>, + <span class='kw'>pub</span> <span class='ident'>st_ino</span>: <span class='ident'>c_ulonglong</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>utimbuf</span> { + <span class='kw'>pub</span> <span class='ident'>actime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>modtime</span>: <span class='ident'>time_t</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>pthread_attr_t</span> { + <span class='kw'>pub</span> <span class='ident'>__size</span>: [<span class='ident'>u32</span>; <span class='number'>9</span>] + } + } + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"mips"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"mipsel"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_long</span>, <span class='ident'>c_ulong</span>, <span class='ident'>time_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>gid_t</span>, <span class='ident'>ino_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>mode_t</span>, <span class='ident'>off_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>uid_t</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>nlink_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blksize_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blkcnt_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>stat</span> { + <span class='kw'>pub</span> <span class='ident'>st_dev</span>: <span class='ident'>c_ulong</span>, + <span class='kw'>pub</span> <span class='ident'>st_pad1</span>: [<span class='ident'>c_long</span>; <span class='number'>3</span>], + <span class='kw'>pub</span> <span class='ident'>st_ino</span>: <span class='ident'>ino_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mode</span>: <span class='ident'>mode_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_nlink</span>: <span class='ident'>nlink_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_uid</span>: <span class='ident'>uid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_gid</span>: <span class='ident'>gid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_rdev</span>: <span class='ident'>c_ulong</span>, + <span class='kw'>pub</span> <span class='ident'>st_pad2</span>: [<span class='ident'>c_long</span>; <span class='number'>2</span>], + <span class='kw'>pub</span> <span class='ident'>st_size</span>: <span class='ident'>off_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_pad3</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_blksize</span>: <span class='ident'>blksize_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_blocks</span>: <span class='ident'>blkcnt_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_pad5</span>: [<span class='ident'>c_long</span>; <span class='number'>14</span>], + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>utimbuf</span> { + <span class='kw'>pub</span> <span class='ident'>actime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>modtime</span>: <span class='ident'>time_t</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>pthread_attr_t</span> { + <span class='kw'>pub</span> <span class='ident'>__size</span>: [<span class='ident'>u32</span>; <span class='number'>9</span>] + } + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix08</span> {} + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> {} + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_ushort</span>, <span class='ident'>c_int</span>, <span class='ident'>c_uchar</span>}; + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_ll</span> { + <span class='kw'>pub</span> <span class='ident'>sll_family</span>: <span class='ident'>c_ushort</span>, + <span class='kw'>pub</span> <span class='ident'>sll_protocol</span>: <span class='ident'>c_ushort</span>, + <span class='kw'>pub</span> <span class='ident'>sll_ifindex</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>sll_hatype</span>: <span class='ident'>c_ushort</span>, + <span class='kw'>pub</span> <span class='ident'>sll_pkttype</span>: <span class='ident'>c_uchar</span>, + <span class='kw'>pub</span> <span class='ident'>sll_halen</span>: <span class='ident'>c_uchar</span>, + <span class='kw'>pub</span> <span class='ident'>sll_addr</span>: [<span class='ident'>c_uchar</span>; <span class='number'>8</span>] + } + } + + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"aarch64"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>arch</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c95</span> { + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"aarch64"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_char</span> <span class='op'>=</span> <span class='ident'>i8</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"aarch64"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_char</span> <span class='op'>=</span> <span class='ident'>u8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_schar</span> <span class='op'>=</span> <span class='ident'>i8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_uchar</span> <span class='op'>=</span> <span class='ident'>u8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_short</span> <span class='op'>=</span> <span class='ident'>i16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ushort</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_long</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ulong</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_float</span> <span class='op'>=</span> <span class='ident'>f32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_double</span> <span class='op'>=</span> <span class='ident'>f64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>size_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ptrdiff_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>clock_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>time_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>suseconds_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"aarch64"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>wchar_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"aarch64"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>wchar_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c99</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_longlong</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ulonglong</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>intptr_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uintptr_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>intmax_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uintmax_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>off_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>dev_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ino_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pid_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uid_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>gid_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>useconds_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ssize_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + } + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"aarch64"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_long</span>, <span class='ident'>time_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>dev_t</span>, <span class='ident'>gid_t</span>, <span class='ident'>ino_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>mode_t</span>, <span class='ident'>off_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>uid_t</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>nlink_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blksize_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blkcnt_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>stat</span> { + <span class='kw'>pub</span> <span class='ident'>st_dev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ino</span>: <span class='ident'>ino_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_nlink</span>: <span class='ident'>nlink_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mode</span>: <span class='ident'>mode_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_uid</span>: <span class='ident'>uid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_gid</span>: <span class='ident'>gid_t</span>, + <span class='kw'>pub</span> <span class='ident'>__pad0</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>st_rdev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_size</span>: <span class='ident'>off_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_blksize</span>: <span class='ident'>blksize_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_blocks</span>: <span class='ident'>blkcnt_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>__unused</span>: [<span class='ident'>c_long</span>; <span class='number'>3</span>], + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>utimbuf</span> { + <span class='kw'>pub</span> <span class='ident'>actime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>modtime</span>: <span class='ident'>time_t</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>pthread_attr_t</span> { + <span class='kw'>pub</span> <span class='ident'>__size</span>: [<span class='ident'>u64</span>; <span class='number'>7</span>] + } + } + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"aarch64"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_long</span>, <span class='ident'>time_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>dev_t</span>, <span class='ident'>gid_t</span>, <span class='ident'>ino_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>mode_t</span>, <span class='ident'>off_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>uid_t</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>nlink_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blksize_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blkcnt_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>stat</span> { + <span class='kw'>pub</span> <span class='ident'>st_dev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ino</span>: <span class='ident'>ino_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mode</span>: <span class='ident'>mode_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_nlink</span>: <span class='ident'>nlink_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_uid</span>: <span class='ident'>uid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_gid</span>: <span class='ident'>gid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_rdev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>__pad1</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_size</span>: <span class='ident'>off_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_blksize</span>: <span class='ident'>blksize_t</span>, + <span class='kw'>pub</span> <span class='ident'>__pad2</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>st_blocks</span>: <span class='ident'>blkcnt_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>__unused</span>: [<span class='ident'>c_int</span>; <span class='number'>2</span>], + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>utimbuf</span> { + <span class='kw'>pub</span> <span class='ident'>actime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>modtime</span>: <span class='ident'>time_t</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>pthread_attr_t</span> { + <span class='kw'>pub</span> <span class='ident'>__size</span>: [<span class='ident'>u64</span>; <span class='number'>8</span>] + } + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix08</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_ushort</span>, <span class='ident'>c_int</span>, <span class='ident'>c_uchar</span>}; + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_ll</span> { + <span class='kw'>pub</span> <span class='ident'>sll_family</span>: <span class='ident'>c_ushort</span>, + <span class='kw'>pub</span> <span class='ident'>sll_protocol</span>: <span class='ident'>c_ushort</span>, + <span class='kw'>pub</span> <span class='ident'>sll_ifindex</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>sll_hatype</span>: <span class='ident'>c_ushort</span>, + <span class='kw'>pub</span> <span class='ident'>sll_pkttype</span>: <span class='ident'>c_uchar</span>, + <span class='kw'>pub</span> <span class='ident'>sll_halen</span>: <span class='ident'>c_uchar</span>, + <span class='kw'>pub</span> <span class='ident'>sll_addr</span>: [<span class='ident'>c_uchar</span>; <span class='number'>8</span>] + } + + } + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"freebsd"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>os</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>common</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>, <span class='ident'>size_t</span>, + <span class='ident'>time_t</span>, <span class='ident'>suseconds_t</span>, <span class='ident'>c_long</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c99</span>::{<span class='ident'>uintptr_t</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pthread_t</span> <span class='op'>=</span> <span class='ident'>uintptr_t</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>rlim_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>glob_t</span> { + <span class='kw'>pub</span> <span class='ident'>gl_pathc</span>: <span class='ident'>size_t</span>, + <span class='kw'>pub</span> <span class='ident'>__unused1</span>: <span class='ident'>size_t</span>, + <span class='kw'>pub</span> <span class='ident'>gl_offs</span>: <span class='ident'>size_t</span>, + <span class='kw'>pub</span> <span class='ident'>__unused2</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>gl_pathv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + + <span class='kw'>pub</span> <span class='ident'>__unused3</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + + <span class='kw'>pub</span> <span class='ident'>__unused4</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused5</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused6</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused7</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused8</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>timeval</span> { + <span class='kw'>pub</span> <span class='ident'>tv_sec</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>tv_usec</span>: <span class='ident'>suseconds_t</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>timespec</span> { + <span class='kw'>pub</span> <span class='ident'>tv_sec</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>tv_nsec</span>: <span class='ident'>c_long</span>, + } + + <span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>timezone</span> {} + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>sighandler_t</span> <span class='op'>=</span> <span class='ident'>size_t</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>rlimit</span> { + <span class='kw'>pub</span> <span class='ident'>rlim_cur</span>: <span class='ident'>rlim_t</span>, + <span class='kw'>pub</span> <span class='ident'>rlim_max</span>: <span class='ident'>rlim_t</span>, + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd43</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>posix01</span>::<span class='ident'>timeval</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_long</span>; + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>rusage</span> { + <span class='kw'>pub</span> <span class='ident'>ru_utime</span>: <span class='ident'>timeval</span>, + <span class='kw'>pub</span> <span class='ident'>ru_stime</span>: <span class='ident'>timeval</span>, + <span class='kw'>pub</span> <span class='ident'>ru_maxrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_ixrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_idrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_isrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_minflt</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_majflt</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nswap</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_inblock</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_oublock</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_msgsnd</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_msgrcv</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nsignals</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nvcsw</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nivcsw</span>: <span class='ident'>c_long</span> + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>, <span class='ident'>c_uint</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>socklen_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>sa_family_t</span> <span class='op'>=</span> <span class='ident'>u8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>in_port_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>in_addr_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr</span> { + <span class='kw'>pub</span> <span class='ident'>sa_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>sa_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sa_data</span>: [<span class='ident'>u8</span>; <span class='number'>14</span>], + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_storage</span> { + <span class='kw'>pub</span> <span class='ident'>ss_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>ss_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>__ss_pad1</span>: [<span class='ident'>u8</span>; <span class='number'>6</span>], + <span class='kw'>pub</span> <span class='ident'>__ss_align</span>: <span class='ident'>i64</span>, + <span class='kw'>pub</span> <span class='ident'>__ss_pad2</span>: [<span class='ident'>u8</span>; <span class='number'>112</span>], + } + <span class='kw'>impl</span> ::<span class='ident'>core</span>::<span class='ident'>clone</span>::<span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>sockaddr_storage</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>sockaddr_storage</span> { <span class='op'>*</span><span class='self'>self</span> } + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_in</span> { + <span class='kw'>pub</span> <span class='ident'>sin_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>sin_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin_port</span>: <span class='ident'>in_port_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin_addr</span>: <span class='ident'>in_addr</span>, + <span class='kw'>pub</span> <span class='ident'>sin_zero</span>: [<span class='ident'>u8</span>; <span class='number'>8</span>], + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>in_addr</span> { + <span class='kw'>pub</span> <span class='ident'>s_addr</span>: <span class='ident'>in_addr_t</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_in6</span> { + <span class='kw'>pub</span> <span class='ident'>sin6_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_port</span>: <span class='ident'>in_port_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_flowinfo</span>: <span class='ident'>u32</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_addr</span>: <span class='ident'>in6_addr</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_scope_id</span>: <span class='ident'>u32</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>in6_addr</span> { + <span class='kw'>pub</span> <span class='ident'>s6_addr</span>: [<span class='ident'>u16</span>; <span class='number'>8</span>] + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ip_mreq</span> { + <span class='kw'>pub</span> <span class='ident'>imr_multiaddr</span>: <span class='ident'>in_addr</span>, + <span class='kw'>pub</span> <span class='ident'>imr_interface</span>: <span class='ident'>in_addr</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ip6_mreq</span> { + <span class='kw'>pub</span> <span class='ident'>ipv6mr_multiaddr</span>: <span class='ident'>in6_addr</span>, + <span class='kw'>pub</span> <span class='ident'>ipv6mr_interface</span>: <span class='ident'>c_uint</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>addrinfo</span> { + <span class='kw'>pub</span> <span class='ident'>ai_flags</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_family</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_socktype</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_protocol</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_addrlen</span>: <span class='ident'>socklen_t</span>, + <span class='kw'>pub</span> <span class='ident'>ai_canonname</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + <span class='kw'>pub</span> <span class='ident'>ai_addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ai_next</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>addrinfo</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_un</span> { + <span class='kw'>pub</span> <span class='ident'>sun_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>sun_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sun_path</span>: [<span class='ident'>c_char</span>; <span class='number'>104</span>] + } + <span class='kw'>impl</span> ::<span class='ident'>core</span>::<span class='ident'>clone</span>::<span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>sockaddr_un</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>sockaddr_un</span> { <span class='op'>*</span><span class='self'>self</span> } + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ifaddrs</span> { + <span class='kw'>pub</span> <span class='ident'>ifa_next</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ifaddrs</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_name</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_flags</span>: <span class='ident'>c_uint</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_netmask</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_dstaddr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_data</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span> + } + + + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>arch</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c95</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_char</span> <span class='op'>=</span> <span class='ident'>i8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_schar</span> <span class='op'>=</span> <span class='ident'>i8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_uchar</span> <span class='op'>=</span> <span class='ident'>u8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_short</span> <span class='op'>=</span> <span class='ident'>i16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ushort</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_long</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ulong</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_float</span> <span class='op'>=</span> <span class='ident'>f32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_double</span> <span class='op'>=</span> <span class='ident'>f64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>size_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ptrdiff_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>clock_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>time_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>suseconds_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>wchar_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c99</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_longlong</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ulonglong</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>intptr_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uintptr_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>intmax_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uintmax_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>off_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>dev_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ino_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pid_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uid_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>gid_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>useconds_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ssize_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c99</span>::{<span class='ident'>uint8_t</span>, <span class='ident'>uint32_t</span>, <span class='ident'>int32_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_long</span>, <span class='ident'>time_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>dev_t</span>, <span class='ident'>gid_t</span>, <span class='ident'>ino_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>mode_t</span>, <span class='ident'>off_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>uid_t</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>nlink_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blksize_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blkcnt_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>fflags_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>stat</span> { + <span class='kw'>pub</span> <span class='ident'>st_dev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ino</span>: <span class='ident'>ino_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mode</span>: <span class='ident'>mode_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_nlink</span>: <span class='ident'>nlink_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_uid</span>: <span class='ident'>uid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_gid</span>: <span class='ident'>gid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_rdev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_size</span>: <span class='ident'>off_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_blocks</span>: <span class='ident'>blkcnt_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_blksize</span>: <span class='ident'>blksize_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_flags</span>: <span class='ident'>fflags_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_gen</span>: <span class='ident'>uint32_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_lspare</span>: <span class='ident'>int32_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_birthtime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_birthtime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>__unused</span>: [<span class='ident'>uint8_t</span>; <span class='number'>2</span>], + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>utimbuf</span> { + <span class='kw'>pub</span> <span class='ident'>actime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>modtime</span>: <span class='ident'>time_t</span>, + } + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pthread_attr_t</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix08</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + } + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"dragonfly"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>os</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>common</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>, <span class='ident'>size_t</span>, + <span class='ident'>time_t</span>, <span class='ident'>suseconds_t</span>, <span class='ident'>c_long</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c99</span>::{<span class='ident'>uintptr_t</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pthread_t</span> <span class='op'>=</span> <span class='ident'>uintptr_t</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>rlim_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>glob_t</span> { + <span class='kw'>pub</span> <span class='ident'>gl_pathc</span>: <span class='ident'>size_t</span>, + <span class='kw'>pub</span> <span class='ident'>__unused1</span>: <span class='ident'>size_t</span>, + <span class='kw'>pub</span> <span class='ident'>gl_offs</span>: <span class='ident'>size_t</span>, + <span class='kw'>pub</span> <span class='ident'>__unused2</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>gl_pathv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + + <span class='kw'>pub</span> <span class='ident'>__unused3</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + + <span class='kw'>pub</span> <span class='ident'>__unused4</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused5</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused6</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused7</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused8</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>timeval</span> { + <span class='kw'>pub</span> <span class='ident'>tv_sec</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>tv_usec</span>: <span class='ident'>suseconds_t</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>timespec</span> { + <span class='kw'>pub</span> <span class='ident'>tv_sec</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>tv_nsec</span>: <span class='ident'>c_long</span>, + } + + <span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>timezone</span> {} + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>sighandler_t</span> <span class='op'>=</span> <span class='ident'>size_t</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>rlimit</span> { + <span class='kw'>pub</span> <span class='ident'>rlim_cur</span>: <span class='ident'>rlim_t</span>, + <span class='kw'>pub</span> <span class='ident'>rlim_max</span>: <span class='ident'>rlim_t</span>, + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd43</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>posix01</span>::<span class='ident'>timeval</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_long</span>; + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>rusage</span> { + <span class='kw'>pub</span> <span class='ident'>ru_utime</span>: <span class='ident'>timeval</span>, + <span class='kw'>pub</span> <span class='ident'>ru_stime</span>: <span class='ident'>timeval</span>, + <span class='kw'>pub</span> <span class='ident'>ru_maxrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_ixrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_idrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_isrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_minflt</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_majflt</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nswap</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_inblock</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_oublock</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_msgsnd</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_msgrcv</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nsignals</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nvcsw</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nivcsw</span>: <span class='ident'>c_long</span> + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>, <span class='ident'>c_uint</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>socklen_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>sa_family_t</span> <span class='op'>=</span> <span class='ident'>u8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>in_port_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>in_addr_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr</span> { + <span class='kw'>pub</span> <span class='ident'>sa_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>sa_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sa_data</span>: [<span class='ident'>u8</span>; <span class='number'>14</span>], + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_storage</span> { + <span class='kw'>pub</span> <span class='ident'>ss_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>ss_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>__ss_pad1</span>: [<span class='ident'>u8</span>; <span class='number'>6</span>], + <span class='kw'>pub</span> <span class='ident'>__ss_align</span>: <span class='ident'>i64</span>, + <span class='kw'>pub</span> <span class='ident'>__ss_pad2</span>: [<span class='ident'>u8</span>; <span class='number'>112</span>], + } + <span class='kw'>impl</span> ::<span class='ident'>core</span>::<span class='ident'>clone</span>::<span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>sockaddr_storage</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>sockaddr_storage</span> { <span class='op'>*</span><span class='self'>self</span> } + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_in</span> { + <span class='kw'>pub</span> <span class='ident'>sin_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>sin_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin_port</span>: <span class='ident'>in_port_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin_addr</span>: <span class='ident'>in_addr</span>, + <span class='kw'>pub</span> <span class='ident'>sin_zero</span>: [<span class='ident'>u8</span>; <span class='number'>8</span>], + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>in_addr</span> { + <span class='kw'>pub</span> <span class='ident'>s_addr</span>: <span class='ident'>in_addr_t</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_in6</span> { + <span class='kw'>pub</span> <span class='ident'>sin6_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_port</span>: <span class='ident'>in_port_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_flowinfo</span>: <span class='ident'>u32</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_addr</span>: <span class='ident'>in6_addr</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_scope_id</span>: <span class='ident'>u32</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>in6_addr</span> { + <span class='kw'>pub</span> <span class='ident'>s6_addr</span>: [<span class='ident'>u16</span>; <span class='number'>8</span>] + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ip_mreq</span> { + <span class='kw'>pub</span> <span class='ident'>imr_multiaddr</span>: <span class='ident'>in_addr</span>, + <span class='kw'>pub</span> <span class='ident'>imr_interface</span>: <span class='ident'>in_addr</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ip6_mreq</span> { + <span class='kw'>pub</span> <span class='ident'>ipv6mr_multiaddr</span>: <span class='ident'>in6_addr</span>, + <span class='kw'>pub</span> <span class='ident'>ipv6mr_interface</span>: <span class='ident'>c_uint</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>addrinfo</span> { + <span class='kw'>pub</span> <span class='ident'>ai_flags</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_family</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_socktype</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_protocol</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_addrlen</span>: <span class='ident'>socklen_t</span>, + <span class='kw'>pub</span> <span class='ident'>ai_canonname</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + <span class='kw'>pub</span> <span class='ident'>ai_addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ai_next</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>addrinfo</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_un</span> { + <span class='kw'>pub</span> <span class='ident'>sun_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>sun_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sun_path</span>: [<span class='ident'>c_char</span>; <span class='number'>104</span>] + } + <span class='kw'>impl</span> ::<span class='ident'>core</span>::<span class='ident'>clone</span>::<span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>sockaddr_un</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>sockaddr_un</span> { <span class='op'>*</span><span class='self'>self</span> } + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ifaddrs</span> { + <span class='kw'>pub</span> <span class='ident'>ifa_next</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ifaddrs</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_name</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_flags</span>: <span class='ident'>c_uint</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_netmask</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_dstaddr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_data</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span> + } + + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>arch</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c95</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_char</span> <span class='op'>=</span> <span class='ident'>i8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_schar</span> <span class='op'>=</span> <span class='ident'>i8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_uchar</span> <span class='op'>=</span> <span class='ident'>u8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_short</span> <span class='op'>=</span> <span class='ident'>i16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ushort</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_long</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ulong</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_float</span> <span class='op'>=</span> <span class='ident'>f32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_double</span> <span class='op'>=</span> <span class='ident'>f64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>size_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ptrdiff_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>clock_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>time_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>suseconds_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>wchar_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c99</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_longlong</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ulonglong</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>intptr_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uintptr_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>intmax_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uintmax_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>off_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>dev_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pid_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uid_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>gid_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>useconds_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ssize_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c99</span>::{<span class='ident'>uint16_t</span>, <span class='ident'>uint32_t</span>, <span class='ident'>int32_t</span>, <span class='ident'>uint64_t</span>, <span class='ident'>int64_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_long</span>, <span class='ident'>time_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>dev_t</span>, <span class='ident'>gid_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>mode_t</span>, <span class='ident'>off_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>uid_t</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>nlink_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blksize_t</span> <span class='op'>=</span> <span class='ident'>uint32_t</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ino_t</span> <span class='op'>=</span> <span class='ident'>uint64_t</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blkcnt_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>fflags_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>stat</span> { + <span class='kw'>pub</span> <span class='ident'>st_ino</span>: <span class='ident'>ino_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_nlink</span>: <span class='ident'>nlink_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_dev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mode</span>: <span class='ident'>mode_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_padding1</span>: <span class='ident'>uint16_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_uid</span>: <span class='ident'>uid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_gid</span>: <span class='ident'>gid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_rdev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_size</span>: <span class='ident'>off_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_blocks</span>: <span class='ident'>blkcnt_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_blksize</span>: <span class='ident'>blksize_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_flags</span>: <span class='ident'>fflags_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_gen</span>: <span class='ident'>uint32_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_lspare</span>: <span class='ident'>int32_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_qspare1</span>: <span class='ident'>int64_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_qspare2</span>: <span class='ident'>int64_t</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>utimbuf</span> { + <span class='kw'>pub</span> <span class='ident'>actime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>modtime</span>: <span class='ident'>time_t</span>, + } + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pthread_attr_t</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix08</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + } + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"bitrig"</span>, <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"openbsd"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>os</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>common</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>, <span class='ident'>size_t</span>, + <span class='ident'>time_t</span>, <span class='ident'>suseconds_t</span>, <span class='ident'>c_long</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c99</span>::{<span class='ident'>uintptr_t</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pthread_t</span> <span class='op'>=</span> <span class='ident'>uintptr_t</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>rlim_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"bitrig"</span>)]</span> + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>glob_t</span> { + <span class='kw'>pub</span> <span class='ident'>gl_pathc</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>gl_matchc</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>gl_offs</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>gl_flags</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>gl_pathv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + <span class='kw'>pub</span> <span class='ident'>__unused1</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused2</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused3</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused4</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused5</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused6</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused7</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"openbsd"</span>)]</span> + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>glob_t</span> { + <span class='kw'>pub</span> <span class='ident'>gl_pathc</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>__unused1</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>gl_offs</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>__unused2</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>gl_pathv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + + <span class='kw'>pub</span> <span class='ident'>__unused3</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + + <span class='kw'>pub</span> <span class='ident'>__unused4</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused5</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused6</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused7</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused8</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused9</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>timeval</span> { + <span class='kw'>pub</span> <span class='ident'>tv_sec</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>tv_usec</span>: <span class='ident'>suseconds_t</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>timespec</span> { + <span class='kw'>pub</span> <span class='ident'>tv_sec</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>tv_nsec</span>: <span class='ident'>c_long</span>, + } + + <span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>timezone</span> {} + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>sighandler_t</span> <span class='op'>=</span> <span class='ident'>size_t</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>rlimit</span> { + <span class='kw'>pub</span> <span class='ident'>rlim_cur</span>: <span class='ident'>rlim_t</span>, + <span class='kw'>pub</span> <span class='ident'>rlim_max</span>: <span class='ident'>rlim_t</span>, + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd43</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>posix01</span>::<span class='ident'>timeval</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_long</span>; + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>rusage</span> { + <span class='kw'>pub</span> <span class='ident'>ru_utime</span>: <span class='ident'>timeval</span>, + <span class='kw'>pub</span> <span class='ident'>ru_stime</span>: <span class='ident'>timeval</span>, + <span class='kw'>pub</span> <span class='ident'>ru_maxrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_ixrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_idrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_isrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_minflt</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_majflt</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nswap</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_inblock</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_oublock</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_msgsnd</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_msgrcv</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nsignals</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nvcsw</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nivcsw</span>: <span class='ident'>c_long</span> + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>, <span class='ident'>c_uint</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>socklen_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>sa_family_t</span> <span class='op'>=</span> <span class='ident'>u8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>in_port_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>in_addr_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr</span> { + <span class='kw'>pub</span> <span class='ident'>sa_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>sa_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sa_data</span>: [<span class='ident'>u8</span>; <span class='number'>14</span>], + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_storage</span> { + <span class='kw'>pub</span> <span class='ident'>ss_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>ss_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>__ss_pad1</span>: [<span class='ident'>u8</span>; <span class='number'>6</span>], + <span class='kw'>pub</span> <span class='ident'>__ss_pad2</span>: <span class='ident'>i64</span>, + <span class='kw'>pub</span> <span class='ident'>__ss_pad3</span>: [<span class='ident'>u8</span>; <span class='number'>240</span>], + } + <span class='kw'>impl</span> ::<span class='ident'>core</span>::<span class='ident'>clone</span>::<span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>sockaddr_storage</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>sockaddr_storage</span> { <span class='op'>*</span><span class='self'>self</span> } + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_in</span> { + <span class='kw'>pub</span> <span class='ident'>sin_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>sin_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin_port</span>: <span class='ident'>in_port_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin_addr</span>: <span class='ident'>in_addr</span>, + <span class='kw'>pub</span> <span class='ident'>sin_zero</span>: [<span class='ident'>u8</span>; <span class='number'>8</span>], + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>in_addr</span> { + <span class='kw'>pub</span> <span class='ident'>s_addr</span>: <span class='ident'>in_addr_t</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_in6</span> { + <span class='kw'>pub</span> <span class='ident'>sin6_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_port</span>: <span class='ident'>in_port_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_flowinfo</span>: <span class='ident'>u32</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_addr</span>: <span class='ident'>in6_addr</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_scope_id</span>: <span class='ident'>u32</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>in6_addr</span> { + <span class='kw'>pub</span> <span class='ident'>s6_addr</span>: [<span class='ident'>u16</span>; <span class='number'>8</span>] + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ip_mreq</span> { + <span class='kw'>pub</span> <span class='ident'>imr_multiaddr</span>: <span class='ident'>in_addr</span>, + <span class='kw'>pub</span> <span class='ident'>imr_interface</span>: <span class='ident'>in_addr</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ip6_mreq</span> { + <span class='kw'>pub</span> <span class='ident'>ipv6mr_multiaddr</span>: <span class='ident'>in6_addr</span>, + <span class='kw'>pub</span> <span class='ident'>ipv6mr_interface</span>: <span class='ident'>c_uint</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>addrinfo</span> { + <span class='kw'>pub</span> <span class='ident'>ai_flags</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_family</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_socktype</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_protocol</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_addrlen</span>: <span class='ident'>socklen_t</span>, + <span class='kw'>pub</span> <span class='ident'>ai_addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ai_canonname</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + <span class='kw'>pub</span> <span class='ident'>ai_next</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>addrinfo</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_un</span> { + <span class='kw'>pub</span> <span class='ident'>sun_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>sun_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sun_path</span>: [<span class='ident'>c_char</span>; <span class='number'>104</span>] + } + <span class='kw'>impl</span> ::<span class='ident'>core</span>::<span class='ident'>clone</span>::<span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>sockaddr_un</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>sockaddr_un</span> { <span class='op'>*</span><span class='self'>self</span> } + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ifaddrs</span> { + <span class='kw'>pub</span> <span class='ident'>ifa_next</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ifaddrs</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_name</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_flags</span>: <span class='ident'>c_uint</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_netmask</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_dstaddr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_data</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span> + } + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>arch</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c95</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_char</span> <span class='op'>=</span> <span class='ident'>i8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_schar</span> <span class='op'>=</span> <span class='ident'>i8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_uchar</span> <span class='op'>=</span> <span class='ident'>u8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_short</span> <span class='op'>=</span> <span class='ident'>i16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ushort</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_long</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ulong</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_float</span> <span class='op'>=</span> <span class='ident'>f32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_double</span> <span class='op'>=</span> <span class='ident'>f64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>size_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ptrdiff_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>clock_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>time_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>suseconds_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>wchar_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c99</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_longlong</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ulonglong</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>intptr_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uintptr_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>intmax_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uintmax_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_long</span>}; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>off_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>dev_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pid_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uid_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>gid_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>useconds_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ssize_t</span> <span class='op'>=</span> <span class='ident'>c_long</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c99</span>::{<span class='ident'>uint32_t</span>, <span class='ident'>uint64_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_long</span>, <span class='ident'>time_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>dev_t</span>, <span class='ident'>gid_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>mode_t</span>, <span class='ident'>off_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>uid_t</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>nlink_t</span> <span class='op'>=</span> <span class='ident'>uint32_t</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blksize_t</span> <span class='op'>=</span> <span class='ident'>uint32_t</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ino_t</span> <span class='op'>=</span> <span class='ident'>uint64_t</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blkcnt_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>fflags_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; <span class='comment'>// type not declared, but struct stat have u_int32_t</span> + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>stat</span> { + <span class='kw'>pub</span> <span class='ident'>st_mode</span>: <span class='ident'>mode_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_dev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ino</span>: <span class='ident'>ino_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_nlink</span>: <span class='ident'>nlink_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_uid</span>: <span class='ident'>uid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_gid</span>: <span class='ident'>gid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_rdev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_size</span>: <span class='ident'>off_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_blocks</span>: <span class='ident'>blkcnt_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_blksize</span>: <span class='ident'>blksize_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_flags</span>: <span class='ident'>fflags_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_gen</span>: <span class='ident'>uint32_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_birthtime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_birthtime_nsec</span>: <span class='ident'>c_long</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>utimbuf</span> { + <span class='kw'>pub</span> <span class='ident'>actime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>modtime</span>: <span class='ident'>time_t</span>, + } + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pthread_attr_t</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix08</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + } + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"windows"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>os</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>common</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_short</span>, <span class='ident'>time_t</span>, <span class='ident'>c_long</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>extra</span>::{<span class='ident'>int64</span>, <span class='ident'>time64_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>dev_t</span>, <span class='ident'>ino_t</span>}; + + <span class='comment'>// pub Note: this is the struct called stat64 in Windows. Not stat,</span> + <span class='comment'>// nor stati64.</span> + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>stat</span> { + <span class='kw'>pub</span> <span class='ident'>st_dev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ino</span>: <span class='ident'>ino_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mode</span>: <span class='ident'>u16</span>, + <span class='kw'>pub</span> <span class='ident'>st_nlink</span>: <span class='ident'>c_short</span>, + <span class='kw'>pub</span> <span class='ident'>st_uid</span>: <span class='ident'>c_short</span>, + <span class='kw'>pub</span> <span class='ident'>st_gid</span>: <span class='ident'>c_short</span>, + <span class='kw'>pub</span> <span class='ident'>st_rdev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_size</span>: <span class='ident'>int64</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime</span>: <span class='ident'>time64_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime</span>: <span class='ident'>time64_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime</span>: <span class='ident'>time64_t</span>, + } + + <span class='comment'>// note that this is called utimbuf64 in Windows</span> + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>utimbuf</span> { + <span class='kw'>pub</span> <span class='ident'>actime</span>: <span class='ident'>time64_t</span>, + <span class='kw'>pub</span> <span class='ident'>modtime</span>: <span class='ident'>time64_t</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>timeval</span> { + <span class='kw'>pub</span> <span class='ident'>tv_sec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>tv_usec</span>: <span class='ident'>c_long</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>timespec</span> { + <span class='kw'>pub</span> <span class='ident'>tv_sec</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>tv_nsec</span>: <span class='ident'>c_long</span>, + } + + <span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>timezone</span> {} + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>, <span class='ident'>c_uint</span>, <span class='ident'>size_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c99</span>::<span class='ident'>uintptr_t</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>SOCKET</span> <span class='op'>=</span> <span class='ident'>uintptr_t</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>socklen_t</span> <span class='op'>=</span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>sa_family_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>in_port_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>in_addr_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr</span> { + <span class='kw'>pub</span> <span class='ident'>sa_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sa_data</span>: [<span class='ident'>u8</span>; <span class='number'>14</span>], + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_storage</span> { + <span class='kw'>pub</span> <span class='ident'>ss_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>__ss_pad1</span>: [<span class='ident'>u8</span>; <span class='number'>6</span>], + <span class='kw'>pub</span> <span class='ident'>__ss_align</span>: <span class='ident'>i64</span>, + <span class='kw'>pub</span> <span class='ident'>__ss_pad2</span>: [<span class='ident'>u8</span>; <span class='number'>112</span>], + } + <span class='kw'>impl</span> ::<span class='ident'>core</span>::<span class='ident'>clone</span>::<span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>sockaddr_storage</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>sockaddr_storage</span> { <span class='op'>*</span><span class='self'>self</span> } + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_in</span> { + <span class='kw'>pub</span> <span class='ident'>sin_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin_port</span>: <span class='ident'>in_port_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin_addr</span>: <span class='ident'>in_addr</span>, + <span class='kw'>pub</span> <span class='ident'>sin_zero</span>: [<span class='ident'>u8</span>; <span class='number'>8</span>], + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>in_addr</span> { + <span class='kw'>pub</span> <span class='ident'>s_addr</span>: <span class='ident'>in_addr_t</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_in6</span> { + <span class='kw'>pub</span> <span class='ident'>sin6_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_port</span>: <span class='ident'>in_port_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_flowinfo</span>: <span class='ident'>u32</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_addr</span>: <span class='ident'>in6_addr</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_scope_id</span>: <span class='ident'>u32</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>in6_addr</span> { + <span class='kw'>pub</span> <span class='ident'>s6_addr</span>: [<span class='ident'>u16</span>; <span class='number'>8</span>] + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ip_mreq</span> { + <span class='kw'>pub</span> <span class='ident'>imr_multiaddr</span>: <span class='ident'>in_addr</span>, + <span class='kw'>pub</span> <span class='ident'>imr_interface</span>: <span class='ident'>in_addr</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ip6_mreq</span> { + <span class='kw'>pub</span> <span class='ident'>ipv6mr_multiaddr</span>: <span class='ident'>in6_addr</span>, + <span class='kw'>pub</span> <span class='ident'>ipv6mr_interface</span>: <span class='ident'>c_uint</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>addrinfo</span> { + <span class='kw'>pub</span> <span class='ident'>ai_flags</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_family</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_socktype</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_protocol</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_addrlen</span>: <span class='ident'>size_t</span>, + <span class='kw'>pub</span> <span class='ident'>ai_canonname</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + <span class='kw'>pub</span> <span class='ident'>ai_addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ai_next</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>addrinfo</span>, + } + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_un</span> { + <span class='kw'>pub</span> <span class='ident'>sun_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sun_path</span>: [<span class='ident'>c_char</span>; <span class='number'>108</span>] + } + <span class='kw'>impl</span> ::<span class='ident'>core</span>::<span class='ident'>clone</span>::<span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>sockaddr_un</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>sockaddr_un</span> { <span class='op'>*</span><span class='self'>self</span> } + } + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>arch</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c95</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_char</span> <span class='op'>=</span> <span class='ident'>i8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_schar</span> <span class='op'>=</span> <span class='ident'>i8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_uchar</span> <span class='op'>=</span> <span class='ident'>u8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_short</span> <span class='op'>=</span> <span class='ident'>i16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ushort</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_long</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ulong</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_float</span> <span class='op'>=</span> <span class='ident'>f32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_double</span> <span class='op'>=</span> <span class='ident'>f64</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>size_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>size_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ptrdiff_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ptrdiff_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>clock_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>time_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>time_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>suseconds_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>suseconds_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>wchar_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c99</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_longlong</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ulonglong</span> <span class='op'>=</span> <span class='ident'>u64</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>intptr_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>intptr_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uintptr_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uintptr_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>intmax_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uintmax_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>off_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>dev_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ino_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pid_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>useconds_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ssize_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ssize_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix08</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + <span class='kw'>use</span> <span class='ident'>consts</span>::<span class='ident'>os</span>::<span class='ident'>extra</span>::{<span class='ident'>MAX_PROTOCOL_CHAIN</span>, + <span class='ident'>WSAPROTOCOL_LEN</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::<span class='ident'>c_void</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>, <span class='ident'>c_uint</span>, <span class='ident'>size_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_long</span>, <span class='ident'>c_ulong</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>wchar_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c99</span>::{<span class='ident'>c_ulonglong</span>, <span class='ident'>c_longlong</span>, <span class='ident'>uintptr_t</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>BOOL</span> <span class='op'>=</span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>BYTE</span> <span class='op'>=</span> <span class='ident'>u8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>BOOLEAN</span> <span class='op'>=</span> <span class='ident'>BYTE</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>CCHAR</span> <span class='op'>=</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>CHAR</span> <span class='op'>=</span> <span class='ident'>c_char</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='ident'>c_ulong</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>DWORDLONG</span> <span class='op'>=</span> <span class='ident'>c_ulonglong</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>HANDLE</span> <span class='op'>=</span> <span class='ident'>LPVOID</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>HINSTANCE</span> <span class='op'>=</span> <span class='ident'>HANDLE</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>HMODULE</span> <span class='op'>=</span> <span class='ident'>HINSTANCE</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LONG</span> <span class='op'>=</span> <span class='ident'>c_long</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>PLONG</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_long</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LONG_PTR</span> <span class='op'>=</span> <span class='ident'>c_long</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LONG_PTR</span> <span class='op'>=</span> <span class='ident'>i64</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LARGE_INTEGER</span> <span class='op'>=</span> <span class='ident'>c_longlong</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>PLARGE_INTEGER</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_longlong</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPCWSTR</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>WCHAR</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPCSTR</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>CHAR</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPWSTR</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>WCHAR</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPSTR</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>CHAR</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPWCH</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>WCHAR</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPCH</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>CHAR</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>SECURITY_ATTRIBUTES</span> { + <span class='kw'>pub</span> <span class='ident'>nLength</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>lpSecurityDescriptor</span>: <span class='ident'>LPVOID</span>, + <span class='kw'>pub</span> <span class='ident'>bInheritHandle</span>: <span class='ident'>BOOL</span>, + } + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPSECURITY_ATTRIBUTES</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SECURITY_ATTRIBUTES</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPVOID</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPCVOID</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPBYTE</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BYTE</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPWORD</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>WORD</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPDWORD</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>DWORD</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPHANDLE</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>HANDLE</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LRESULT</span> <span class='op'>=</span> <span class='ident'>LONG_PTR</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>PBOOL</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>WCHAR</span> <span class='op'>=</span> <span class='ident'>wchar_t</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>WORD</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>SIZE_T</span> <span class='op'>=</span> <span class='ident'>size_t</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>time64_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>int64</span> <span class='op'>=</span> <span class='ident'>i64</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>STARTUPINFO</span> { + <span class='kw'>pub</span> <span class='ident'>cb</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>lpReserved</span>: <span class='ident'>LPWSTR</span>, + <span class='kw'>pub</span> <span class='ident'>lpDesktop</span>: <span class='ident'>LPWSTR</span>, + <span class='kw'>pub</span> <span class='ident'>lpTitle</span>: <span class='ident'>LPWSTR</span>, + <span class='kw'>pub</span> <span class='ident'>dwX</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwY</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwXSize</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwYSize</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwXCountChars</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwYCountCharts</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwFillAttribute</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwFlags</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>wShowWindow</span>: <span class='ident'>WORD</span>, + <span class='kw'>pub</span> <span class='ident'>cbReserved2</span>: <span class='ident'>WORD</span>, + <span class='kw'>pub</span> <span class='ident'>lpReserved2</span>: <span class='ident'>LPBYTE</span>, + <span class='kw'>pub</span> <span class='ident'>hStdInput</span>: <span class='ident'>HANDLE</span>, + <span class='kw'>pub</span> <span class='ident'>hStdOutput</span>: <span class='ident'>HANDLE</span>, + <span class='kw'>pub</span> <span class='ident'>hStdError</span>: <span class='ident'>HANDLE</span>, + } + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPSTARTUPINFO</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>STARTUPINFO</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>PROCESS_INFORMATION</span> { + <span class='kw'>pub</span> <span class='ident'>hProcess</span>: <span class='ident'>HANDLE</span>, + <span class='kw'>pub</span> <span class='ident'>hThread</span>: <span class='ident'>HANDLE</span>, + <span class='kw'>pub</span> <span class='ident'>dwProcessId</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwThreadId</span>: <span class='ident'>DWORD</span>, + } + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPPROCESS_INFORMATION</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>PROCESS_INFORMATION</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>SYSTEM_INFO</span> { + <span class='kw'>pub</span> <span class='ident'>wProcessorArchitecture</span>: <span class='ident'>WORD</span>, + <span class='kw'>pub</span> <span class='ident'>wReserved</span>: <span class='ident'>WORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwPageSize</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>lpMinimumApplicationAddress</span>: <span class='ident'>LPVOID</span>, + <span class='kw'>pub</span> <span class='ident'>lpMaximumApplicationAddress</span>: <span class='ident'>LPVOID</span>, + <span class='kw'>pub</span> <span class='ident'>dwActiveProcessorMask</span>: <span class='ident'>uintptr_t</span>, + <span class='kw'>pub</span> <span class='ident'>dwNumberOfProcessors</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwProcessorType</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwAllocationGranularity</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>wProcessorLevel</span>: <span class='ident'>WORD</span>, + <span class='kw'>pub</span> <span class='ident'>wProcessorRevision</span>: <span class='ident'>WORD</span>, + } + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPSYSTEM_INFO</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SYSTEM_INFO</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>MEMORY_BASIC_INFORMATION</span> { + <span class='kw'>pub</span> <span class='ident'>BaseAddress</span>: <span class='ident'>LPVOID</span>, + <span class='kw'>pub</span> <span class='ident'>AllocationBase</span>: <span class='ident'>LPVOID</span>, + <span class='kw'>pub</span> <span class='ident'>AllocationProtect</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>RegionSize</span>: <span class='ident'>SIZE_T</span>, + <span class='kw'>pub</span> <span class='ident'>State</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>Protect</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>Type</span>: <span class='ident'>DWORD</span>, + } + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPMEMORY_BASIC_INFORMATION</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>MEMORY_BASIC_INFORMATION</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>OVERLAPPED</span> { + <span class='kw'>pub</span> <span class='ident'>Internal</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_ulong</span>, + <span class='kw'>pub</span> <span class='ident'>InternalHigh</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_ulong</span>, + <span class='kw'>pub</span> <span class='ident'>Offset</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>OffsetHigh</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>hEvent</span>: <span class='ident'>HANDLE</span>, + } + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPOVERLAPPED</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>OVERLAPPED</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>FILETIME</span> { + <span class='kw'>pub</span> <span class='ident'>dwLowDateTime</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwHighDateTime</span>: <span class='ident'>DWORD</span>, + } + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPFILETIME</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILETIME</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>GUID</span> { + <span class='kw'>pub</span> <span class='ident'>Data1</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>Data2</span>: <span class='ident'>WORD</span>, + <span class='kw'>pub</span> <span class='ident'>Data3</span>: <span class='ident'>WORD</span>, + <span class='kw'>pub</span> <span class='ident'>Data4</span>: [<span class='ident'>BYTE</span>; <span class='number'>8</span>], + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>WSAPROTOCOLCHAIN</span> { + <span class='kw'>pub</span> <span class='ident'>ChainLen</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ChainEntries</span>: [<span class='ident'>DWORD</span>; <span class='ident'>MAX_PROTOCOL_CHAIN</span> <span class='kw'>as</span> <span class='ident'>usize</span>], + } + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPWSAPROTOCOLCHAIN</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>WSAPROTOCOLCHAIN</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>WSAPROTOCOL_INFO</span> { + <span class='kw'>pub</span> <span class='ident'>dwServiceFlags1</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwServiceFlags2</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwServiceFlags3</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwServiceFlags4</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwProviderFlags</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>ProviderId</span>: <span class='ident'>GUID</span>, + <span class='kw'>pub</span> <span class='ident'>dwCatalogEntryId</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>ProtocolChain</span>: <span class='ident'>WSAPROTOCOLCHAIN</span>, + <span class='kw'>pub</span> <span class='ident'>iVersion</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>iAddressFamily</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>iMaxSockAddr</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>iMinSockAddr</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>iSocketType</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>iProtocol</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>iProtocolMaxOffset</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>iNetworkByteOrder</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>iSecurityScheme</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>dwMessageSize</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwProviderReserved</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>szProtocol</span>: [<span class='ident'>u8</span>; <span class='ident'>WSAPROTOCOL_LEN</span> <span class='kw'>as</span> <span class='ident'>usize</span> <span class='op'>+</span> <span class='number'>1</span>], + } + <span class='kw'>impl</span> ::<span class='ident'>core</span>::<span class='ident'>clone</span>::<span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>WSAPROTOCOL_INFO</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>WSAPROTOCOL_INFO</span> { <span class='op'>*</span><span class='self'>self</span> } + } + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPWSAPROTOCOL_INFO</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>WSAPROTOCOL_INFO</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>GROUP</span> <span class='op'>=</span> <span class='ident'>c_uint</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>WIN32_FIND_DATAW</span> { + <span class='kw'>pub</span> <span class='ident'>dwFileAttributes</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>ftCreationTime</span>: <span class='ident'>FILETIME</span>, + <span class='kw'>pub</span> <span class='ident'>ftLastAccessTime</span>: <span class='ident'>FILETIME</span>, + <span class='kw'>pub</span> <span class='ident'>ftLastWriteTime</span>: <span class='ident'>FILETIME</span>, + <span class='kw'>pub</span> <span class='ident'>nFileSizeHigh</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>nFileSizeLow</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwReserved0</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>dwReserved1</span>: <span class='ident'>DWORD</span>, + <span class='kw'>pub</span> <span class='ident'>cFileName</span>: [<span class='ident'>wchar_t</span>; <span class='number'>260</span>], <span class='comment'>// #define MAX_PATH 260</span> + <span class='kw'>pub</span> <span class='ident'>cAlternateFileName</span>: [<span class='ident'>wchar_t</span>; <span class='number'>14</span>], + } + <span class='kw'>impl</span> ::<span class='ident'>core</span>::<span class='ident'>clone</span>::<span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>WIN32_FIND_DATAW</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>WIN32_FIND_DATAW</span> { <span class='op'>*</span><span class='self'>self</span> } + } + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>LPWIN32_FIND_DATAW</span> <span class='op'>=</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>WIN32_FIND_DATAW</span>; + } + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"macos"</span>, <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"ios"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>os</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>common</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::<span class='ident'>c_void</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>, <span class='ident'>size_t</span>, <span class='ident'>time_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>suseconds_t</span>, <span class='ident'>c_long</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c99</span>::{<span class='ident'>uintptr_t</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pthread_t</span> <span class='op'>=</span> <span class='ident'>uintptr_t</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>rlim_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>glob_t</span> { + <span class='kw'>pub</span> <span class='ident'>gl_pathc</span>: <span class='ident'>size_t</span>, + <span class='kw'>pub</span> <span class='ident'>__unused1</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>gl_offs</span>: <span class='ident'>size_t</span>, + <span class='kw'>pub</span> <span class='ident'>__unused2</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>gl_pathv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + + <span class='kw'>pub</span> <span class='ident'>__unused3</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + + <span class='kw'>pub</span> <span class='ident'>__unused4</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused5</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused6</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused7</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>__unused8</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>timeval</span> { + <span class='kw'>pub</span> <span class='ident'>tv_sec</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>tv_usec</span>: <span class='ident'>suseconds_t</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>timespec</span> { + <span class='kw'>pub</span> <span class='ident'>tv_sec</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>tv_nsec</span>: <span class='ident'>c_long</span>, + } + + <span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>timezone</span> {} + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>sighandler_t</span> <span class='op'>=</span> <span class='ident'>size_t</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>rlimit</span> { + <span class='kw'>pub</span> <span class='ident'>rlim_cur</span>: <span class='ident'>rlim_t</span>, + <span class='kw'>pub</span> <span class='ident'>rlim_max</span>: <span class='ident'>rlim_t</span>, + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd43</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>posix01</span>::<span class='ident'>timeval</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_long</span>; + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>rusage</span> { + <span class='kw'>pub</span> <span class='ident'>ru_utime</span>: <span class='ident'>timeval</span>, + <span class='kw'>pub</span> <span class='ident'>ru_stime</span>: <span class='ident'>timeval</span>, + <span class='kw'>pub</span> <span class='ident'>ru_maxrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_ixrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_idrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_isrss</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_minflt</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_majflt</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nswap</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_inblock</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_oublock</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_msgsnd</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_msgrcv</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nsignals</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nvcsw</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>ru_nivcsw</span>: <span class='ident'>c_long</span> + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>, <span class='ident'>c_uint</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>socklen_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>sa_family_t</span> <span class='op'>=</span> <span class='ident'>u8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>in_port_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>in_addr_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr</span> { + <span class='kw'>pub</span> <span class='ident'>sa_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>sa_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sa_data</span>: [<span class='ident'>u8</span>; <span class='number'>14</span>], + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_storage</span> { + <span class='kw'>pub</span> <span class='ident'>ss_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>ss_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>__ss_pad1</span>: [<span class='ident'>u8</span>; <span class='number'>6</span>], + <span class='kw'>pub</span> <span class='ident'>__ss_align</span>: <span class='ident'>i64</span>, + <span class='kw'>pub</span> <span class='ident'>__ss_pad2</span>: [<span class='ident'>u8</span>; <span class='number'>112</span>], + } + <span class='kw'>impl</span> ::<span class='ident'>core</span>::<span class='ident'>clone</span>::<span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>sockaddr_storage</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>sockaddr_storage</span> { <span class='op'>*</span><span class='self'>self</span> } + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_in</span> { + <span class='kw'>pub</span> <span class='ident'>sin_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>sin_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin_port</span>: <span class='ident'>in_port_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin_addr</span>: <span class='ident'>in_addr</span>, + <span class='kw'>pub</span> <span class='ident'>sin_zero</span>: [<span class='ident'>u8</span>; <span class='number'>8</span>], + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>in_addr</span> { + <span class='kw'>pub</span> <span class='ident'>s_addr</span>: <span class='ident'>in_addr_t</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_in6</span> { + <span class='kw'>pub</span> <span class='ident'>sin6_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_port</span>: <span class='ident'>in_port_t</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_flowinfo</span>: <span class='ident'>u32</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_addr</span>: <span class='ident'>in6_addr</span>, + <span class='kw'>pub</span> <span class='ident'>sin6_scope_id</span>: <span class='ident'>u32</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>in6_addr</span> { + <span class='kw'>pub</span> <span class='ident'>s6_addr</span>: [<span class='ident'>u16</span>; <span class='number'>8</span>] + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ip_mreq</span> { + <span class='kw'>pub</span> <span class='ident'>imr_multiaddr</span>: <span class='ident'>in_addr</span>, + <span class='kw'>pub</span> <span class='ident'>imr_interface</span>: <span class='ident'>in_addr</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ip6_mreq</span> { + <span class='kw'>pub</span> <span class='ident'>ipv6mr_multiaddr</span>: <span class='ident'>in6_addr</span>, + <span class='kw'>pub</span> <span class='ident'>ipv6mr_interface</span>: <span class='ident'>c_uint</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>addrinfo</span> { + <span class='kw'>pub</span> <span class='ident'>ai_flags</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_family</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_socktype</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_protocol</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>ai_addrlen</span>: <span class='ident'>socklen_t</span>, + <span class='kw'>pub</span> <span class='ident'>ai_canonname</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + <span class='kw'>pub</span> <span class='ident'>ai_addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ai_next</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>addrinfo</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>sockaddr_un</span> { + <span class='kw'>pub</span> <span class='ident'>sun_len</span>: <span class='ident'>u8</span>, + <span class='kw'>pub</span> <span class='ident'>sun_family</span>: <span class='ident'>sa_family_t</span>, + <span class='kw'>pub</span> <span class='ident'>sun_path</span>: [<span class='ident'>c_char</span>; <span class='number'>104</span>] + } + <span class='kw'>impl</span> ::<span class='ident'>core</span>::<span class='ident'>clone</span>::<span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>sockaddr_un</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>sockaddr_un</span> { <span class='op'>*</span><span class='self'>self</span> } + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ifaddrs</span> { + <span class='kw'>pub</span> <span class='ident'>ifa_next</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ifaddrs</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_name</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_flags</span>: <span class='ident'>c_uint</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_netmask</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_dstaddr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='kw'>pub</span> <span class='ident'>ifa_data</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span> + } + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"arm"</span>, <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>arch</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c95</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_char</span> <span class='op'>=</span> <span class='ident'>i8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_schar</span> <span class='op'>=</span> <span class='ident'>i8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_uchar</span> <span class='op'>=</span> <span class='ident'>u8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_short</span> <span class='op'>=</span> <span class='ident'>i16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ushort</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_long</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ulong</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_float</span> <span class='op'>=</span> <span class='ident'>f32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_double</span> <span class='op'>=</span> <span class='ident'>f64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>size_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ptrdiff_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>clock_t</span> <span class='op'>=</span> <span class='ident'>c_ulong</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>time_t</span> <span class='op'>=</span> <span class='ident'>c_long</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>suseconds_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>wchar_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c99</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_longlong</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ulonglong</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>intptr_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uintptr_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>intmax_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uintmax_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_long</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>off_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>dev_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ino_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pid_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uid_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>gid_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>useconds_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ssize_t</span> <span class='op'>=</span> <span class='ident'>c_long</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c99</span>::{<span class='ident'>int32_t</span>, <span class='ident'>int64_t</span>, <span class='ident'>uint32_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_long</span>, <span class='ident'>time_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>dev_t</span>, <span class='ident'>gid_t</span>, <span class='ident'>ino_t</span>, + <span class='ident'>mode_t</span>, <span class='ident'>off_t</span>, <span class='ident'>uid_t</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>nlink_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blksize_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blkcnt_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>stat</span> { + <span class='kw'>pub</span> <span class='ident'>st_dev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mode</span>: <span class='ident'>mode_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_nlink</span>: <span class='ident'>nlink_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ino</span>: <span class='ident'>ino_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_uid</span>: <span class='ident'>uid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_gid</span>: <span class='ident'>gid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_rdev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_birthtime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_birthtime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_size</span>: <span class='ident'>off_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_blocks</span>: <span class='ident'>blkcnt_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_blksize</span>: <span class='ident'>blksize_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_flags</span>: <span class='ident'>uint32_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_gen</span>: <span class='ident'>uint32_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_lspare</span>: <span class='ident'>int32_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_qspare</span>: [<span class='ident'>int64_t</span>; <span class='number'>2</span>], + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>utimbuf</span> { + <span class='kw'>pub</span> <span class='ident'>actime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>modtime</span>: <span class='ident'>time_t</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>pthread_attr_t</span> { + <span class='kw'>pub</span> <span class='ident'>__sig</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>__opaque</span>: [<span class='ident'>c_char</span>; <span class='number'>36</span>] + } + <span class='kw'>impl</span> ::<span class='ident'>core</span>::<span class='ident'>clone</span>::<span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>pthread_attr_t</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>pthread_attr_t</span> { <span class='op'>*</span><span class='self'>self</span> } + } + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix08</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>mach_timebase_info</span> { + <span class='kw'>pub</span> <span class='ident'>numer</span>: <span class='ident'>u32</span>, + <span class='kw'>pub</span> <span class='ident'>denom</span>: <span class='ident'>u32</span>, + } + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>mach_timebase_info_data_t</span> <span class='op'>=</span> <span class='ident'>mach_timebase_info</span>; + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>, <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"aarch64"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>arch</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c95</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_char</span> <span class='op'>=</span> <span class='ident'>i8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_schar</span> <span class='op'>=</span> <span class='ident'>i8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_uchar</span> <span class='op'>=</span> <span class='ident'>u8</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_short</span> <span class='op'>=</span> <span class='ident'>i16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ushort</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_long</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ulong</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_float</span> <span class='op'>=</span> <span class='ident'>f32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_double</span> <span class='op'>=</span> <span class='ident'>f64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>size_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ptrdiff_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>clock_t</span> <span class='op'>=</span> <span class='ident'>c_ulong</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>time_t</span> <span class='op'>=</span> <span class='ident'>c_long</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>suseconds_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>wchar_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c99</span> { + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_longlong</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>c_ulonglong</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>intptr_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uintptr_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>intmax_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uintmax_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_long</span>; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>off_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>dev_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ino_t</span> <span class='op'>=</span> <span class='ident'>u64</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>pid_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>uid_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>gid_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>useconds_t</span> <span class='op'>=</span> <span class='ident'>u32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ssize_t</span> <span class='op'>=</span> <span class='ident'>c_long</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c99</span>::{<span class='ident'>int32_t</span>, <span class='ident'>int64_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c99</span>::{<span class='ident'>uint32_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_long</span>, <span class='ident'>time_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>dev_t</span>, <span class='ident'>gid_t</span>, <span class='ident'>ino_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>mode_t</span>, <span class='ident'>off_t</span>, <span class='ident'>uid_t</span>}; + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>nlink_t</span> <span class='op'>=</span> <span class='ident'>u16</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blksize_t</span> <span class='op'>=</span> <span class='ident'>i32</span>; + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>blkcnt_t</span> <span class='op'>=</span> <span class='ident'>i64</span>; + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>stat</span> { + <span class='kw'>pub</span> <span class='ident'>st_dev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mode</span>: <span class='ident'>mode_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_nlink</span>: <span class='ident'>nlink_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ino</span>: <span class='ident'>ino_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_uid</span>: <span class='ident'>uid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_gid</span>: <span class='ident'>gid_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_rdev</span>: <span class='ident'>dev_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_atime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_mtime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_ctime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_birthtime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_birthtime_nsec</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>st_size</span>: <span class='ident'>off_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_blocks</span>: <span class='ident'>blkcnt_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_blksize</span>: <span class='ident'>blksize_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_flags</span>: <span class='ident'>uint32_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_gen</span>: <span class='ident'>uint32_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_lspare</span>: <span class='ident'>int32_t</span>, + <span class='kw'>pub</span> <span class='ident'>st_qspare</span>: [<span class='ident'>int64_t</span>; <span class='number'>2</span>], + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>utimbuf</span> { + <span class='kw'>pub</span> <span class='ident'>actime</span>: <span class='ident'>time_t</span>, + <span class='kw'>pub</span> <span class='ident'>modtime</span>: <span class='ident'>time_t</span>, + } + + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>pthread_attr_t</span> { + <span class='kw'>pub</span> <span class='ident'>__sig</span>: <span class='ident'>c_long</span>, + <span class='kw'>pub</span> <span class='ident'>__opaque</span>: [<span class='ident'>c_char</span>; <span class='number'>56</span>] + } + <span class='kw'>impl</span> ::<span class='ident'>core</span>::<span class='ident'>clone</span>::<span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>pthread_attr_t</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>pthread_attr_t</span> { <span class='op'>*</span><span class='self'>self</span> } + } + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix08</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> <span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>mach_timebase_info</span> { + <span class='kw'>pub</span> <span class='ident'>numer</span>: <span class='ident'>u32</span>, + <span class='kw'>pub</span> <span class='ident'>denom</span>: <span class='ident'>u32</span>, + } + + <span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>mach_timebase_info_data_t</span> <span class='op'>=</span> <span class='ident'>mach_timebase_info</span>; + } + } + } +} + +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>consts</span> { + <span class='comment'>// Consts tend to vary per OS so we pull their definitions out</span> + <span class='comment'>// into this module.</span> + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"windows"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>os</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c95</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_uint</span>}; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EXIT_FAILURE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EXIT_SUCCESS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RAND_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>32767</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEEK_SET</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEEK_CUR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEEK_END</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_IOFBF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_IONBF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_IOLBF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>BUFSIZ</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>512</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FOPEN_MAX</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILENAME_MAX</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>260</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>L_tmpnam</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TMP_MAX</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>32767</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEINTR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEBADF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10009</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEACCES</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10013</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEFAULT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10014</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEINVAL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10022</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEMFILE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10024</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEWOULDBLOCK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10035</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEINPROGRESS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10036</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEALREADY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10037</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAENOTSOCK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10038</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEDESTADDRREQ</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10039</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEMSGSIZE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10040</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEPROTOTYPE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10041</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAENOPROTOOPT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10042</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEPROTONOSUPPORT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10043</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAESOCKTNOSUPPORT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10044</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEOPNOTSUPP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10045</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEPFNOSUPPORT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10046</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEAFNOSUPPORT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10047</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEADDRINUSE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10048</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEADDRNOTAVAIL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10049</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAENETDOWN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10050</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAENETUNREACH</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10051</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAENETRESET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10052</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAECONNABORTED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10053</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAECONNRESET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10054</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAENOBUFS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10055</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEISCONN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10056</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAENOTCONN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10057</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAESHUTDOWN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10058</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAETOOMANYREFS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10059</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAETIMEDOUT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10060</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAECONNREFUSED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10061</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAELOOP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10062</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAENAMETOOLONG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10063</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEHOSTDOWN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10064</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEHOSTUNREACH</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10065</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAENOTEMPTY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10066</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEPROCLIM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10067</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEUSERS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10068</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEDQUOT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10069</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAESTALE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10070</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEREMOTE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10071</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSASYSNOTREADY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10091</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAVERNOTSUPPORTED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10092</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSANOTINITIALISED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10093</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEDISCON</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10101</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAENOMORE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10102</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAECANCELLED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10103</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEINVALIDPROCTABLE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10104</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEINVALIDPROVIDER</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10105</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAEPROVIDERFAILEDINIT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10106</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c99</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::<span class='ident'>mode_t</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_RDONLY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_WRONLY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_RDWR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_APPEND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_CREAT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>256</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_EXCL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1024</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_TRUNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>512</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFIFO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4096</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFCHR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8192</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFBLK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12288</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFDIR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16384</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFREG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>32768</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFLNK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>40960</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFMT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>61440</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IEXEC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWRITE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IREAD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>256</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXU</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>448</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXUSR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWUSR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRUSR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>256</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXG</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>56</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>32</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXO</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXOTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWOTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IROTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>R_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>W_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDIN_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDOUT_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDERR_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix08</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_INET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_INET6</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>23</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_STREAM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_DGRAM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_RAW</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_TCP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_IP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_IPV6</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>41</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_MULTICAST_TTL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_MULTICAST_LOOP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_ADD_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_DROP_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPV6_ADD_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPV6_DROP_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_TTL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_HDRINCL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_NODELAY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOL_SOCKET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0xffff</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_DEBUG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_ACCEPTCONN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_REUSEADDR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_KEEPALIVE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0008</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_DONTROUTE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0010</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_BROADCAST</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0020</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_USELOOPBACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0040</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_LINGER</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0080</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_OOBINLINE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0100</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDBUF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVBUF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDLOWAT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1003</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVLOWAT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDTIMEO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1005</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVTIMEO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1006</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_ERROR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1007</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_TYPE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1008</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IFF_LOOPBACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_RD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_WR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_RDWR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>bsd44</span>::<span class='ident'>SOCKET</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_long</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>extra</span>::{<span class='ident'>WORD</span>, <span class='ident'>DWORD</span>, <span class='ident'>BOOL</span>, <span class='ident'>HANDLE</span>}; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TRUE</span> : <span class='ident'>BOOL</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FALSE</span> : <span class='ident'>BOOL</span> <span class='op'>=</span> <span class='number'>0</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_TEXT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16384</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_BINARY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>32768</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_NOINHERIT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>128</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_SUCCESS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_INVALID_FUNCTION</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_FILE_NOT_FOUND</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_ACCESS_DENIED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_INVALID_HANDLE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_BROKEN_PIPE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>109</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_DISK_FULL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>112</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_CALL_NOT_IMPLEMENTED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>120</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_INSUFFICIENT_BUFFER</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>122</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_INVALID_NAME</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>123</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_ALREADY_EXISTS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>183</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_PIPE_BUSY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>231</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_NO_DATA</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>232</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_INVALID_ADDRESS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>487</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_PIPE_CONNECTED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>535</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_NOTHING_TO_TERMINATE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>758</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_OPERATION_ABORTED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>995</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_IO_PENDING</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>997</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_FILE_INVALID</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1006</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERROR_NOT_FOUND</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1168</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>INVALID_HANDLE_VALUE</span>: <span class='ident'>HANDLE</span> <span class='op'>=</span> <span class='op'>!</span><span class='number'>0</span> <span class='kw'>as</span> <span class='ident'>HANDLE</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>DELETE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00010000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>READ_CONTROL</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00020000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SYNCHRONIZE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00100000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WRITE_DAC</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00040000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WRITE_OWNER</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00080000</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROCESS_CREATE_PROCESS</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x0080</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROCESS_CREATE_THREAD</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROCESS_DUP_HANDLE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x0040</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROCESS_QUERY_INFORMATION</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x0400</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROCESS_QUERY_LIMITED_INFORMATION</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x1000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROCESS_SET_INFORMATION</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x0200</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROCESS_SET_QUOTA</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x0100</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROCESS_SUSPEND_RESUME</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x0800</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROCESS_TERMINATE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROCESS_VM_OPERATION</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x0008</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROCESS_VM_READ</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x0010</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROCESS_VM_WRITE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x0020</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STARTF_FORCEONFEEDBACK</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000040</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STARTF_FORCEOFFFEEDBACK</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000080</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STARTF_PREVENTPINNING</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00002000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STARTF_RUNFULLSCREEN</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000020</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STARTF_TITLEISAPPID</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00001000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STARTF_TITLEISLINKNAME</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000800</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STARTF_USECOUNTCHARS</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000008</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STARTF_USEFILLATTRIBUTE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000010</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STARTF_USEHOTKEY</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000200</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STARTF_USEPOSITION</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STARTF_USESHOWWINDOW</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STARTF_USESIZE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STARTF_USESTDHANDLES</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000100</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WAIT_ABANDONED</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000080</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WAIT_OBJECT_0</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WAIT_TIMEOUT</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000102</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WAIT_FAILED</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='op'>!</span><span class='number'>0</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>DUPLICATE_CLOSE_SOURCE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>DUPLICATE_SAME_ACCESS</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000002</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>INFINITE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='op'>!</span><span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STILL_ACTIVE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>259</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MEM_COMMIT</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00001000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MEM_RESERVE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00002000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MEM_DECOMMIT</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00004000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MEM_RELEASE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00008000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MEM_RESET</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00080000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MEM_RESET_UNDO</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x1000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MEM_LARGE_PAGES</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x20000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MEM_PHYSICAL</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00400000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MEM_TOP_DOWN</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00100000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MEM_WRITE_WATCH</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00200000</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PAGE_EXECUTE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PAGE_EXECUTE_READ</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PAGE_EXECUTE_READWRITE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x40</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PAGE_EXECUTE_WRITECOPY</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x80</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PAGE_NOACCESS</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x01</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PAGE_READONLY</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x02</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PAGE_READWRITE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x04</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PAGE_WRITECOPY</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x08</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PAGE_GUARD</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x100</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PAGE_NOCACHE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x200</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PAGE_WRITECOMBINE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x400</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEC_COMMIT</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x8000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEC_IMAGE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x1000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEC_IMAGE_NO_EXECUTE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x11000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEC_LARGE_PAGES</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x80000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEC_NOCACHE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x10000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEC_RESERVE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x4000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEC_WRITECOMBINE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x40000000</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_MAP_ALL_ACCESS</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0xf001f</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_MAP_READ</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_MAP_WRITE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_MAP_COPY</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_MAP_EXECUTE</span> : <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x20</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROCESSOR_ARCHITECTURE_INTEL</span> : <span class='ident'>WORD</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROCESSOR_ARCHITECTURE_ARM</span> : <span class='ident'>WORD</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROCESSOR_ARCHITECTURE_IA64</span> : <span class='ident'>WORD</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROCESSOR_ARCHITECTURE_AMD64</span> : <span class='ident'>WORD</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROCESSOR_ARCHITECTURE_UNKNOWN</span> : <span class='ident'>WORD</span> <span class='op'>=</span> <span class='number'>0xffff</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MOVEFILE_COPY_ALLOWED</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MOVEFILE_CREATE_HARDLINK</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MOVEFILE_DELAY_UNTIL_REBOOT</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MOVEFILE_FAIL_IF_NOT_TRACKABLE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>32</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MOVEFILE_REPLACE_EXISTING</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MOVEFILE_WRITE_THROUGH</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>8</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SYMBOLIC_LINK_FLAG_DIRECTORY</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>1</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_SHARE_DELETE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_SHARE_READ</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_SHARE_WRITE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x2</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>CREATE_ALWAYS</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>CREATE_NEW</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>OPEN_ALWAYS</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>OPEN_EXISTING</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TRUNCATE_EXISTING</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>5</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_APPEND_DATA</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_READ_DATA</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_WRITE_DATA</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000002</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_ATTRIBUTE_ARCHIVE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_ATTRIBUTE_COMPRESSED</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x800</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_ATTRIBUTE_DEVICE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x40</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_ATTRIBUTE_DIRECTORY</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_ATTRIBUTE_ENCRYPTED</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x4000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_ATTRIBUTE_HIDDEN</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_ATTRIBUTE_INTEGRITY_STREAM</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x8000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_ATTRIBUTE_NORMAL</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x80</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_ATTRIBUTE_NOT_CONTENT_INDEXED</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x2000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_ATTRIBUTE_NO_SCRUB_DATA</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x20000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_ATTRIBUTE_OFFLINE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x1000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_ATTRIBUTE_READONLY</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_ATTRIBUTE_REPARSE_POINT</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x400</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_ATTRIBUTE_SPARSE_FILE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x200</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_ATTRIBUTE_SYSTEM</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_ATTRIBUTE_TEMPORARY</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x100</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_ATTRIBUTE_VIRTUAL</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x10000</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_FLAG_BACKUP_SEMANTICS</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x02000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_FLAG_DELETE_ON_CLOSE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x04000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_FLAG_NO_BUFFERING</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x20000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_FLAG_OPEN_NO_RECALL</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00100000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_FLAG_OPEN_REPARSE_POINT</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00200000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_FLAG_OVERLAPPED</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x40000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_FLAG_POSIX_SEMANTICS</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x0100000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_FLAG_RANDOM_ACCESS</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x10000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_FLAG_SESSION_AWARE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00800000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_FLAG_SEQUENTIAL_SCAN</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x08000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_FLAG_WRITE_THROUGH</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x80000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_FLAG_FIRST_PIPE_INSTANCE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00080000</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_NAME_NORMALIZED</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_NAME_OPENED</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x8</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>VOLUME_NAME_DOS</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>VOLUME_NAME_GUID</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>VOLUME_NAME_NONE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>VOLUME_NAME_NT</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x2</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GENERIC_READ</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x80000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GENERIC_WRITE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x40000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GENERIC_EXECUTE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x20000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GENERIC_ALL</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x10000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_WRITE_ATTRIBUTES</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000100</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_READ_ATTRIBUTES</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000080</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STANDARD_RIGHTS_READ</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x20000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STANDARD_RIGHTS_WRITE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x20000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_WRITE_EA</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000010</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_READ_EA</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000008</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_GENERIC_READ</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> + <span class='ident'>STANDARD_RIGHTS_READ</span> <span class='op'>|</span> <span class='ident'>FILE_READ_DATA</span> <span class='op'>|</span> + <span class='ident'>FILE_READ_ATTRIBUTES</span> <span class='op'>|</span> <span class='ident'>FILE_READ_EA</span> <span class='op'>|</span> <span class='ident'>SYNCHRONIZE</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_GENERIC_WRITE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> + <span class='ident'>STANDARD_RIGHTS_WRITE</span> <span class='op'>|</span> <span class='ident'>FILE_WRITE_DATA</span> <span class='op'>|</span> + <span class='ident'>FILE_WRITE_ATTRIBUTES</span> <span class='op'>|</span> <span class='ident'>FILE_WRITE_EA</span> <span class='op'>|</span> <span class='ident'>FILE_APPEND_DATA</span> <span class='op'>|</span> + <span class='ident'>SYNCHRONIZE</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_BEGIN</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_CURRENT</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILE_END</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>2</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAX_PROTOCOL_CHAIN</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>WSAPROTOCOL_LEN</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>255</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>INVALID_SOCKET</span>: <span class='ident'>SOCKET</span> <span class='op'>=</span> <span class='op'>!</span><span class='number'>0</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>DETACHED_PROCESS</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000008</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>CREATE_NEW_PROCESS_GROUP</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000200</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>CREATE_UNICODE_ENVIRONMENT</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000400</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PIPE_ACCESS_DUPLEX</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000003</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PIPE_ACCESS_INBOUND</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PIPE_ACCESS_OUTBOUND</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PIPE_TYPE_BYTE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PIPE_TYPE_MESSAGE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PIPE_READMODE_BYTE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PIPE_READMODE_MESSAGE</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PIPE_WAIT</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PIPE_NOWAIT</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PIPE_ACCEPT_REMOTE_CLIENTS</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PIPE_REJECT_REMOTE_CLIENTS</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>0x00000008</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PIPE_UNLIMITED_INSTANCES</span>: <span class='ident'>DWORD</span> <span class='op'>=</span> <span class='number'>255</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_RAW</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>255</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FIONBIO</span>: <span class='ident'>c_long</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>0x7FFB9982</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>sysconf</span> { + } + } + + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"linux"</span>, <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>, <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>os</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c95</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_uint</span>}; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EXIT_FAILURE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EXIT_SUCCESS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RAND_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2147483647</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEEK_SET</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEEK_CUR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEEK_END</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_IOFBF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_IONBF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_IOLBF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>BUFSIZ</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>8192</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FOPEN_MAX</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILENAME_MAX</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>4096</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>L_tmpnam</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TMP_MAX</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>238328</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c99</span> { + } + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"arm"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"aarch64"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"le32"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"powerpc"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::<span class='ident'>c_void</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::<span class='ident'>mode_t</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_RDONLY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_WRONLY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_RDWR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_APPEND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1024</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_CREAT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_EXCL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_NOCTTY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>256</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_TRUNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>512</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFIFO</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>4096</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFCHR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>8192</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFBLK</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>24576</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFDIR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>16384</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFREG</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>32768</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFLNK</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>40960</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFMT</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>61440</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IEXEC</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWRITE</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IREAD</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>256</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXU</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>448</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXUSR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWUSR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRUSR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>256</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXG</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>56</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>32</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXO</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXOTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWOTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IROTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>R_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>W_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDIN_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDOUT_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDERR_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_LOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_TEST</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_TLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_ULOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGHUP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGINT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGQUIT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGILL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGABRT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGFPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGKILL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGSEGV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGPIPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGALRM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGTERM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_NONE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_READ</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_WRITE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_EXEC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_FILE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_SHARED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_PRIVATE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_FIXED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0010</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_ANON</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0020</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_FAILED</span> : <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span> <span class='op'>=</span> <span class='op'>!</span><span class='number'>0</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MCL_CURRENT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MCL_FUTURE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MS_ASYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MS_INVALIDATE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MS_SYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0004</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPERM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOENT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESRCH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EINTR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EIO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENXIO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>E2BIG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOEXEC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECHILD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EAGAIN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOMEM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EACCES</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EFAULT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTBLK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBUSY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EEXIST</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>17</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EXDEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>18</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENODEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>19</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTDIR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EISDIR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>21</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EINVAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>22</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENFILE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>23</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMFILE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>24</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTTY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>25</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETXTBSY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>26</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EFBIG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>27</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOSPC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>28</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESPIPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>29</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EROFS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>30</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMLINK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>31</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPIPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>32</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDOM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>33</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERANGE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>34</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDEADLK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>35</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENAMETOOLONG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>36</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOLCK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>37</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOSYS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>38</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTEMPTY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>39</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELOOP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>40</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EWOULDBLOCK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>EAGAIN</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOMSG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>42</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EIDRM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>43</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECHRNG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>44</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EL2NSYNC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>45</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EL3HLT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>46</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EL3RST</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>47</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELNRNG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>48</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EUNATCH</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>49</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOCSI</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>50</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EL2HLT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>51</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>52</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>53</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EXFULL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>54</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOANO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>55</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADRQC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>56</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADSLT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>57</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDEADLOCK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>EDEADLK</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBFONT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>59</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOSTR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>60</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENODATA</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>61</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETIME</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>62</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOSR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>63</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENONET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOPKG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>65</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EREMOTE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>66</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOLINK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>67</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EADV</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>68</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESRMNT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>69</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECOMM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>70</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROTO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>71</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMULTIHOP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>72</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDOTDOT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>73</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADMSG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>74</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOVERFLOW</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>75</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTUNIQ</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>76</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADFD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>77</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EREMCHG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>78</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELIBACC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>79</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELIBBAD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>80</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELIBSCN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>81</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELIBMAX</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>82</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELIBEXEC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>83</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EILSEQ</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>84</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERESTART</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>85</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESTRPIPE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>86</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EUSERS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>87</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTSOCK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>88</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDESTADDRREQ</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>89</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMSGSIZE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>90</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROTOTYPE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>91</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOPROTOOPT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>92</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROTONOSUPPORT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>93</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESOCKTNOSUPPORT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>94</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOPNOTSUPP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>95</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPFNOSUPPORT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>96</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EAFNOSUPPORT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>97</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EADDRINUSE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>98</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EADDRNOTAVAIL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>99</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENETDOWN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>100</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENETUNREACH</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>101</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENETRESET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>102</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECONNABORTED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>103</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECONNRESET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>104</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOBUFS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>105</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EISCONN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>106</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTCONN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>107</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESHUTDOWN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>108</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETOOMANYREFS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>109</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETIMEDOUT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>110</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECONNREFUSED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>111</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EHOSTDOWN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>112</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EHOSTUNREACH</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>113</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EALREADY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>114</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EINPROGRESS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>115</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESTALE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>116</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EUCLEAN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>117</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTNAM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>118</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENAVAIL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>119</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EISNAM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>120</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EREMOTEIO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>121</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDQUOT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>122</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOMEDIUM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>123</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMEDIUMTYPE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>124</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECANCELED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>125</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOKEY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>126</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EKEYEXPIRED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>127</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EKEYREVOKED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EKEYREJECTED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>129</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOWNERDEAD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>130</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTRECOVERABLE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>131</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERFKILL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>132</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EHWPOISON</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>133</span>; + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"mips"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"mipsel"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::<span class='ident'>c_void</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::<span class='ident'>mode_t</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_RDONLY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_WRONLY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_RDWR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_APPEND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_CREAT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>256</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_EXCL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1024</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_NOCTTY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2048</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_TRUNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>512</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFIFO</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>4096</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFCHR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>8192</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFBLK</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>24576</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFDIR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>16384</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFREG</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>32768</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFLNK</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>40960</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFMT</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>61440</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IEXEC</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWRITE</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IREAD</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>256</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXU</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>448</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXUSR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWUSR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRUSR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>256</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXG</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>56</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>32</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXO</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXOTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWOTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IROTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>R_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>W_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDIN_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDOUT_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDERR_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_LOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_TEST</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_TLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_ULOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGHUP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGINT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGQUIT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGILL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGABRT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGFPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGKILL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGSEGV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGPIPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGALRM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGTERM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_NONE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_READ</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_WRITE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_EXEC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_FILE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_SHARED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_PRIVATE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_FIXED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0010</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_ANON</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0800</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_FAILED</span> : <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span> <span class='op'>=</span> <span class='op'>!</span><span class='number'>0</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MCL_CURRENT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MCL_FUTURE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MS_ASYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MS_INVALIDATE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MS_SYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0004</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPERM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOENT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESRCH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EINTR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EIO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENXIO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>E2BIG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOEXEC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECHILD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EAGAIN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOMEM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EACCES</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EFAULT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTBLK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBUSY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EEXIST</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>17</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EXDEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>18</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENODEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>19</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTDIR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EISDIR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>21</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EINVAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>22</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENFILE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>23</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMFILE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>24</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTTY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>25</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETXTBSY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>26</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EFBIG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>27</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOSPC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>28</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESPIPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>29</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EROFS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>30</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMLINK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>31</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPIPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>32</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDOM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>33</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERANGE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>34</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOMSG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>35</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EIDRM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>36</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECHRNG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>37</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EL2NSYNC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>38</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EL3HLT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>39</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EL3RST</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>40</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELNRNG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>41</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EUNATCH</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>42</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOCSI</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>43</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EL2HLT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>44</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDEADLK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>45</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOLCK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>46</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>50</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>51</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EXFULL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>52</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOANO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>53</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADRQC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>54</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADSLT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>55</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDEADLOCK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>56</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBFONT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>59</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOSTR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>60</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENODATA</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>61</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETIME</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>62</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOSR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>63</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENONET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOPKG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>65</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EREMOTE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>66</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOLINK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>67</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EADV</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>68</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESRMNT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>69</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECOMM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>70</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROTO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>71</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDOTDOT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>73</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMULTIHOP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>74</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADMSG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>77</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENAMETOOLONG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>78</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOVERFLOW</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>79</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTUNIQ</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>80</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADFD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>81</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EREMCHG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>82</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELIBACC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>83</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELIBBAD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>84</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELIBSCN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>95</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELIBMAX</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>86</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELIBEXEC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>87</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EILSEQ</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>88</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOSYS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>89</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELOOP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>90</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERESTART</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>91</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESTRPIPE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>92</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTEMPTY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>93</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EUSERS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>94</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTSOCK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>95</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDESTADDRREQ</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>96</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMSGSIZE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>97</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROTOTYPE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>98</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOPROTOOPT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>99</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROTONOSUPPORT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>120</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESOCKTNOSUPPORT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>121</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOPNOTSUPP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>122</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPFNOSUPPORT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>123</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EAFNOSUPPORT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>124</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EADDRINUSE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>125</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EADDRNOTAVAIL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>126</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENETDOWN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>127</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENETUNREACH</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENETRESET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>129</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECONNABORTED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>130</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECONNRESET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>131</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOBUFS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>132</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EISCONN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>133</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTCONN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>134</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EUCLEAN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>135</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTNAM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>137</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENAVAIL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>138</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EISNAM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>139</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EREMOTEIO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>140</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESHUTDOWN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>143</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETOOMANYREFS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>144</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETIMEDOUT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>145</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECONNREFUSED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>146</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EHOSTDOWN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>147</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EHOSTUNREACH</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>148</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EWOULDBLOCK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>EAGAIN</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EALREADY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>149</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EINPROGRESS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>150</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESTALE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>151</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECANCELED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>158</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOMEDIUM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>159</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMEDIUMTYPE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>160</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOKEY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>161</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EKEYEXPIRED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>162</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EKEYREVOKED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>163</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EKEYREJECTED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>164</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOWNERDEAD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>165</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTRECOVERABLE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>166</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERFKILL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>167</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EHWPOISON</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>168</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDQUOT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1133</span>; + } + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>size_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>posix01</span>::<span class='ident'>rlim_t</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_DUPFD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_GETFD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_SETFD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_GETFL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_SETFL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_ACCMODE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGTRAP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIG_IGN</span>: <span class='ident'>size_t</span> <span class='op'>=</span> <span class='number'>1</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_ERR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span> <span class='op'><<</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_MARK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span> <span class='op'><<</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOSORT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span> <span class='op'><<</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_DOOFFS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span> <span class='op'><<</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOCHECK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span> <span class='op'><<</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_APPEND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span> <span class='op'><<</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOESCAPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span> <span class='op'><<</span> <span class='number'>6</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOSPACE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_ABORTED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOMATCH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_NORMAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_RANDOM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_SEQUENTIAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_WILLNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_DONTNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MQ_PRIO_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>28</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_IOV_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>60</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_GETGR_R_SIZE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>69</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_GETPW_R_SIZE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>70</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_LOGIN_NAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>71</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TTY_NAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>72</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREADS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>67</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_SAFE_FUNCTIONS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>68</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_DESTRUCTOR_ITERATIONS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>73</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_KEYS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>74</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_STACK_MIN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>75</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_THREADS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>76</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_ATTR_STACKADDR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>77</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_ATTR_STACKSIZE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>78</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PRIORITY_SCHEDULING</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>79</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PRIO_INHERIT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>80</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PRIO_PROTECT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>81</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PROCESS_SHARED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>82</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_ATEXIT_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>87</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>89</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_XCU_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>90</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_UNIX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>91</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_CRYPT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>92</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_ENH_I18N</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>93</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_SHM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>94</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_LEGACY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>129</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_REALTIME</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>130</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_REALTIME_THREADS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>131</span>; + + + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_CREATE_JOINABLE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_CREATE_DETACHED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_STACK_MIN</span>: <span class='ident'>size_t</span> <span class='op'>=</span> <span class='number'>8192</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>all</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"linux"</span>, + <span class='ident'>any</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"arm"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>)))]</span> + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_STACK_MIN</span>: <span class='ident'>size_t</span> <span class='op'>=</span> <span class='number'>16384</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>all</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"linux"</span>, + <span class='ident'>any</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"mips"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"mipsel"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"aarch64"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"powerpc"</span>)))]</span> + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_STACK_MIN</span>: <span class='ident'>size_t</span> <span class='op'>=</span> <span class='number'>131072</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>CLOCK_REALTIME</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>CLOCK_MONOTONIC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_CPU</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_FSIZE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_DATA</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_STACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_CORE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_RSS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_NOFILE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_AS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_NPROC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_MEMLOCK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_LOCKS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_SIGPENDING</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_MSGQUEUE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_NICE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_RTPRIO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_RTTIME</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_NLIMITS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIM_INFINITY</span>: <span class='ident'>rlim_t</span> <span class='op'>=</span> <span class='number'>0xffff_ffff_ffff_ffff</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIM_SAVED_MAX</span>: <span class='ident'>rlim_t</span> <span class='op'>=</span> <span class='ident'>RLIM_INFINITY</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIM_SAVED_CUR</span>: <span class='ident'>rlim_t</span> <span class='op'>=</span> <span class='ident'>RLIM_INFINITY</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RUSAGE_SELF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RUSAGE_CHILDREN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RUSAGE_THREAD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + } + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>size_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>posix01</span>::<span class='ident'>rlim_t</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_DUPFD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_GETFD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_SETFD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_GETFL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_SETFL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGTRAP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIG_IGN</span>: <span class='ident'>size_t</span> <span class='op'>=</span> <span class='number'>1</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_ERR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span> <span class='op'><<</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_MARK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span> <span class='op'><<</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOSORT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span> <span class='op'><<</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_DOOFFS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span> <span class='op'><<</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOCHECK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span> <span class='op'><<</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_APPEND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span> <span class='op'><<</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOESCAPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span> <span class='op'><<</span> <span class='number'>6</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOSPACE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_ABORTED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOMATCH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_NORMAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_RANDOM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_SEQUENTIAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_WILLNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_DONTNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MQ_PRIO_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>28</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_IOV_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>60</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_GETGR_R_SIZE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>69</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_GETPW_R_SIZE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>70</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_LOGIN_NAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>71</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TTY_NAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>72</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREADS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>67</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_SAFE_FUNCTIONS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>68</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_DESTRUCTOR_ITERATIONS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>73</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_KEYS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>74</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_STACK_MIN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>75</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_THREADS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>76</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_ATTR_STACKADDR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>77</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_ATTR_STACKSIZE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>78</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PRIORITY_SCHEDULING</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>79</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PRIO_INHERIT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>80</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PRIO_PROTECT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>81</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PROCESS_SHARED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>82</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_ATEXIT_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>87</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>89</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_XCU_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>90</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_UNIX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>91</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_CRYPT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>92</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_ENH_I18N</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>93</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_SHM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>94</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_LEGACY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>129</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_REALTIME</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>130</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_REALTIME_THREADS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>131</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_CREATE_JOINABLE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_CREATE_DETACHED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_STACK_MIN</span>: <span class='ident'>size_t</span> <span class='op'>=</span> <span class='number'>1024</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>CLOCK_REALTIME</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>CLOCK_MONOTONIC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_CPU</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_FSIZE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_DATA</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_STACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_CORE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_RSS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_NOFILE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_AS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_NPROC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_MEMLOCK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_LOCKS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_SIGPENDING</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_MSGQUEUE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_NICE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_RTPRIO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_RTTIME</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_NLIMITS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIM_INFINITY</span>: <span class='ident'>rlim_t</span> <span class='op'>=</span> <span class='number'>0xffff_ffff_ffff_ffff</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIM_SAVED_MAX</span>: <span class='ident'>rlim_t</span> <span class='op'>=</span> <span class='ident'>RLIM_INFINITY</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIM_SAVED_CUR</span>: <span class='ident'>rlim_t</span> <span class='op'>=</span> <span class='ident'>RLIM_INFINITY</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RUSAGE_SELF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RUSAGE_CHILDREN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RUSAGE_THREAD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix08</span> { + } + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"arm"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"aarch64"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"le32"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"powerpc"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_NORMAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_RANDOM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_SEQUENTIAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_WILLNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_DONTNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_REMOVE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_DONTFORK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_DOFORK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_MERGEABLE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_UNMERGEABLE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_HWPOISON</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>100</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IFF_LOOPBACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x8</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_UNIX</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_INET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_INET6</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_STREAM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_DGRAM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_RAW</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_TCP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_IP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_IPV6</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>41</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_MULTICAST_TTL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>33</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_MULTICAST_LOOP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>34</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_TTL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_HDRINCL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_ADD_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>35</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_DROP_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>36</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPV6_ADD_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPV6_DROP_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>21</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_NODELAY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_MAXSEG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_CORK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_KEEPIDLE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_KEEPINTVL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_KEEPCNT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_SYNCNT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_LINGER2</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_DEFER_ACCEPT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_WINDOW_CLAMP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_INFO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_QUICKACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_CONGESTION</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_MD5SIG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_COOKIE_TRANSACTIONS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_THIN_LINEAR_TIMEOUTS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_THIN_DUPACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>17</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_USER_TIMEOUT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>18</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_REPAIR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>19</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_REPAIR_QUEUE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_QUEUE_SEQ</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>21</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_REPAIR_OPTIONS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>22</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_FASTOPEN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>23</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_TIMESTAMP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>24</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOL_SOCKET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_DEBUG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_REUSEADDR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_TYPE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_ERROR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_DONTROUTE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_BROADCAST</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDBUF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVBUF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_KEEPALIVE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_OOBINLINE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_LINGER</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_REUSEPORT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVLOWAT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>18</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDLOWAT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>19</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVTIMEO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDTIMEO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>21</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_ACCEPTCONN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>30</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_RD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_WR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_RDWR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + } + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"mips"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"mipsel"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_NORMAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_RANDOM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_SEQUENTIAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_WILLNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_DONTNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_REMOVE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_DONTFORK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_DOFORK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_MERGEABLE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_UNMERGEABLE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_HWPOISON</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>100</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_UNIX</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_INET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_INET6</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_STREAM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_DGRAM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_RAW</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_TCP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_IP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_IPV6</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>41</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_MULTICAST_TTL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>33</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_MULTICAST_LOOP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>34</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_TTL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_HDRINCL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_ADD_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>35</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_DROP_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>36</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPV6_ADD_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPV6_DROP_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>21</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_NODELAY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_MAXSEG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_CORK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_KEEPIDLE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_KEEPINTVL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_KEEPCNT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_SYNCNT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_LINGER2</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_DEFER_ACCEPT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_WINDOW_CLAMP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_INFO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_QUICKACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_CONGESTION</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_MD5SIG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_COOKIE_TRANSACTIONS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_THIN_LINEAR_TIMEOUTS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_THIN_DUPACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>17</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_USER_TIMEOUT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>18</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_REPAIR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>19</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_REPAIR_QUEUE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_QUEUE_SEQ</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>21</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_REPAIR_OPTIONS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>22</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_FASTOPEN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>23</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_TIMESTAMP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>24</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOL_SOCKET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>65535</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_DEBUG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_REUSEADDR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_KEEPALIVE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0008</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_DONTROUTE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0010</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_BROADCAST</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0020</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_LINGER</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0080</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_OOBINLINE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x100</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_REUSEPORT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0200</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDBUF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVBUF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDLOWAT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1003</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVLOWAT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDTIMEO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1005</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVTIMEO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1006</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_ERROR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1007</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_TYPE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1008</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_ACCEPTCONN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1009</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_RD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_WR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_RDWR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + } + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"arm"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"aarch64"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"le32"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"powerpc"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_PACKET</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>17</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_RAW</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>255</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_RSYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1052672</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_DSYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4096</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_NONBLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2048</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_SYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1052672</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_GROWSDOWN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x010000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_GROWSUP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x020000000</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_TYPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x000f</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_ANONYMOUS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0020</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_32BIT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0040</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_GROWSDOWN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0100</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_DENYWRITE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0800</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_EXECUTABLE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x01000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_LOCKED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x02000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_NORESERVE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x04000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_POPULATE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x08000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_NONBLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x010000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_STACK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x020000</span>; + } + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"mips"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"mipsel"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_PACKET</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>17</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_RAW</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>255</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_RSYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16400</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_DSYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_NONBLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_SYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16400</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_GROWSDOWN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x01000000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_GROWSUP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x02000000</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_TYPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x000f</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_ANONYMOUS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0800</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_GROWSDOWN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x01000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_DENYWRITE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x02000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_EXECUTABLE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x04000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_LOCKED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x08000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_NORESERVE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0400</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_POPULATE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x010000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_NONBLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x020000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_STACK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x040000</span>; + } + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"linux"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>sysconf</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_ARG_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_CHILD_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_CLK_TCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_NGROUPS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_OPEN_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_STREAM_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TZNAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_JOB_CONTROL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SAVED_IDS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_REALTIME_SIGNALS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_PRIORITY_SCHEDULING</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TIMERS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_ASYNCHRONOUS_IO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_PRIORITIZED_IO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SYNCHRONIZED_IO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_FSYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MAPPED_FILES</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MEMLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>17</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MEMLOCK_RANGE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>18</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MEMORY_PROTECTION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>19</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MESSAGE_PASSING</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SEMAPHORES</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>21</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SHARED_MEMORY_OBJECTS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>22</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_AIO_LISTIO_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>23</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_AIO_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>24</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_AIO_PRIO_DELTA_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>25</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_DELAYTIMER_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>26</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MQ_OPEN_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>27</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>29</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_PAGESIZE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>30</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_RTSIG_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>31</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SEM_NSEMS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>32</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SEM_VALUE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>33</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SIGQUEUE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>34</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TIMER_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>35</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_BASE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>36</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_DIM_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>37</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_SCALE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>38</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_STRING_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>39</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_COLL_WEIGHTS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>40</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_EXPR_NEST_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>42</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_LINE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>43</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_RE_DUP_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>44</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>46</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_C_BIND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>47</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_C_DEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>48</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_FORT_DEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>49</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_FORT_RUN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>50</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_SW_DEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>51</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_LOCALEDEF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>52</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_NPROCESSORS_ONLN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>84</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_CHAR_TERM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>95</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_C_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>96</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_UPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>97</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XBS5_ILP32_OFF32</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>125</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XBS5_ILP32_OFFBIG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>126</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XBS5_LPBIG_OFFBIG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>128</span>; + + } + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>sysconf</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>static</span> <span class='ident'>_SC_SENDMSG_MAX_SIZE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>static</span> <span class='ident'>_SC_NPROCESSORS_ONLN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>static</span> <span class='ident'>_SC_PAGESIZE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>sysconf</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_ARG_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_BASE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_DIM_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_SCALE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_STRING_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_CHILD_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_CLK_TCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_COLL_WEIGHTS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_EXPR_NEST_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_LINE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_NGROUPS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_OPEN_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_C_BIND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_C_DEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_C_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_CHAR_TERM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_FORT_DEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>17</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_FORT_RUN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>18</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_LOCALEDEF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>19</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_SW_DEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_UPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>21</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>22</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_JOB_CONTROL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>23</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SAVED_IDS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>24</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>25</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_RE_DUP_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>26</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_STREAM_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>27</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TZNAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>28</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_PAGESIZE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>39</span>; + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"freebsd"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"dragonfly"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>os</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c95</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_uint</span>}; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EXIT_FAILURE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EXIT_SUCCESS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RAND_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2147483647</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEEK_SET</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEEK_CUR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEEK_END</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_IOFBF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_IONBF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_IOLBF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>BUFSIZ</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>1024</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FOPEN_MAX</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILENAME_MAX</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>1024</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>L_tmpnam</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>1024</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TMP_MAX</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>308915776</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c99</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::<span class='ident'>c_void</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::<span class='ident'>mode_t</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_RDONLY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_WRONLY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_RDWR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_APPEND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_CREAT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>512</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_EXCL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2048</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_NOCTTY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>32768</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_TRUNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1024</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFIFO</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>4096</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFCHR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>8192</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFBLK</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>24576</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFDIR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>16384</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFREG</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>32768</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFLNK</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>40960</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFMT</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>61440</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IEXEC</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWRITE</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IREAD</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>256</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXU</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>448</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXUSR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWUSR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRUSR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>256</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXG</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>56</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>32</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXO</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXOTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWOTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IROTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>R_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>W_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDIN_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDOUT_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDERR_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_LOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_TEST</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_TLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_ULOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGHUP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGINT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGQUIT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGILL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGABRT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGFPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGKILL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGSEGV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGPIPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGALRM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGTERM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_NONE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_READ</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_WRITE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_EXEC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_FILE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_SHARED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_PRIVATE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_FIXED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0010</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_ANON</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1000</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_FAILED</span> : <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span> <span class='op'>=</span> <span class='op'>!</span><span class='number'>0</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MCL_CURRENT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MCL_FUTURE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MS_SYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MS_ASYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MS_INVALIDATE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPERM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOENT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESRCH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EINTR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EIO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENXIO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>E2BIG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOEXEC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECHILD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDEADLK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOMEM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EACCES</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EFAULT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTBLK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBUSY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EEXIST</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>17</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EXDEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>18</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENODEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>19</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTDIR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EISDIR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>21</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EINVAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>22</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENFILE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>23</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMFILE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>24</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTTY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>25</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETXTBSY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>26</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EFBIG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>27</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOSPC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>28</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESPIPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>29</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EROFS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>30</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMLINK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>31</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPIPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>32</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDOM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>33</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERANGE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>34</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EAGAIN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>35</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EWOULDBLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>35</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EINPROGRESS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>36</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EALREADY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>37</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTSOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>38</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDESTADDRREQ</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>39</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMSGSIZE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>40</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROTOTYPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>41</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOPROTOOPT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>42</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROTONOSUPPORT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>43</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESOCKTNOSUPPORT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>44</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOPNOTSUPP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>45</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPFNOSUPPORT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>46</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EAFNOSUPPORT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>47</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EADDRINUSE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>48</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EADDRNOTAVAIL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>49</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENETDOWN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>50</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENETUNREACH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>51</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENETRESET</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>52</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECONNABORTED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>53</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECONNRESET</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>54</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOBUFS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>55</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EISCONN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>56</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTCONN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>57</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESHUTDOWN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>58</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETOOMANYREFS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>59</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETIMEDOUT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>60</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECONNREFUSED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>61</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELOOP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>62</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENAMETOOLONG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>63</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EHOSTDOWN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EHOSTUNREACH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>65</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTEMPTY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>66</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROCLIM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>67</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EUSERS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>68</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDQUOT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>69</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESTALE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>70</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EREMOTE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>71</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADRPC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>72</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERPCMISMATCH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>73</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROGUNAVAIL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>74</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROGMISMATCH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>75</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROCUNAVAIL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>76</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOLCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>77</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOSYS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>78</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EFTYPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>79</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EAUTH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>80</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENEEDAUTH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>81</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EIDRM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>82</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOMSG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>83</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOVERFLOW</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>84</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECANCELED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>85</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EILSEQ</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>86</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOATTR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>87</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDOOFUS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>88</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADMSG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>89</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMULTIHOP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>90</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOLINK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>91</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROTO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>92</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOMEDIUM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>93</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EUNUSED94</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>94</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EUNUSED95</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>95</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EUNUSED96</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>96</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EUNUSED97</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>97</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EUNUSED98</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>98</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EASYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>99</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELAST</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>99</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>size_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>posix01</span>::<span class='ident'>rlim_t</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_DUPFD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_GETFD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_SETFD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_GETFL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_SETFL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGTRAP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIG_IGN</span>: <span class='ident'>size_t</span> <span class='op'>=</span> <span class='number'>1</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_APPEND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_DOOFFS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_ERR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_MARK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0008</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOCHECK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0010</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOSORT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0020</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOESCAPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x2000</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOSPACE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_ABORTED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOMATCH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>3</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_NORMAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_RANDOM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_SEQUENTIAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_WILLNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_DONTNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_IOV_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>56</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_GETGR_R_SIZE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>70</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_GETPW_R_SIZE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>71</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_LOGIN_NAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>73</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MQ_PRIO_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>75</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_ATTR_STACKADDR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>82</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_ATTR_STACKSIZE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>83</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_DESTRUCTOR_ITERATIONS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>85</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_KEYS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>86</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PRIO_INHERIT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>87</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PRIO_PROTECT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>88</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PRIORITY_SCHEDULING</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>89</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PROCESS_SHARED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>90</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_SAFE_FUNCTIONS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>91</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_STACK_MIN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>93</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_THREADS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>94</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREADS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>96</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TTY_NAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>101</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_ATEXIT_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>107</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_CRYPT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>108</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_ENH_I18N</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>109</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_LEGACY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>110</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_REALTIME</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>111</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_REALTIME_THREADS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>112</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_SHM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>113</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_UNIX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>115</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>116</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_XCU_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>117</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_CREATE_JOINABLE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_CREATE_DETACHED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"arm"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_STACK_MIN</span>: <span class='ident'>size_t</span> <span class='op'>=</span> <span class='number'>4096</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>all</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"freebsd"</span>, + <span class='ident'>any</span>(<span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"mips"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"mipsel"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86"</span>, + <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"x86_64"</span>)))]</span> + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_STACK_MIN</span>: <span class='ident'>size_t</span> <span class='op'>=</span> <span class='number'>2048</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"dragonfly"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_STACK_MIN</span>: <span class='ident'>size_t</span> <span class='op'>=</span> <span class='number'>1024</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>CLOCK_REALTIME</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>CLOCK_MONOTONIC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_CPU</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_FSIZE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_DATA</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_STACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_CORE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_RSS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_MEMLOCK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_NPROC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_NOFILE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_SBSIZE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_VMEM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_AS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>RLIMIT_VMEM</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_NPTS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_SWAP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_KQUEUES</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIM_NLIMITS</span>: <span class='ident'>rlim_t</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIM_INFINITY</span>: <span class='ident'>rlim_t</span> <span class='op'>=</span> <span class='number'>0x7fff_ffff_ffff_ffff</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RUSAGE_SELF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RUSAGE_CHILDREN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RUSAGE_THREAD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix08</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_NORMAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_RANDOM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_SEQUENTIAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_WILLNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_DONTNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_FREE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_NOSYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_AUTOSYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_NOCORE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_CORE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_PROTECT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MINCORE_INCORE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MINCORE_REFERENCED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MINCORE_MODIFIED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MINCORE_REFERENCED_OTHER</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MINCORE_MODIFIED_OTHER</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MINCORE_SUPER</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x20</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_INET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_INET6</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>28</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_UNIX</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_STREAM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_DGRAM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_RAW</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_TCP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_IP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_IPV6</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>41</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_MULTICAST_TTL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_MULTICAST_LOOP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_TTL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_HDRINCL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_ADD_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_DROP_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPV6_ADD_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPV6_DROP_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_NODELAY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_KEEPIDLE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>256</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOL_SOCKET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0xffff</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_DEBUG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x01</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_ACCEPTCONN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_REUSEADDR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_KEEPALIVE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0008</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_DONTROUTE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0010</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_BROADCAST</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0020</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_USELOOPBACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0040</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_LINGER</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0080</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_OOBINLINE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0100</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_REUSEPORT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0200</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDBUF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVBUF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDLOWAT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1003</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVLOWAT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDTIMEO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1005</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVTIMEO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1006</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_ERROR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1007</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_TYPE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1008</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IFF_LOOPBACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x8</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_RD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_WR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_RDWR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_SYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_NONBLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>CTL_KERN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>KERN_PROC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"freebsd"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>KERN_PROC_PATHNAME</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"dragonfly"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>KERN_PROC_PATHNAME</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_COPY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_RENAME</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0020</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_NORESERVE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0040</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_HASSEMAPHORE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0200</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_STACK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0400</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_NOSYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0800</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_NOCORE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x020000</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_RAW</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>255</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>sysconf</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_ARG_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_CHILD_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_CLK_TCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_NGROUPS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_OPEN_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_JOB_CONTROL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SAVED_IDS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_BASE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_DIM_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_SCALE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_STRING_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_COLL_WEIGHTS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_EXPR_NEST_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_LINE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_RE_DUP_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>17</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_C_BIND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>18</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_C_DEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>19</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_CHAR_TERM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_FORT_DEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>21</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_FORT_RUN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>22</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_LOCALEDEF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>23</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_SW_DEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>24</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_UPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>25</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_STREAM_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>26</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TZNAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>27</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_ASYNCHRONOUS_IO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>28</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MAPPED_FILES</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>29</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MEMLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>30</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MEMLOCK_RANGE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>31</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MEMORY_PROTECTION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>32</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MESSAGE_PASSING</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>33</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_PRIORITIZED_IO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>34</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_PRIORITY_SCHEDULING</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>35</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_REALTIME_SIGNALS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>36</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SEMAPHORES</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>37</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_FSYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>38</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SHARED_MEMORY_OBJECTS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>39</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SYNCHRONIZED_IO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>40</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TIMERS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>41</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_AIO_LISTIO_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>42</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_AIO_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>43</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_AIO_PRIO_DELTA_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>44</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_DELAYTIMER_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>45</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MQ_OPEN_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>46</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_PAGESIZE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>47</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_RTSIG_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>48</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SEM_NSEMS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>49</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SEM_VALUE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>50</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SIGQUEUE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>51</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TIMER_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>52</span>; + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"bitrig"</span>, <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"openbsd"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>os</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c95</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_uint</span>}; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EXIT_FAILURE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EXIT_SUCCESS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RAND_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2147483647</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEEK_SET</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEEK_CUR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEEK_END</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_IOFBF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_IONBF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_IOLBF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>BUFSIZ</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>1024</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FOPEN_MAX</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILENAME_MAX</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>1024</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>L_tmpnam</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>1024</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TMP_MAX</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>308915776</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c99</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::<span class='ident'>c_void</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::<span class='ident'>mode_t</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_RDONLY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_WRONLY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_RDWR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_APPEND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_CREAT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>512</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_EXCL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2048</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_NOCTTY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>32768</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_TRUNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1024</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFIFO</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>4096</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFCHR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>8192</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFBLK</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>24576</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFDIR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>16384</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFREG</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>32768</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFLNK</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>40960</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFMT</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>61440</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IEXEC</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWRITE</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IREAD</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>256</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXU</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>448</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXUSR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWUSR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRUSR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>256</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXG</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>56</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>32</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXO</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXOTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWOTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IROTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>R_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>W_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDIN_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDOUT_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDERR_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_LOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_TEST</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_TLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_ULOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGHUP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGINT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGQUIT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGILL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGABRT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGFPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGKILL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGSEGV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGPIPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGALRM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGTERM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_NONE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_READ</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_WRITE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_EXEC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_FILE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_SHARED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_PRIVATE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_FIXED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0010</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_ANON</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1000</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_FAILED</span> : <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span> <span class='op'>=</span> <span class='op'>!</span><span class='number'>0</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MCL_CURRENT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MCL_FUTURE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MS_ASYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MS_SYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MS_INVALIDATE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0004</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPERM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOENT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESRCH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EINTR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EIO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENXIO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>E2BIG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOEXEC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECHILD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDEADLK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOMEM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EACCES</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EFAULT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTBLK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBUSY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EEXIST</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>17</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EXDEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>18</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENODEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>19</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTDIR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EISDIR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>21</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EINVAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>22</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENFILE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>23</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMFILE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>24</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTTY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>25</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETXTBSY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>26</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EFBIG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>27</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOSPC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>28</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESPIPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>29</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EROFS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>30</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMLINK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>31</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPIPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>32</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDOM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>33</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERANGE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>34</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EAGAIN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>35</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EWOULDBLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>35</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EINPROGRESS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>36</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EALREADY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>37</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTSOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>38</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDESTADDRREQ</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>39</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMSGSIZE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>40</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROTOTYPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>41</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOPROTOOPT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>42</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROTONOSUPPORT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>43</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESOCKTNOSUPPORT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>44</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOPNOTSUPP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>45</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPFNOSUPPORT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>46</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EAFNOSUPPORT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>47</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EADDRINUSE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>48</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EADDRNOTAVAIL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>49</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENETDOWN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>50</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENETUNREACH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>51</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENETRESET</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>52</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECONNABORTED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>53</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECONNRESET</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>54</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOBUFS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>55</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EISCONN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>56</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTCONN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>57</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESHUTDOWN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>58</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETOOMANYREFS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>59</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETIMEDOUT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>60</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECONNREFUSED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>61</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELOOP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>62</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENAMETOOLONG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>63</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EHOSTDOWN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EHOSTUNREACH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>65</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTEMPTY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>66</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROCLIM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>67</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EUSERS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>68</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDQUOT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>69</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESTALE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>70</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EREMOTE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>71</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADRPC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>72</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERPCMISMATCH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>73</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROGUNAVAIL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>74</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROGMISMATCH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>75</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROCUNAVAIL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>76</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOLCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>77</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOSYS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>78</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EFTYPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>79</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EAUTH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>80</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENEEDAUTH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>81</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EIPSEC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>82</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOATTR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>83</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EILSEQ</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>84</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOMEDIUM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>85</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMEDIUMTYPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>86</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOVERFLOW</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>87</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECANCELED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>88</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EIDRM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>89</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOMSG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>90</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTSUP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>91</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELAST</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>91</span>; <span class='comment'>// must be equal to largest errno</span> + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>size_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>posix01</span>::<span class='ident'>rlim_t</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_DUPFD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_GETFD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_SETFD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_GETFL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_SETFL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_GETOWN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_SETOWN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_GETLK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_SETLK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_SETLKW</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_DUPFD_CLOEXEC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGTRAP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIG_IGN</span>: <span class='ident'>size_t</span> <span class='op'>=</span> <span class='number'>1</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_APPEND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_DOOFFS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_ERR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_MARK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0008</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOCHECK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0010</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOSORT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0020</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOESCAPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1000</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOSPACE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_ABORTED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOMATCH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOSYS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>4</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_NORMAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_RANDOM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_SEQUENTIAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_WILLNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_DONTNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_IOV_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>51</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_GETGR_R_SIZE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>100</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_GETPW_R_SIZE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>101</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_LOGIN_NAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>102</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MQ_PRIO_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>59</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_ATTR_STACKADDR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>77</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_ATTR_STACKSIZE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>78</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_DESTRUCTOR_ITERATIONS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>80</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_KEYS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>81</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PRIO_INHERIT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>82</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PRIO_PROTECT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>83</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PRIORITY_SCHEDULING</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>84</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PROCESS_SHARED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>85</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_SAFE_FUNCTIONS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>103</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_STACK_MIN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>89</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_THREADS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>90</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREADS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>91</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TTY_NAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>107</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_ATEXIT_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>46</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_CRYPT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>117</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_ENH_I18N</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>118</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_LEGACY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>119</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_REALTIME</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>120</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_REALTIME_THREADS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>121</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_SHM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>30</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_UNIX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>123</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>125</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_CREATE_JOINABLE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_CREATE_DETACHED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_STACK_MIN</span> : <span class='ident'>size_t</span> <span class='op'>=</span> <span class='number'>2048</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>CLOCK_REALTIME</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>CLOCK_MONOTONIC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_CPU</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_FSIZE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_DATA</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_STACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_CORE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_RSS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_MEMLOCK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_NPROC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_NOFILE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIM_NLIMITS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIM_INFINITY</span>: <span class='ident'>rlim_t</span> <span class='op'>=</span> <span class='number'>0x7fff_ffff_ffff_ffff</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIM_SAVED_MAX</span>: <span class='ident'>rlim_t</span> <span class='op'>=</span> <span class='ident'>RLIM_INFINITY</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIM_SAVED_CUR</span>: <span class='ident'>rlim_t</span> <span class='op'>=</span> <span class='ident'>RLIM_INFINITY</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RUSAGE_SELF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RUSAGE_CHILDREN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RUSAGE_THREAD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix08</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_NORMAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_RANDOM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_SEQUENTIAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_WILLNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_DONTNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_FREE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_UNIX</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_INET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_INET6</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>24</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_STREAM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_DGRAM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_RAW</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_TCP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_IP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_IPV6</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>41</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_MULTICAST_TTL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_MULTICAST_LOOP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_TTL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_HDRINCL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_ADD_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_DROP_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPV6_ADD_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; <span class='comment'>// don't exist</span> + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPV6_DROP_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; <span class='comment'>// don't exist</span> + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_NODELAY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x01</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOL_SOCKET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0xffff</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_DEBUG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x01</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_ACCEPTCONN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_REUSEADDR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_KEEPALIVE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0008</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_DONTROUTE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0010</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_BROADCAST</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0020</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_USELOOPBACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0040</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_LINGER</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0080</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_OOBINLINE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0100</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_REUSEPORT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0200</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDBUF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVBUF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDLOWAT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1003</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVLOWAT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDTIMEO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1005</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVTIMEO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1006</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_ERROR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1007</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_TYPE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1008</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IFF_LOOPBACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x8</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_RD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_WR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_RDWR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_DSYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>128</span>; <span class='comment'>// same as SYNC</span> + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_SYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_NONBLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>CTL_KERN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>KERN_PROC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>66</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_COPY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_RENAME</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_NORESERVE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_NOEXTEND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_HASSEMAPHORE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0000</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_RAW</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>255</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PATH_MAX</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1024</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>sysconf</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_ARG_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_CHILD_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_CLK_TCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_NGROUPS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_OPEN_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_JOB_CONTROL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SAVED_IDS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_BASE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_DIM_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_SCALE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_STRING_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_COLL_WEIGHTS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_EXPR_NEST_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_LINE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_RE_DUP_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>17</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_C_BIND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>18</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_C_DEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>19</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_CHAR_TERM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_FORT_DEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>21</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_FORT_RUN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>22</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_LOCALEDEF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>23</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_SW_DEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>24</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_UPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>25</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_STREAM_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>26</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TZNAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>27</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_PAGESIZE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>28</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_FSYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>29</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SEM_NSEMS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>31</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SEM_VALUE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>32</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_AIO_LISTIO_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>42</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_AIO_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>43</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_AIO_PRIO_DELTA_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>44</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_ASYNCHRONOUS_IO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>45</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_DELAYTIMER_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>50</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MAPPED_FILES</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>53</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MEMLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>54</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MEMLOCK_RANGE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>55</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MEMORY_PROTECTION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>56</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MESSAGE_PASSING</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>57</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MQ_OPEN_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>58</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_PRIORITIZED_IO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>60</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_PRIORITY_SCHEDULING</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>61</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_REALTIME_SIGNALS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_RTSIG_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>66</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SEMAPHORES</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>67</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SHARED_MEMORY_OBJECTS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>68</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SIGQUEUE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>70</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SYNCHRONIZED_IO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>75</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TIMER_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>93</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TIMERS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>94</span>; + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"macos"</span>, <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"ios"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>os</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c95</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_uint</span>}; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EXIT_FAILURE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EXIT_SUCCESS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RAND_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2147483647</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEEK_SET</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEEK_CUR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SEEK_END</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_IOFBF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_IONBF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_IOLBF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>BUFSIZ</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>1024</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FOPEN_MAX</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>FILENAME_MAX</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>1024</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>L_tmpnam</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>1024</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TMP_MAX</span> : <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>308915776</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c99</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::<span class='ident'>c_void</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::<span class='ident'>mode_t</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_RDONLY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_WRONLY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_RDWR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_APPEND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_CREAT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>512</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_EXCL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2048</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_NOCTTY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>131072</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_TRUNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1024</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFIFO</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>4096</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFCHR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>8192</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFBLK</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>24576</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFDIR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>16384</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFREG</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>32768</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFLNK</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>40960</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IFMT</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>61440</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IEXEC</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWRITE</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IREAD</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>256</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXU</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>448</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXUSR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWUSR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRUSR</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>256</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXG</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>56</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRGRP</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>32</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IRWXO</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IXOTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IWOTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>S_IROTH</span> : <span class='ident'>mode_t</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>R_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>W_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X_OK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDIN_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDOUT_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>STDERR_FILENO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_LOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_TEST</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_TLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_ULOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGHUP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGINT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGQUIT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGILL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGABRT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGFPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGKILL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGSEGV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGPIPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGALRM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGTERM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_NONE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_READ</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_WRITE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PROT_EXEC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_FILE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_SHARED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_PRIVATE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_FIXED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0010</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_ANON</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1000</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_FAILED</span> : <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span> <span class='op'>=</span> <span class='op'>!</span><span class='number'>0</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MCL_CURRENT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MCL_FUTURE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MS_ASYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MS_INVALIDATE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MS_SYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0010</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MS_KILLPAGES</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MS_DEACTIVATE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0008</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPERM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOENT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESRCH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EINTR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EIO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENXIO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>E2BIG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOEXEC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECHILD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDEADLK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOMEM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EACCES</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EFAULT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTBLK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBUSY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EEXIST</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>17</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EXDEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>18</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENODEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>19</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTDIR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EISDIR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>21</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EINVAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>22</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENFILE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>23</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMFILE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>24</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTTY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>25</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETXTBSY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>26</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EFBIG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>27</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOSPC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>28</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESPIPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>29</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EROFS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>30</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMLINK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>31</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPIPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>32</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDOM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>33</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERANGE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>34</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EAGAIN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>35</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EWOULDBLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>EAGAIN</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EINPROGRESS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>36</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EALREADY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>37</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTSOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>38</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDESTADDRREQ</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>39</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMSGSIZE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>40</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROTOTYPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>41</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOPROTOOPT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>42</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROTONOSUPPORT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>43</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESOCKTNOSUPPORT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>44</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTSUP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>45</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPFNOSUPPORT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>46</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EAFNOSUPPORT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>47</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EADDRINUSE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>48</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EADDRNOTAVAIL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>49</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENETDOWN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>50</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENETUNREACH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>51</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENETRESET</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>52</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECONNABORTED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>53</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECONNRESET</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>54</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOBUFS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>55</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EISCONN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>56</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTCONN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>57</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESHUTDOWN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>58</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETOOMANYREFS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>59</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETIMEDOUT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>60</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECONNREFUSED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>61</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELOOP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>62</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENAMETOOLONG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>63</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EHOSTDOWN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EHOSTUNREACH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>65</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTEMPTY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>66</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROCLIM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>67</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EUSERS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>68</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDQUOT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>69</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESTALE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>70</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EREMOTE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>71</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADRPC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>72</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ERPCMISMATCH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>73</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROGUNAVAIL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>74</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROGMISMATCH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>75</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROCUNAVAIL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>76</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOLCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>77</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOSYS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>78</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EFTYPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>79</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EAUTH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>80</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENEEDAUTH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>81</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPWROFF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>82</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EDEVERR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>83</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOVERFLOW</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>84</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADEXEC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>85</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADARCH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>86</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ESHLIBVERS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>87</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADMACHO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>88</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ECANCELED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>89</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EIDRM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>90</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOMSG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>91</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EILSEQ</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>92</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOATTR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>93</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EBADMSG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>94</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EMULTIHOP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>95</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENODATA</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>96</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOLINK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>97</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOSR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>98</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOSTR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>99</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EPROTO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>100</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ETIME</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>101</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOPNOTSUPP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>102</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOPOLICY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>103</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ENOTRECOVERABLE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>104</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EOWNERDEAD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>105</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>EQFULL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>106</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>ELAST</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>106</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>size_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>posix01</span>::<span class='ident'>rlim_t</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_DUPFD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_GETFD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_SETFD</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_GETFL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_SETFL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIGTRAP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SIG_IGN</span>: <span class='ident'>size_t</span> <span class='op'>=</span> <span class='number'>1</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_APPEND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_DOOFFS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_ERR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_MARK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0008</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOCHECK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0010</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOSORT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0020</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOESCAPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x2000</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOSPACE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_ABORTED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>GLOB_NOMATCH</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>3</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_NORMAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_RANDOM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_SEQUENTIAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_WILLNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>POSIX_MADV_DONTNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_IOV_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>56</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_GETGR_R_SIZE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>70</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_GETPW_R_SIZE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>71</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_LOGIN_NAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>73</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MQ_PRIO_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>75</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_ATTR_STACKADDR</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>82</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_ATTR_STACKSIZE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>83</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_DESTRUCTOR_ITERATIONS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>85</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_KEYS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>86</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PRIO_INHERIT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>87</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PRIO_PROTECT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>88</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PRIORITY_SCHEDULING</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>89</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_PROCESS_SHARED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>90</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_SAFE_FUNCTIONS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>91</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_STACK_MIN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>93</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_THREADS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>94</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREADS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>96</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TTY_NAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>101</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_ATEXIT_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>107</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_CRYPT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>108</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_ENH_I18N</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>109</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_LEGACY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>110</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_REALTIME</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>111</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_REALTIME_THREADS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>112</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_SHM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>113</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_UNIX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>115</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>116</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_XCU_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>121</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_CREATE_JOINABLE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_CREATE_DETACHED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>PTHREAD_STACK_MIN</span>: <span class='ident'>size_t</span> <span class='op'>=</span> <span class='number'>8192</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_CPU</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_FSIZE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_DATA</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_STACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_CORE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_AS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_MEMLOCK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_NPROC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIMIT_NOFILE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIM_NLIMITS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_RLIMIT_POSIX_FLAG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1000</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RLIM_INFINITY</span>: <span class='ident'>rlim_t</span> <span class='op'>=</span> <span class='number'>0xffff_ffff_ffff_ffff</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RUSAGE_SELF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RUSAGE_CHILDREN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>RUSAGE_THREAD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix08</span> { + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_NORMAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_RANDOM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_SEQUENTIAL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_WILLNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_DONTNEED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_FREE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_ZERO_WIRED_PAGES</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_FREE_REUSABLE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_FREE_REUSE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MADV_CAN_REUSE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MINCORE_INCORE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MINCORE_REFERENCED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MINCORE_MODIFIED</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MINCORE_REFERENCED_OTHER</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MINCORE_MODIFIED_OTHER</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x10</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_UNIX</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_INET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>AF_INET6</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>30</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_STREAM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_DGRAM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOCK_RAW</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_TCP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_IP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_IPV6</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>41</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_MULTICAST_TTL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_MULTICAST_LOOP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_TTL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_HDRINCL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_ADD_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IP_DROP_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPV6_ADD_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPV6_DROP_MEMBERSHIP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_NODELAY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x01</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TCP_KEEPALIVE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SOL_SOCKET</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0xffff</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_DEBUG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x01</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_ACCEPTCONN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_REUSEADDR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_KEEPALIVE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0008</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_DONTROUTE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0010</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_BROADCAST</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0020</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_USELOOPBACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0040</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_LINGER</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0080</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_OOBINLINE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0100</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_REUSEPORT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0200</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDBUF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1001</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVBUF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDLOWAT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1003</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVLOWAT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1004</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_SNDTIMEO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1005</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_RCVTIMEO</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1006</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_ERROR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1007</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_TYPE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1008</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IFF_LOOPBACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x8</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_RD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_WR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SHUT_RDWR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_DSYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4194304</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_SYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>O_NONBLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>F_FULLFSYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>51</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_COPY</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0002</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_RENAME</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0020</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_NORESERVE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0040</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_NOEXTEND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0100</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_HASSEMAPHORE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0200</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_NOCACHE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0400</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_JIT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x0800</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MAP_STACK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>IPPROTO_RAW</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>255</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_NREAD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1020</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_NKE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1021</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_NOSIGPIPE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1022</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_NOADDRERR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1023</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_NWRITE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1024</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_DONTTRUNC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x2000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_WANTMORE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x4000</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SO_WANTOOBFLAG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x8000</span>; + } + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>sysconf</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_ARG_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_CHILD_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_CLK_TCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_NGROUPS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_OPEN_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_JOB_CONTROL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SAVED_IDS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_BASE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_DIM_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_SCALE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BC_STRING_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_COLL_WEIGHTS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_EXPR_NEST_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_LINE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_RE_DUP_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_VERSION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>17</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_C_BIND</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>18</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_C_DEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>19</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_CHAR_TERM</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>20</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_FORT_DEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>21</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_FORT_RUN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>22</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_LOCALEDEF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>23</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_SW_DEV</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>24</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_UPE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>25</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_STREAM_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>26</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TZNAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>27</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_ASYNCHRONOUS_IO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>28</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_PAGESIZE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>29</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MEMLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>30</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MEMLOCK_RANGE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>31</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MEMORY_PROTECTION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>32</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MESSAGE_PASSING</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>33</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_PRIORITIZED_IO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>34</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_PRIORITY_SCHEDULING</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>35</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_REALTIME_SIGNALS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>36</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SEMAPHORES</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>37</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_FSYNC</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>38</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SHARED_MEMORY_OBJECTS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>39</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SYNCHRONIZED_IO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>40</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TIMERS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>41</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_AIO_LISTIO_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>42</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_AIO_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>43</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_AIO_PRIO_DELTA_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>44</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_DELAYTIMER_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>45</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MQ_OPEN_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>46</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MAPPED_FILES</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>47</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_RTSIG_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>48</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SEM_NSEMS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>49</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SEM_VALUE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>50</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SIGQUEUE_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>51</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TIMER_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>52</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_NPROCESSORS_CONF</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>57</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_NPROCESSORS_ONLN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>58</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_PBS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>59</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_PBS_ACCOUNTING</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>60</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_PBS_CHECKPOINT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>61</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_PBS_LOCATE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>62</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_PBS_MESSAGE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>63</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_2_PBS_TRACK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>64</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_ADVISORY_INFO</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>65</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_BARRIERS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>66</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_CLOCK_SELECTION</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>67</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_CPUTIME</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>68</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_FILE_LOCKING</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>69</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_HOST_NAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>72</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_MONOTONIC_CLOCK</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>74</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_READER_WRITER_LOCKS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>76</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_REGEXP</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>77</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SHELL</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>78</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SPAWN</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>79</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SPIN_LOCKS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>80</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SPORADIC_SERVER</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>81</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_CPUTIME</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>84</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_THREAD_SPORADIC_SERVER</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>92</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TIMEOUTS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>95</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TRACE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>97</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TRACE_EVENT_FILTER</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>98</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TRACE_INHERIT</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>99</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TRACE_LOG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>100</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TYPED_MEMORY_OBJECTS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>102</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_V6_ILP32_OFF32</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>103</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_V6_ILP32_OFFBIG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>104</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_V6_LP64_OFF64</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>105</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_V6_LPBIG_OFFBIG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>106</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_IPV6</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>118</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_RAW_SOCKETS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>119</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SYMLOOP_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>120</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_PAGE_SIZE</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>_SC_PAGESIZE</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XOPEN_STREAMS</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>114</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XBS5_ILP32_OFF32</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>122</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XBS5_ILP32_OFFBIG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>123</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XBS5_LP64_OFF64</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>124</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_XBS5_LPBIG_OFFBIG</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>125</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_SS_REPL_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>126</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TRACE_EVENT_NAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>127</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TRACE_NAME_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>128</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TRACE_SYS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>129</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_TRACE_USER_EVENT_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>130</span>; + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_SC_PASS_MAX</span> : <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>131</span>; + } + } +} + + +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>funcs</span> { + <span class='comment'>// Thankfully most of c95 is universally available and does not vary by OS</span> + <span class='comment'>// or anything. The same is not true of POSIX.</span> + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>c95</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>ctype</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>}; + + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>isalnum</span>(<span class='ident'>c</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>isalpha</span>(<span class='ident'>c</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>iscntrl</span>(<span class='ident'>c</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>isdigit</span>(<span class='ident'>c</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>isgraph</span>(<span class='ident'>c</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>islower</span>(<span class='ident'>c</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>isprint</span>(<span class='ident'>c</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ispunct</span>(<span class='ident'>c</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>isspace</span>(<span class='ident'>c</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>isupper</span>(<span class='ident'>c</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>isxdigit</span>(<span class='ident'>c</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>tolower</span>(<span class='ident'>c</span>: <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>toupper</span>(<span class='ident'>c</span>: <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_char</span>; + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>stdio</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>FILE</span>, <span class='ident'>c_void</span>, <span class='ident'>fpos_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>, <span class='ident'>c_long</span>, <span class='ident'>size_t</span>}; + + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fopen</span>(<span class='ident'>filename</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>mode</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>freopen</span>(<span class='ident'>filename</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>mode</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>file</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>) + <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fflush</span>(<span class='ident'>file</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fclose</span>(<span class='ident'>file</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>remove</span>(<span class='ident'>filename</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>rename</span>(<span class='ident'>oldname</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>newname</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>tmpfile</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>setvbuf</span>(<span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>, + <span class='ident'>buffer</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + <span class='ident'>mode</span>: <span class='ident'>c_int</span>, + <span class='ident'>size</span>: <span class='ident'>size_t</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>setbuf</span>(<span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>); + <span class='comment'>// Omitted: printf and scanf variants.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fgetc</span>(<span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fgets</span>(<span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, <span class='ident'>n</span>: <span class='ident'>c_int</span>, <span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>) + <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fputc</span>(<span class='ident'>c</span>: <span class='ident'>c_int</span>, <span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fputs</span>(<span class='ident'>s</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>)<span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='comment'>// Omitted: getc, getchar (might be macros).</span> + + <span class='comment'>// Omitted: gets, so ridiculously unsafe that it should not</span> + <span class='comment'>// survive.</span> + + <span class='comment'>// Omitted: putc, putchar (might be macros).</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>puts</span>(<span class='ident'>s</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ungetc</span>(<span class='ident'>c</span>: <span class='ident'>c_int</span>, <span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fread</span>(<span class='ident'>ptr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>size</span>: <span class='ident'>size_t</span>, + <span class='ident'>nobj</span>: <span class='ident'>size_t</span>, + <span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>) + <span class='op'>-></span> <span class='ident'>size_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fwrite</span>(<span class='ident'>ptr</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, + <span class='ident'>size</span>: <span class='ident'>size_t</span>, + <span class='ident'>nobj</span>: <span class='ident'>size_t</span>, + <span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>) + <span class='op'>-></span> <span class='ident'>size_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fseek</span>(<span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>, <span class='ident'>offset</span>: <span class='ident'>c_long</span>, <span class='ident'>whence</span>: <span class='ident'>c_int</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ftell</span>(<span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>) <span class='op'>-></span> <span class='ident'>c_long</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>rewind</span>(<span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fgetpos</span>(<span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>, <span class='ident'>ptr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>fpos_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fsetpos</span>(<span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>, <span class='ident'>ptr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>fpos_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>feof</span>(<span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ferror</span>(<span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>perror</span>(<span class='ident'>s</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>); + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>stdlib</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::<span class='ident'>c_void</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_double</span>, <span class='ident'>c_int</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_long</span>, <span class='ident'>c_uint</span>, <span class='ident'>c_ulong</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>size_t</span>}; + + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>abs</span>(<span class='ident'>i</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>labs</span>(<span class='ident'>i</span>: <span class='ident'>c_long</span>) <span class='op'>-></span> <span class='ident'>c_long</span>; + <span class='comment'>// Omitted: div, ldiv (return pub type incomplete).</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>atof</span>(<span class='ident'>s</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_double</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>atoi</span>(<span class='ident'>s</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strtod</span>(<span class='ident'>s</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>endp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_double</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strtol</span>(<span class='ident'>s</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>endp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, <span class='ident'>base</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_long</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strtoul</span>(<span class='ident'>s</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>endp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + <span class='ident'>base</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_ulong</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>calloc</span>(<span class='ident'>nobj</span>: <span class='ident'>size_t</span>, <span class='ident'>size</span>: <span class='ident'>size_t</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>malloc</span>(<span class='ident'>size</span>: <span class='ident'>size_t</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>realloc</span>(<span class='ident'>p</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>size</span>: <span class='ident'>size_t</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>free</span>(<span class='ident'>p</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>); + + <span class='doccomment'>/// Exits the running program in a possibly dangerous manner.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// # Unsafety</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// While this forces your program to exit, it does so in a way that has</span> + <span class='doccomment'>/// consequences. This will skip all unwinding code, which means that anything</span> + <span class='doccomment'>/// relying on unwinding for cleanup (such as flushing and closing a buffer to a</span> + <span class='doccomment'>/// file) may act in an unexpected way.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// # Examples</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```no_run,ignore</span> + <span class='doccomment'>/// extern crate libc;</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// fn main() {</span> + <span class='doccomment'>/// unsafe {</span> + <span class='doccomment'>/// libc::exit(1);</span> + <span class='doccomment'>/// }</span> + <span class='doccomment'>/// }</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>exit</span>(<span class='ident'>status</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='op'>!</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>_exit</span>(<span class='ident'>status</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='op'>!</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>atexit</span>(<span class='ident'>cb</span>: <span class='kw'>extern</span> <span class='kw'>fn</span>()) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>system</span>(<span class='ident'>s</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getenv</span>(<span class='ident'>s</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='comment'>// Omitted: bsearch, qsort</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>rand</span>() <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>srand</span>(<span class='ident'>seed</span>: <span class='ident'>c_uint</span>); + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>string</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::<span class='ident'>c_void</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>, <span class='ident'>size_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>wchar_t</span>}; + + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strcpy</span>(<span class='ident'>dst</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + <span class='ident'>src</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strncpy</span>(<span class='ident'>dst</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, <span class='ident'>src</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>n</span>: <span class='ident'>size_t</span>) + <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strcat</span>(<span class='ident'>s</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, <span class='ident'>ct</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strncat</span>(<span class='ident'>s</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, <span class='ident'>ct</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>n</span>: <span class='ident'>size_t</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strcmp</span>(<span class='ident'>cs</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>ct</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strncmp</span>(<span class='ident'>cs</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>ct</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>n</span>: <span class='ident'>size_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strcoll</span>(<span class='ident'>cs</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>ct</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strchr</span>(<span class='ident'>cs</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>c</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strrchr</span>(<span class='ident'>cs</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>c</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strspn</span>(<span class='ident'>cs</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>ct</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>size_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strcspn</span>(<span class='ident'>cs</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>ct</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>size_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strpbrk</span>(<span class='ident'>cs</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>ct</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strstr</span>(<span class='ident'>cs</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>ct</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strlen</span>(<span class='ident'>cs</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>size_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strerror</span>(<span class='ident'>n</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strtok</span>(<span class='ident'>s</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, <span class='ident'>t</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>strxfrm</span>(<span class='ident'>s</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, <span class='ident'>ct</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>n</span>: <span class='ident'>size_t</span>) <span class='op'>-></span> <span class='ident'>size_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>wcslen</span>(<span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>wchar_t</span>) <span class='op'>-></span> <span class='ident'>size_t</span>; + + <span class='comment'>// Omitted: memcpy, memmove, memset (provided by LLVM)</span> + + <span class='comment'>// These are fine to execute on the Rust stack. They must be,</span> + <span class='comment'>// in fact, because LLVM generates calls to them!</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>memcmp</span>(<span class='ident'>cx</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>ct</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, + <span class='ident'>n</span>: <span class='ident'>size_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>memchr</span>(<span class='ident'>cx</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>c</span>: <span class='ident'>c_int</span>, + <span class='ident'>n</span>: <span class='ident'>size_t</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>; + } + } + } + + <span class='comment'>// Microsoft helpfully underscore-qualifies all of its POSIX-like symbols</span> + <span class='comment'>// to make sure you don't use them accidentally. It also randomly deviates</span> + <span class='comment'>// from the exact signatures you might otherwise expect, and omits much,</span> + <span class='comment'>// so be careful when trying to write portable code; it won't always work</span> + <span class='comment'>// with the same POSIX functions and types as other platforms.</span> + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"windows"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>stat_</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>posix01</span>::{<span class='ident'>stat</span>, <span class='ident'>utimbuf</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_char</span>, <span class='ident'>wchar_t</span>}; + + <span class='kw'>extern</span> { + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_chmod"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>chmod</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>mode</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_wchmod"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>wchmod</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>wchar_t</span>, <span class='ident'>mode</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_mkdir"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mkdir</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_wrmdir"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>wrmdir</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>wchar_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_fstat64"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fstat</span>(<span class='ident'>fildes</span>: <span class='ident'>c_int</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>stat</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_stat64"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>stat</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>stat</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_wstat64"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>wstat</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>wchar_t</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>stat</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_wutime64"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>wutime</span>(<span class='ident'>file</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>wchar_t</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>utimbuf</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>stdio</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::<span class='ident'>FILE</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_char</span>}; + + <span class='kw'>extern</span> { + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_popen"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>popen</span>(<span class='ident'>command</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>mode</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_pclose"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>pclose</span>(<span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_fdopen"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fdopen</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>mode</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_fileno"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fileno</span>(<span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>fcntl</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_char</span>, <span class='ident'>wchar_t</span>}; + <span class='kw'>extern</span> { + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_open"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>open</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>oflag</span>: <span class='ident'>c_int</span>, <span class='ident'>mode</span>: <span class='ident'>c_int</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_wopen"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>wopen</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>wchar_t</span>, <span class='ident'>oflag</span>: <span class='ident'>c_int</span>, <span class='ident'>mode</span>: <span class='ident'>c_int</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_creat"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>creat</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>mode</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>dirent</span> { + <span class='comment'>// Not supplied at all.</span> + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>unistd</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::<span class='ident'>c_void</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_uint</span>, <span class='ident'>c_char</span>, + <span class='ident'>c_long</span>, <span class='ident'>size_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c99</span>::<span class='ident'>intptr_t</span>; + + <span class='kw'>extern</span> { + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_access"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>access</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>amode</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_chdir"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>chdir</span>(<span class='ident'>dir</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_close"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>close</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_dup"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>dup</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_dup2"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>dup2</span>(<span class='ident'>src</span>: <span class='ident'>c_int</span>, <span class='ident'>dst</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_execv"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>execv</span>(<span class='ident'>prog</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>argv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>intptr_t</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_execve"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>execve</span>(<span class='ident'>prog</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>argv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>envp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_execvp"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>execvp</span>(<span class='ident'>c</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>argv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_execvpe"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>execvpe</span>(<span class='ident'>c</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>argv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>envp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_getcwd"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getcwd</span>(<span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, <span class='ident'>size</span>: <span class='ident'>size_t</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_getpid"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getpid</span>() <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_isatty"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>isatty</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_lseek"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>lseek</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>offset</span>: <span class='ident'>c_long</span>, <span class='ident'>origin</span>: <span class='ident'>c_int</span>) + <span class='op'>-></span> <span class='ident'>c_long</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_pipe"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>pipe</span>(<span class='ident'>fds</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_int</span>, <span class='ident'>psize</span>: <span class='ident'>c_uint</span>, <span class='ident'>textmode</span>: <span class='ident'>c_int</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_read"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>read</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>count</span>: <span class='ident'>c_uint</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_rmdir"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>rmdir</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_unlink"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>unlink</span>(<span class='ident'>c</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_write"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>write</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, + <span class='ident'>count</span>: <span class='ident'>c_uint</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>mman</span> { + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"linux"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"macos"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"ios"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"freebsd"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"dragonfly"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"bitrig"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"openbsd"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix88</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>stat_</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix01</span>::<span class='ident'>stat</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::<span class='ident'>mode_t</span>; + + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>chmod</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>mode</span>: <span class='ident'>mode_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fchmod</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>mode</span>: <span class='ident'>mode_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"linux"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"freebsd"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"dragonfly"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"bitrig"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"openbsd"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"ios"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fstat</span>(<span class='ident'>fildes</span>: <span class='ident'>c_int</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>stat</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"macos"</span>)]</span> + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"fstat64"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fstat</span>(<span class='ident'>fildes</span>: <span class='ident'>c_int</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>stat</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mkdir</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>mode</span>: <span class='ident'>mode_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mkfifo</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>mode</span>: <span class='ident'>mode_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"linux"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"freebsd"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"dragonfly"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"bitrig"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"openbsd"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"ios"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>stat</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>stat</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"macos"</span>)]</span> + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"stat64"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>stat</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>stat</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>stdio</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::<span class='ident'>FILE</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>}; + + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>popen</span>(<span class='ident'>command</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>mode</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>pclose</span>(<span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fdopen</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>mode</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fileno</span>(<span class='ident'>stream</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>FILE</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>fcntl</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::<span class='ident'>mode_t</span>; + + <span class='kw'>mod</span> <span class='ident'>open_shim</span> { + <span class='kw'>extern</span> { + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"macos"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"ios"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>open</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> ::<span class='ident'>c_char</span>, <span class='ident'>oflag</span>: ::<span class='ident'>c_int</span>, ...) + <span class='op'>-></span> ::<span class='ident'>c_int</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"macos"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"ios"</span>)))]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>open</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> ::<span class='ident'>c_char</span>, <span class='ident'>oflag</span>: ::<span class='ident'>c_int</span>, <span class='ident'>mode</span>: ::<span class='ident'>mode_t</span>) + <span class='op'>-></span> ::<span class='ident'>c_int</span>; + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"macos"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"ios"</span>))]</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>unsafe</span> <span class='kw'>extern</span> <span class='kw'>fn</span> <span class='ident'>open</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>oflag</span>: <span class='ident'>c_int</span>, <span class='ident'>mode</span>: <span class='ident'>mode_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_uint</span>; + <span class='ident'>open_shim</span>::<span class='ident'>open</span>(<span class='ident'>path</span>, <span class='ident'>oflag</span>, <span class='ident'>mode</span> <span class='kw'>as</span> <span class='ident'>c_uint</span>) + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"macos"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"ios"</span>)))]</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>unsafe</span> <span class='kw'>extern</span> <span class='kw'>fn</span> <span class='ident'>open</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>oflag</span>: <span class='ident'>c_int</span>, <span class='ident'>mode</span>: <span class='ident'>mode_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span> { + <span class='ident'>open_shim</span>::<span class='ident'>open</span>(<span class='ident'>path</span>, <span class='ident'>oflag</span>, <span class='ident'>mode</span>) + } + + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>creat</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>mode</span>: <span class='ident'>mode_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fcntl</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>cmd</span>: <span class='ident'>c_int</span>, ...) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>dirent</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>posix88</span>::{<span class='ident'>DIR</span>, <span class='ident'>dirent_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>, <span class='ident'>c_long</span>}; + + <span class='comment'>// NB: On OS X opendir and readdir have two versions,</span> + <span class='comment'>// one for 32-bit kernelspace and one for 64.</span> + <span class='comment'>// We should be linking to the 64-bit ones, called</span> + <span class='comment'>// opendir$INODE64, etc. but for some reason rustc</span> + <span class='comment'>// doesn't link it correctly on i686, so we're going</span> + <span class='comment'>// through a C function that mysteriously does work.</span> + + <span class='kw'>extern</span> { + <span class='attribute'>#[<span class='ident'>link_name</span><span class='op'>=</span><span class='string'>"rust_opendir"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>opendir</span>(<span class='ident'>dirname</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>DIR</span>; + <span class='attribute'>#[<span class='ident'>link_name</span><span class='op'>=</span><span class='string'>"rust_readdir_r"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>readdir_r</span>(<span class='ident'>dirp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>DIR</span>, <span class='ident'>entry</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>dirent_t</span>, + <span class='ident'>result</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>dirent_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>closedir</span>(<span class='ident'>dirp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>DIR</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>rewinddir</span>(<span class='ident'>dirp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>DIR</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>seekdir</span>(<span class='ident'>dirp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>DIR</span>, <span class='ident'>loc</span>: <span class='ident'>c_long</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>telldir</span>(<span class='ident'>dirp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>DIR</span>) <span class='op'>-></span> <span class='ident'>c_long</span>; + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>unistd</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::<span class='ident'>c_void</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>, <span class='ident'>c_long</span>, <span class='ident'>c_uint</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>size_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>posix01</span>::<span class='ident'>timespec</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix01</span>::<span class='ident'>utimbuf</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>gid_t</span>, <span class='ident'>off_t</span>, <span class='ident'>pid_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>ssize_t</span>, <span class='ident'>uid_t</span>}; + + <span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>_PC_NAME_MAX</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>))]</span> + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>access</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>amode</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>alarm</span>(<span class='ident'>seconds</span>: <span class='ident'>c_uint</span>) <span class='op'>-></span> <span class='ident'>c_uint</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>chdir</span>(<span class='ident'>dir</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>chown</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>uid</span>: <span class='ident'>uid_t</span>, + <span class='ident'>gid</span>: <span class='ident'>gid_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>close</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>dup</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>dup2</span>(<span class='ident'>src</span>: <span class='ident'>c_int</span>, <span class='ident'>dst</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>execv</span>(<span class='ident'>prog</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>argv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>execve</span>(<span class='ident'>prog</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>argv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>envp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>execvp</span>(<span class='ident'>c</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>argv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fork</span>() <span class='op'>-></span> <span class='ident'>pid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fpathconf</span>(<span class='ident'>filedes</span>: <span class='ident'>c_int</span>, <span class='ident'>name</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_long</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getcwd</span>(<span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, <span class='ident'>size</span>: <span class='ident'>size_t</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getegid</span>() <span class='op'>-></span> <span class='ident'>gid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>geteuid</span>() <span class='op'>-></span> <span class='ident'>uid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getgid</span>() <span class='op'>-></span> <span class='ident'>gid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getgroups</span>(<span class='ident'>ngroups_max</span>: <span class='ident'>c_int</span>, <span class='ident'>groups</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>gid_t</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getlogin</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getopt</span>(<span class='ident'>argc</span>: <span class='ident'>c_int</span>, <span class='ident'>argv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>optstr</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getpgrp</span>() <span class='op'>-></span> <span class='ident'>pid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getpid</span>() <span class='op'>-></span> <span class='ident'>pid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getppid</span>() <span class='op'>-></span> <span class='ident'>pid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getuid</span>() <span class='op'>-></span> <span class='ident'>uid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getsid</span>(<span class='ident'>pid</span>: <span class='ident'>pid_t</span>) <span class='op'>-></span> <span class='ident'>pid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>isatty</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>link</span>(<span class='ident'>src</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>dst</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>lseek</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>offset</span>: <span class='ident'>off_t</span>, <span class='ident'>whence</span>: <span class='ident'>c_int</span>) + <span class='op'>-></span> <span class='ident'>off_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>pathconf</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, <span class='ident'>name</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_long</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>pause</span>() <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>pipe</span>(<span class='ident'>fds</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>read</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>count</span>: <span class='ident'>size_t</span>) + <span class='op'>-></span> <span class='ident'>ssize_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>rmdir</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>setgid</span>(<span class='ident'>gid</span>: <span class='ident'>gid_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>setpgid</span>(<span class='ident'>pid</span>: <span class='ident'>pid_t</span>, <span class='ident'>pgid</span>: <span class='ident'>pid_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>setsid</span>() <span class='op'>-></span> <span class='ident'>pid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>setuid</span>(<span class='ident'>uid</span>: <span class='ident'>uid_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>sleep</span>(<span class='ident'>secs</span>: <span class='ident'>c_uint</span>) <span class='op'>-></span> <span class='ident'>c_uint</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>usleep</span>(<span class='ident'>secs</span>: <span class='ident'>c_uint</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>nanosleep</span>(<span class='ident'>rqtp</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>timespec</span>, + <span class='ident'>rmtp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>timespec</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>sysconf</span>(<span class='ident'>name</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_long</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>tcgetpgrp</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>pid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ttyname</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>unlink</span>(<span class='ident'>c</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>wait</span>(<span class='ident'>status</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>pid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>waitpid</span>(<span class='ident'>pid</span>: <span class='ident'>pid_t</span>, <span class='ident'>status</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_int</span>, <span class='ident'>options</span>: <span class='ident'>c_int</span>) + <span class='op'>-></span> <span class='ident'>pid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>write</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>count</span>: <span class='ident'>size_t</span>) + <span class='op'>-></span> <span class='ident'>ssize_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>pread</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>count</span>: <span class='ident'>size_t</span>, + <span class='ident'>offset</span>: <span class='ident'>off_t</span>) <span class='op'>-></span> <span class='ident'>ssize_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>pwrite</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>count</span>: <span class='ident'>size_t</span>, + <span class='ident'>offset</span>: <span class='ident'>off_t</span>) <span class='op'>-></span> <span class='ident'>ssize_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>utime</span>(<span class='ident'>file</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>utimbuf</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>)]</span> + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>access</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>amode</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>chdir</span>(<span class='ident'>dir</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>chown</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>uid</span>: <span class='ident'>uid_t</span>, + <span class='ident'>gid</span>: <span class='ident'>gid_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>close</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>dup</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>dup2</span>(<span class='ident'>src</span>: <span class='ident'>c_int</span>, <span class='ident'>dst</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>execv</span>(<span class='ident'>prog</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>argv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>execve</span>(<span class='ident'>prog</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>argv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>envp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>execvp</span>(<span class='ident'>c</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>argv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fork</span>() <span class='op'>-></span> <span class='ident'>pid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getcwd</span>(<span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, <span class='ident'>size</span>: <span class='ident'>size_t</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getegid</span>() <span class='op'>-></span> <span class='ident'>gid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>geteuid</span>() <span class='op'>-></span> <span class='ident'>uid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getgid</span>() <span class='op'>-></span> <span class='ident'>gid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getlogin</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getopt</span>(<span class='ident'>argc</span>: <span class='ident'>c_int</span>, <span class='ident'>argv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>optstr</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getuid</span>() <span class='op'>-></span> <span class='ident'>uid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getsid</span>(<span class='ident'>pid</span>: <span class='ident'>pid_t</span>) <span class='op'>-></span> <span class='ident'>pid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>isatty</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>link</span>(<span class='ident'>src</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>dst</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>lseek</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>offset</span>: <span class='ident'>off_t</span>, <span class='ident'>whence</span>: <span class='ident'>c_int</span>) + <span class='op'>-></span> <span class='ident'>off_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>pipe</span>(<span class='ident'>fds</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>read</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>count</span>: <span class='ident'>size_t</span>) + <span class='op'>-></span> <span class='ident'>ssize_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>rmdir</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>setgid</span>(<span class='ident'>gid</span>: <span class='ident'>gid_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>setuid</span>(<span class='ident'>uid</span>: <span class='ident'>uid_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>sleep</span>(<span class='ident'>secs</span>: <span class='ident'>c_uint</span>) <span class='op'>-></span> <span class='ident'>c_uint</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>usleep</span>(<span class='ident'>secs</span>: <span class='ident'>c_uint</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>nanosleep</span>(<span class='ident'>rqtp</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>timespec</span>, + <span class='ident'>rmtp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>timespec</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>sysconf</span>(<span class='ident'>name</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_long</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ttyname</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>unlink</span>(<span class='ident'>c</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>wait</span>(<span class='ident'>status</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>pid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>waitpid</span>(<span class='ident'>pid</span>: <span class='ident'>pid_t</span>, <span class='ident'>status</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_int</span>, <span class='ident'>options</span>: <span class='ident'>c_int</span>) + <span class='op'>-></span> <span class='ident'>pid_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>write</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>count</span>: <span class='ident'>size_t</span>) + <span class='op'>-></span> <span class='ident'>ssize_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>pread</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>count</span>: <span class='ident'>size_t</span>, + <span class='ident'>offset</span>: <span class='ident'>off_t</span>) <span class='op'>-></span> <span class='ident'>ssize_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>pwrite</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>count</span>: <span class='ident'>size_t</span>, + <span class='ident'>offset</span>: <span class='ident'>off_t</span>) <span class='op'>-></span> <span class='ident'>ssize_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>utime</span>(<span class='ident'>file</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>utimbuf</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>signal</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>pid_t</span>}; + + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>kill</span>(<span class='ident'>pid</span>: <span class='ident'>pid_t</span>, <span class='ident'>sig</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>mman</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>size_t</span>, <span class='ident'>c_int</span>, <span class='ident'>c_char</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>mode_t</span>, <span class='ident'>off_t</span>}; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>))]</span> + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mlock</span>(<span class='ident'>addr</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>size_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>munlock</span>(<span class='ident'>addr</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>size_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mlockall</span>(<span class='ident'>flags</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>munlockall</span>() <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mprotect</span>(<span class='ident'>addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>size_t</span>, <span class='ident'>prot</span>: <span class='ident'>c_int</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>msync</span>(<span class='ident'>addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>size_t</span>, <span class='ident'>flags</span>: <span class='ident'>c_int</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>shm_open</span>(<span class='ident'>name</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>oflag</span>: <span class='ident'>c_int</span>, <span class='ident'>mode</span>: <span class='ident'>mode_t</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>shm_unlink</span>(<span class='ident'>name</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mmap</span>(<span class='ident'>addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>len</span>: <span class='ident'>size_t</span>, + <span class='ident'>prot</span>: <span class='ident'>c_int</span>, + <span class='ident'>flags</span>: <span class='ident'>c_int</span>, + <span class='ident'>fd</span>: <span class='ident'>c_int</span>, + <span class='ident'>offset</span>: <span class='ident'>off_t</span>) + <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>munmap</span>(<span class='ident'>addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>size_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>net</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_uint</span>}; + + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>if_nametoindex</span>(<span class='ident'>ifname</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_uint</span>; + } + } + + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"linux"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"macos"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"ios"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"freebsd"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"dragonfly"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"bitrig"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"openbsd"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>stat_</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix01</span>::<span class='ident'>stat</span>; + + <span class='kw'>extern</span> { + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"linux"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"freebsd"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"dragonfly"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"bitrig"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"openbsd"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"ios"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>lstat</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>stat</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"macos"</span>)]</span> + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"lstat64"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>lstat</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>stat</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>unistd</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>, <span class='ident'>size_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::{<span class='ident'>ssize_t</span>, <span class='ident'>off_t</span>}; + + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>readlink</span>(<span class='ident'>path</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, + <span class='ident'>bufsz</span>: <span class='ident'>size_t</span>) + <span class='op'>-></span> <span class='ident'>ssize_t</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fsync</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"linux"</span>, <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fdatasync</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>setenv</span>(<span class='ident'>name</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>val</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>overwrite</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>unsetenv</span>(<span class='ident'>name</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>putenv</span>(<span class='ident'>string</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>symlink</span>(<span class='ident'>path1</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>path2</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ftruncate</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>, <span class='ident'>length</span>: <span class='ident'>off_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>signal</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>posix01</span>::<span class='ident'>sighandler_t</span>; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>all</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>, <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"arm"</span>)))]</span> + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>signal</span>(<span class='ident'>signum</span>: <span class='ident'>c_int</span>, + <span class='ident'>handler</span>: <span class='ident'>sighandler_t</span>) <span class='op'>-></span> <span class='ident'>sighandler_t</span>; + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>all</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>, <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"arm"</span>))]</span> + <span class='kw'>extern</span> { + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"bsd_signal"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>signal</span>(<span class='ident'>signum</span>: <span class='ident'>c_int</span>, + <span class='ident'>handler</span>: <span class='ident'>sighandler_t</span>) <span class='op'>-></span> <span class='ident'>sighandler_t</span>; + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>glob</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>posix01</span>::{<span class='ident'>glob_t</span>}; + + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>glob</span>(<span class='ident'>pattern</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>flags</span>: <span class='ident'>c_int</span>, + <span class='ident'>errfunc</span>: ::<span class='ident'>core</span>::<span class='ident'>option</span>::<span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw'>extern</span> <span class='string'>"C"</span> <span class='kw'>fn</span>(<span class='ident'>epath</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>errno</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span><span class='op'>></span>, + <span class='ident'>pglob</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>glob_t</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>globfree</span>(<span class='ident'>pglob</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>glob_t</span>); + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>mman</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>size_t</span>}; + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>))]</span> + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>posix_madvise</span>(<span class='ident'>addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>len</span>: <span class='ident'>size_t</span>, + <span class='ident'>advice</span>: <span class='ident'>c_int</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>resource</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>posix01</span>::<span class='ident'>rlimit</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>bsd43</span>::<span class='ident'>rusage</span>; + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getrlimit</span>(<span class='ident'>resource</span>: <span class='ident'>c_int</span>, <span class='ident'>rlim</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>rlimit</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>setrlimit</span>(<span class='ident'>resource</span>: <span class='ident'>c_int</span>, <span class='ident'>rlim</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>rlimit</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getrusage</span>(<span class='ident'>resource</span>: <span class='ident'>c_int</span>, <span class='ident'>usage</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>rusage</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + } + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"windows"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix01</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>stat_</span> { + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>unistd</span> { + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>glob</span> { + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>mman</span> { + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>net</span> { + } + } + + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"windows"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"linux"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"macos"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"ios"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"freebsd"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"dragonfly"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"bitrig"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"openbsd"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>posix08</span> { + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>unistd</span> { + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>windows</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd43</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>bsd44</span>::{<span class='ident'>socklen_t</span>, <span class='ident'>sockaddr</span>, <span class='ident'>ifaddrs</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>size_t</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::<span class='ident'>ssize_t</span>; + + <span class='kw'>extern</span> <span class='string'>"system"</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>socket</span>(<span class='ident'>domain</span>: <span class='ident'>c_int</span>, <span class='ident'>ty</span>: <span class='ident'>c_int</span>, <span class='ident'>protocol</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>connect</span>(<span class='ident'>socket</span>: <span class='ident'>c_int</span>, <span class='ident'>address</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>sockaddr</span>, + <span class='ident'>len</span>: <span class='ident'>socklen_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>bind</span>(<span class='ident'>socket</span>: <span class='ident'>c_int</span>, <span class='ident'>address</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>sockaddr</span>, + <span class='ident'>address_len</span>: <span class='ident'>socklen_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>listen</span>(<span class='ident'>socket</span>: <span class='ident'>c_int</span>, <span class='ident'>backlog</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>accept</span>(<span class='ident'>socket</span>: <span class='ident'>c_int</span>, <span class='ident'>address</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='ident'>address_len</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>socklen_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getpeername</span>(<span class='ident'>socket</span>: <span class='ident'>c_int</span>, <span class='ident'>address</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='ident'>address_len</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>socklen_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getsockname</span>(<span class='ident'>socket</span>: <span class='ident'>c_int</span>, <span class='ident'>address</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='ident'>address_len</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>socklen_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>setsockopt</span>(<span class='ident'>socket</span>: <span class='ident'>c_int</span>, <span class='ident'>level</span>: <span class='ident'>c_int</span>, <span class='ident'>name</span>: <span class='ident'>c_int</span>, + <span class='ident'>value</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, + <span class='ident'>option_len</span>: <span class='ident'>socklen_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>recv</span>(<span class='ident'>socket</span>: <span class='ident'>c_int</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>size_t</span>, + <span class='ident'>flags</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>ssize_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>send</span>(<span class='ident'>socket</span>: <span class='ident'>c_int</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>size_t</span>, + <span class='ident'>flags</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>ssize_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>recvfrom</span>(<span class='ident'>socket</span>: <span class='ident'>c_int</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>size_t</span>, + <span class='ident'>flags</span>: <span class='ident'>c_int</span>, <span class='ident'>addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='ident'>addrlen</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>socklen_t</span>) <span class='op'>-></span> <span class='ident'>ssize_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>sendto</span>(<span class='ident'>socket</span>: <span class='ident'>c_int</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>size_t</span>, + <span class='ident'>flags</span>: <span class='ident'>c_int</span>, <span class='ident'>addr</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>sockaddr</span>, + <span class='ident'>addrlen</span>: <span class='ident'>socklen_t</span>) <span class='op'>-></span> <span class='ident'>ssize_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getifaddrs</span>(<span class='ident'>ifap</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ifaddrs</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>freeifaddrs</span>(<span class='ident'>ifa</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ifaddrs</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>shutdown</span>(<span class='ident'>socket</span>: <span class='ident'>c_int</span>, <span class='ident'>how</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>windows</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd43</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>bsd44</span>::{<span class='ident'>socklen_t</span>, <span class='ident'>sockaddr</span>, <span class='ident'>SOCKET</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>posix88</span>::<span class='ident'>ssize_t</span>; + + <span class='kw'>extern</span> <span class='string'>"system"</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>socket</span>(<span class='ident'>domain</span>: <span class='ident'>c_int</span>, <span class='ident'>ty</span>: <span class='ident'>c_int</span>, <span class='ident'>protocol</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>SOCKET</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>connect</span>(<span class='ident'>socket</span>: <span class='ident'>SOCKET</span>, <span class='ident'>address</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>sockaddr</span>, + <span class='ident'>len</span>: <span class='ident'>socklen_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>bind</span>(<span class='ident'>socket</span>: <span class='ident'>SOCKET</span>, <span class='ident'>address</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>sockaddr</span>, + <span class='ident'>address_len</span>: <span class='ident'>socklen_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>listen</span>(<span class='ident'>socket</span>: <span class='ident'>SOCKET</span>, <span class='ident'>backlog</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>accept</span>(<span class='ident'>socket</span>: <span class='ident'>SOCKET</span>, <span class='ident'>address</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='ident'>address_len</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>socklen_t</span>) <span class='op'>-></span> <span class='ident'>SOCKET</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getpeername</span>(<span class='ident'>socket</span>: <span class='ident'>SOCKET</span>, <span class='ident'>address</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='ident'>address_len</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>socklen_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getsockname</span>(<span class='ident'>socket</span>: <span class='ident'>SOCKET</span>, <span class='ident'>address</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='ident'>address_len</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>socklen_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>setsockopt</span>(<span class='ident'>socket</span>: <span class='ident'>SOCKET</span>, <span class='ident'>level</span>: <span class='ident'>c_int</span>, <span class='ident'>name</span>: <span class='ident'>c_int</span>, + <span class='ident'>value</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, + <span class='ident'>option_len</span>: <span class='ident'>socklen_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>closesocket</span>(<span class='ident'>socket</span>: <span class='ident'>SOCKET</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>recv</span>(<span class='ident'>socket</span>: <span class='ident'>SOCKET</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>c_int</span>, + <span class='ident'>flags</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>send</span>(<span class='ident'>socket</span>: <span class='ident'>SOCKET</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>c_int</span>, + <span class='ident'>flags</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>recvfrom</span>(<span class='ident'>socket</span>: <span class='ident'>SOCKET</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>c_int</span>, + <span class='ident'>flags</span>: <span class='ident'>c_int</span>, <span class='ident'>addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>sockaddr</span>, + <span class='ident'>addrlen</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>ssize_t</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>sendto</span>(<span class='ident'>socket</span>: <span class='ident'>SOCKET</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>c_int</span>, + <span class='ident'>flags</span>: <span class='ident'>c_int</span>, <span class='ident'>addr</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>sockaddr</span>, + <span class='ident'>addrlen</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>shutdown</span>(<span class='ident'>socket</span>: <span class='ident'>SOCKET</span>, <span class='ident'>how</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"macos"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"ios"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"freebsd"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"dragonfly"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"bitrig"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"openbsd"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_uchar</span>, <span class='ident'>c_int</span>, <span class='ident'>c_uint</span>, <span class='ident'>c_ulong</span>, <span class='ident'>size_t</span>}; + + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ioctl</span>(<span class='ident'>d</span>: <span class='ident'>c_int</span>, <span class='ident'>request</span>: <span class='ident'>c_ulong</span>, ...) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>sysctl</span>(<span class='ident'>name</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_int</span>, + <span class='ident'>namelen</span>: <span class='ident'>c_uint</span>, + <span class='ident'>oldp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>oldlenp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>size_t</span>, + <span class='ident'>newp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>newlen</span>: <span class='ident'>size_t</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>sysctlbyname</span>(<span class='ident'>name</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>oldp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>oldlenp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>size_t</span>, + <span class='ident'>newp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>newlen</span>: <span class='ident'>size_t</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>sysctlnametomib</span>(<span class='ident'>name</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>mibp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_int</span>, + <span class='ident'>sizep</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>size_t</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getdtablesize</span>() <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>madvise</span>(<span class='ident'>addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>size_t</span>, <span class='ident'>advice</span>: <span class='ident'>c_int</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mincore</span>(<span class='ident'>addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>size_t</span>, <span class='ident'>vec</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_uchar</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>realpath</span>(<span class='ident'>pathname</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>resolved</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>) + <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>; + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"linux"</span>, <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::{<span class='ident'>c_void</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_uchar</span>, <span class='ident'>c_int</span>, <span class='ident'>size_t</span>}; + + <span class='kw'>extern</span> { + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>all</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>, <span class='ident'>target_arch</span> <span class='op'>=</span> <span class='string'>"aarch64"</span>)))]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getdtablesize</span>() <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ioctl</span>(<span class='ident'>d</span>: <span class='ident'>c_int</span>, <span class='ident'>request</span>: <span class='ident'>c_int</span>, ...) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>madvise</span>(<span class='ident'>addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>size_t</span>, <span class='ident'>advice</span>: <span class='ident'>c_int</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mincore</span>(<span class='ident'>addr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>size_t</span>, <span class='ident'>vec</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_uchar</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::<span class='ident'>c_int</span>; + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>getdtablesize</span>() <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"windows"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bsd44</span> { + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"macos"</span>, <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"ios"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>}; + + <span class='kw'>extern</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>_NSGetExecutablePath</span>(<span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, <span class='ident'>bufsize</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>u32</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"freebsd"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"dragonfly"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"bitrig"</span>, + <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"openbsd"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"linux"</span>, <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"android"</span>, <span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + } + + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"windows"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>extra</span> { + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>kernel32</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_uint</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>extra</span>::{<span class='ident'>BOOL</span>, <span class='ident'>DWORD</span>, <span class='ident'>SIZE_T</span>, <span class='ident'>HMODULE</span>, + <span class='ident'>LPCWSTR</span>, <span class='ident'>LPWSTR</span>, + <span class='ident'>LPWCH</span>, <span class='ident'>LPDWORD</span>, <span class='ident'>LPVOID</span>, + <span class='ident'>LPCVOID</span>, <span class='ident'>LPOVERLAPPED</span>, + <span class='ident'>LPSECURITY_ATTRIBUTES</span>, + <span class='ident'>LPSTARTUPINFO</span>, + <span class='ident'>LPPROCESS_INFORMATION</span>, + <span class='ident'>LPMEMORY_BASIC_INFORMATION</span>, + <span class='ident'>LPSYSTEM_INFO</span>, <span class='ident'>HANDLE</span>, <span class='ident'>LPHANDLE</span>, + <span class='ident'>LARGE_INTEGER</span>, <span class='ident'>PLARGE_INTEGER</span>, + <span class='ident'>LPFILETIME</span>, <span class='ident'>LPWIN32_FIND_DATAW</span>}; + + <span class='kw'>extern</span> <span class='string'>"system"</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>GetEnvironmentVariableW</span>(<span class='ident'>n</span>: <span class='ident'>LPCWSTR</span>, + <span class='ident'>v</span>: <span class='ident'>LPWSTR</span>, + <span class='ident'>nsize</span>: <span class='ident'>DWORD</span>) + <span class='op'>-></span> <span class='ident'>DWORD</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SetEnvironmentVariableW</span>(<span class='ident'>n</span>: <span class='ident'>LPCWSTR</span>, <span class='ident'>v</span>: <span class='ident'>LPCWSTR</span>) + <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>GetEnvironmentStringsW</span>() <span class='op'>-></span> <span class='ident'>LPWCH</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>FreeEnvironmentStringsW</span>(<span class='ident'>env_ptr</span>: <span class='ident'>LPWCH</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>GetModuleFileNameW</span>(<span class='ident'>hModule</span>: <span class='ident'>HMODULE</span>, + <span class='ident'>lpFilename</span>: <span class='ident'>LPWSTR</span>, + <span class='ident'>nSize</span>: <span class='ident'>DWORD</span>) + <span class='op'>-></span> <span class='ident'>DWORD</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>CreateDirectoryW</span>(<span class='ident'>lpPathName</span>: <span class='ident'>LPCWSTR</span>, + <span class='ident'>lpSecurityAttributes</span>: + <span class='ident'>LPSECURITY_ATTRIBUTES</span>) + <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>CopyFileW</span>(<span class='ident'>lpExistingFileName</span>: <span class='ident'>LPCWSTR</span>, + <span class='ident'>lpNewFileName</span>: <span class='ident'>LPCWSTR</span>, + <span class='ident'>bFailIfExists</span>: <span class='ident'>BOOL</span>) + <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>DeleteFileW</span>(<span class='ident'>lpPathName</span>: <span class='ident'>LPCWSTR</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>RemoveDirectoryW</span>(<span class='ident'>lpPathName</span>: <span class='ident'>LPCWSTR</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>GetCurrentDirectoryW</span>(<span class='ident'>nBufferLength</span>: <span class='ident'>DWORD</span>, + <span class='ident'>lpBuffer</span>: <span class='ident'>LPWSTR</span>) + <span class='op'>-></span> <span class='ident'>DWORD</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SetCurrentDirectoryW</span>(<span class='ident'>lpPathName</span>: <span class='ident'>LPCWSTR</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>GetLastError</span>() <span class='op'>-></span> <span class='ident'>DWORD</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>FindFirstFileW</span>(<span class='ident'>fileName</span>: <span class='ident'>LPCWSTR</span>, <span class='ident'>findFileData</span>: <span class='ident'>LPWIN32_FIND_DATAW</span>) + <span class='op'>-></span> <span class='ident'>HANDLE</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>FindNextFileW</span>(<span class='ident'>findFile</span>: <span class='ident'>HANDLE</span>, <span class='ident'>findFileData</span>: <span class='ident'>LPWIN32_FIND_DATAW</span>) + <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>FindClose</span>(<span class='ident'>findFile</span>: <span class='ident'>HANDLE</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>DuplicateHandle</span>(<span class='ident'>hSourceProcessHandle</span>: <span class='ident'>HANDLE</span>, + <span class='ident'>hSourceHandle</span>: <span class='ident'>HANDLE</span>, + <span class='ident'>hTargetProcessHandle</span>: <span class='ident'>HANDLE</span>, + <span class='ident'>lpTargetHandle</span>: <span class='ident'>LPHANDLE</span>, + <span class='ident'>dwDesiredAccess</span>: <span class='ident'>DWORD</span>, + <span class='ident'>bInheritHandle</span>: <span class='ident'>BOOL</span>, + <span class='ident'>dwOptions</span>: <span class='ident'>DWORD</span>) + <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>CloseHandle</span>(<span class='ident'>hObject</span>: <span class='ident'>HANDLE</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>OpenProcess</span>(<span class='ident'>dwDesiredAccess</span>: <span class='ident'>DWORD</span>, + <span class='ident'>bInheritHandle</span>: <span class='ident'>BOOL</span>, + <span class='ident'>dwProcessId</span>: <span class='ident'>DWORD</span>) + <span class='op'>-></span> <span class='ident'>HANDLE</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>GetCurrentProcess</span>() <span class='op'>-></span> <span class='ident'>HANDLE</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>CreateProcessW</span>(<span class='ident'>lpApplicationName</span>: <span class='ident'>LPCWSTR</span>, + <span class='ident'>lpCommandLine</span>: <span class='ident'>LPWSTR</span>, + <span class='ident'>lpProcessAttributes</span>: + <span class='ident'>LPSECURITY_ATTRIBUTES</span>, + <span class='ident'>lpThreadAttributes</span>: + <span class='ident'>LPSECURITY_ATTRIBUTES</span>, + <span class='ident'>bInheritHandles</span>: <span class='ident'>BOOL</span>, + <span class='ident'>dwCreationFlags</span>: <span class='ident'>DWORD</span>, + <span class='ident'>lpEnvironment</span>: <span class='ident'>LPVOID</span>, + <span class='ident'>lpCurrentDirectory</span>: <span class='ident'>LPCWSTR</span>, + <span class='ident'>lpStartupInfo</span>: <span class='ident'>LPSTARTUPINFO</span>, + <span class='ident'>lpProcessInformation</span>: + <span class='ident'>LPPROCESS_INFORMATION</span>) + <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>WaitForSingleObject</span>(<span class='ident'>hHandle</span>: <span class='ident'>HANDLE</span>, + <span class='ident'>dwMilliseconds</span>: <span class='ident'>DWORD</span>) + <span class='op'>-></span> <span class='ident'>DWORD</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>TerminateProcess</span>(<span class='ident'>hProcess</span>: <span class='ident'>HANDLE</span>, <span class='ident'>uExitCode</span>: <span class='ident'>c_uint</span>) + <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>GetExitCodeProcess</span>(<span class='ident'>hProcess</span>: <span class='ident'>HANDLE</span>, + <span class='ident'>lpExitCode</span>: <span class='ident'>LPDWORD</span>) + <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>GetSystemInfo</span>(<span class='ident'>lpSystemInfo</span>: <span class='ident'>LPSYSTEM_INFO</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>VirtualAlloc</span>(<span class='ident'>lpAddress</span>: <span class='ident'>LPVOID</span>, + <span class='ident'>dwSize</span>: <span class='ident'>SIZE_T</span>, + <span class='ident'>flAllocationType</span>: <span class='ident'>DWORD</span>, + <span class='ident'>flProtect</span>: <span class='ident'>DWORD</span>) + <span class='op'>-></span> <span class='ident'>LPVOID</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>VirtualFree</span>(<span class='ident'>lpAddress</span>: <span class='ident'>LPVOID</span>, + <span class='ident'>dwSize</span>: <span class='ident'>SIZE_T</span>, + <span class='ident'>dwFreeType</span>: <span class='ident'>DWORD</span>) + <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>VirtualLock</span>(<span class='ident'>lpAddress</span>: <span class='ident'>LPVOID</span>, <span class='ident'>dwSize</span>: <span class='ident'>SIZE_T</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>VirtualUnlock</span>(<span class='ident'>lpAddress</span>: <span class='ident'>LPVOID</span>, <span class='ident'>dwSize</span>: <span class='ident'>SIZE_T</span>) + <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>VirtualProtect</span>(<span class='ident'>lpAddress</span>: <span class='ident'>LPVOID</span>, + <span class='ident'>dwSize</span>: <span class='ident'>SIZE_T</span>, + <span class='ident'>flNewProtect</span>: <span class='ident'>DWORD</span>, + <span class='ident'>lpflOldProtect</span>: <span class='ident'>LPDWORD</span>) + <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>VirtualQuery</span>(<span class='ident'>lpAddress</span>: <span class='ident'>LPCVOID</span>, + <span class='ident'>lpBuffer</span>: <span class='ident'>LPMEMORY_BASIC_INFORMATION</span>, + <span class='ident'>dwLength</span>: <span class='ident'>SIZE_T</span>) + <span class='op'>-></span> <span class='ident'>SIZE_T</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>CreateFileMappingW</span>(<span class='ident'>hFile</span>: <span class='ident'>HANDLE</span>, + <span class='ident'>lpAttributes</span>: <span class='ident'>LPSECURITY_ATTRIBUTES</span>, + <span class='ident'>flProtect</span>: <span class='ident'>DWORD</span>, + <span class='ident'>dwMaximumSizeHigh</span>: <span class='ident'>DWORD</span>, + <span class='ident'>dwMaximumSizeLow</span>: <span class='ident'>DWORD</span>, + <span class='ident'>lpName</span>: <span class='ident'>LPCWSTR</span>) + <span class='op'>-></span> <span class='ident'>HANDLE</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>MapViewOfFile</span>(<span class='ident'>hFileMappingObject</span>: <span class='ident'>HANDLE</span>, + <span class='ident'>dwDesiredAccess</span>: <span class='ident'>DWORD</span>, + <span class='ident'>dwFileOffsetHigh</span>: <span class='ident'>DWORD</span>, + <span class='ident'>dwFileOffsetLow</span>: <span class='ident'>DWORD</span>, + <span class='ident'>dwNumberOfBytesToMap</span>: <span class='ident'>SIZE_T</span>) + <span class='op'>-></span> <span class='ident'>LPVOID</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>UnmapViewOfFile</span>(<span class='ident'>lpBaseAddress</span>: <span class='ident'>LPCVOID</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>MoveFileExW</span>(<span class='ident'>lpExistingFileName</span>: <span class='ident'>LPCWSTR</span>, + <span class='ident'>lpNewFileName</span>: <span class='ident'>LPCWSTR</span>, + <span class='ident'>dwFlags</span>: <span class='ident'>DWORD</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>CreateHardLinkW</span>(<span class='ident'>lpSymlinkFileName</span>: <span class='ident'>LPCWSTR</span>, + <span class='ident'>lpTargetFileName</span>: <span class='ident'>LPCWSTR</span>, + <span class='ident'>lpSecurityAttributes</span>: <span class='ident'>LPSECURITY_ATTRIBUTES</span>) + <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>FlushFileBuffers</span>(<span class='ident'>hFile</span>: <span class='ident'>HANDLE</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>CreateFileW</span>(<span class='ident'>lpFileName</span>: <span class='ident'>LPCWSTR</span>, + <span class='ident'>dwDesiredAccess</span>: <span class='ident'>DWORD</span>, + <span class='ident'>dwShareMode</span>: <span class='ident'>DWORD</span>, + <span class='ident'>lpSecurityAttributes</span>: <span class='ident'>LPSECURITY_ATTRIBUTES</span>, + <span class='ident'>dwCreationDisposition</span>: <span class='ident'>DWORD</span>, + <span class='ident'>dwFlagsAndAttributes</span>: <span class='ident'>DWORD</span>, + <span class='ident'>hTemplateFile</span>: <span class='ident'>HANDLE</span>) <span class='op'>-></span> <span class='ident'>HANDLE</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ReadFile</span>(<span class='ident'>hFile</span>: <span class='ident'>HANDLE</span>, + <span class='ident'>lpBuffer</span>: <span class='ident'>LPVOID</span>, + <span class='ident'>nNumberOfBytesToRead</span>: <span class='ident'>DWORD</span>, + <span class='ident'>lpNumberOfBytesRead</span>: <span class='ident'>LPDWORD</span>, + <span class='ident'>lpOverlapped</span>: <span class='ident'>LPOVERLAPPED</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>WriteFile</span>(<span class='ident'>hFile</span>: <span class='ident'>HANDLE</span>, + <span class='ident'>lpBuffer</span>: <span class='ident'>LPVOID</span>, + <span class='ident'>nNumberOfBytesToRead</span>: <span class='ident'>DWORD</span>, + <span class='ident'>lpNumberOfBytesRead</span>: <span class='ident'>LPDWORD</span>, + <span class='ident'>lpOverlapped</span>: <span class='ident'>LPOVERLAPPED</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SetFilePointerEx</span>(<span class='ident'>hFile</span>: <span class='ident'>HANDLE</span>, + <span class='ident'>liDistanceToMove</span>: <span class='ident'>LARGE_INTEGER</span>, + <span class='ident'>lpNewFilePointer</span>: <span class='ident'>PLARGE_INTEGER</span>, + <span class='ident'>dwMoveMethod</span>: <span class='ident'>DWORD</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SetEndOfFile</span>(<span class='ident'>hFile</span>: <span class='ident'>HANDLE</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>GetSystemTimeAsFileTime</span>( + <span class='ident'>lpSystemTimeAsFileTime</span>: <span class='ident'>LPFILETIME</span>); + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>QueryPerformanceFrequency</span>( + <span class='ident'>lpFrequency</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>LARGE_INTEGER</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>QueryPerformanceCounter</span>( + <span class='ident'>lpPerformanceCount</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>LARGE_INTEGER</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>GetCurrentProcessId</span>() <span class='op'>-></span> <span class='ident'>DWORD</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>CreateNamedPipeW</span>( + <span class='ident'>lpName</span>: <span class='ident'>LPCWSTR</span>, + <span class='ident'>dwOpenMode</span>: <span class='ident'>DWORD</span>, + <span class='ident'>dwPipeMode</span>: <span class='ident'>DWORD</span>, + <span class='ident'>nMaxInstances</span>: <span class='ident'>DWORD</span>, + <span class='ident'>nOutBufferSize</span>: <span class='ident'>DWORD</span>, + <span class='ident'>nInBufferSize</span>: <span class='ident'>DWORD</span>, + <span class='ident'>nDefaultTimeOut</span>: <span class='ident'>DWORD</span>, + <span class='ident'>lpSecurityAttributes</span>: <span class='ident'>LPSECURITY_ATTRIBUTES</span> + ) <span class='op'>-></span> <span class='ident'>HANDLE</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ConnectNamedPipe</span>(<span class='ident'>hNamedPipe</span>: <span class='ident'>HANDLE</span>, + <span class='ident'>lpOverlapped</span>: <span class='ident'>LPOVERLAPPED</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>WaitNamedPipeW</span>(<span class='ident'>lpNamedPipeName</span>: <span class='ident'>LPCWSTR</span>, + <span class='ident'>nTimeOut</span>: <span class='ident'>DWORD</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SetNamedPipeHandleState</span>(<span class='ident'>hNamedPipe</span>: <span class='ident'>HANDLE</span>, + <span class='ident'>lpMode</span>: <span class='ident'>LPDWORD</span>, + <span class='ident'>lpMaxCollectionCount</span>: <span class='ident'>LPDWORD</span>, + <span class='ident'>lpCollectDataTimeout</span>: <span class='ident'>LPDWORD</span>) + <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>CreateEventW</span>(<span class='ident'>lpEventAttributes</span>: <span class='ident'>LPSECURITY_ATTRIBUTES</span>, + <span class='ident'>bManualReset</span>: <span class='ident'>BOOL</span>, + <span class='ident'>bInitialState</span>: <span class='ident'>BOOL</span>, + <span class='ident'>lpName</span>: <span class='ident'>LPCWSTR</span>) <span class='op'>-></span> <span class='ident'>HANDLE</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>GetOverlappedResult</span>(<span class='ident'>hFile</span>: <span class='ident'>HANDLE</span>, + <span class='ident'>lpOverlapped</span>: <span class='ident'>LPOVERLAPPED</span>, + <span class='ident'>lpNumberOfBytesTransferred</span>: <span class='ident'>LPDWORD</span>, + <span class='ident'>bWait</span>: <span class='ident'>BOOL</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>DisconnectNamedPipe</span>(<span class='ident'>hNamedPipe</span>: <span class='ident'>HANDLE</span>) <span class='op'>-></span> <span class='ident'>BOOL</span>; + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>msvcrt</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_long</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c99</span>::<span class='ident'>intptr_t</span>; + + <span class='kw'>extern</span> { + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_commit"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>commit</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_get_osfhandle"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_osfhandle</span>(<span class='ident'>fd</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_long</span>; + + <span class='attribute'>#[<span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"_open_osfhandle"</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>open_osfhandle</span>(<span class='ident'>osfhandle</span>: <span class='ident'>intptr_t</span>, + <span class='ident'>flags</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + + <span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>winsock</span> { + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_long</span>, <span class='ident'>c_ulong</span>}; + <span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>common</span>::<span class='ident'>bsd44</span>::<span class='ident'>SOCKET</span>; + + <span class='kw'>extern</span> <span class='string'>"system"</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ioctlsocket</span>(<span class='ident'>s</span>: <span class='ident'>SOCKET</span>, <span class='ident'>cmd</span>: <span class='ident'>c_long</span>, <span class='ident'>argp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + } + } + } +} + +<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>issue_14344_workaround</span>() {} <span class='comment'>// FIXME #14344 force linkage to happen correctly</span> + +<span class='attribute'>#[<span class='ident'>test</span>]</span> <span class='kw'>fn</span> <span class='ident'>work_on_windows</span>() { } <span class='comment'>// FIXME #10872 needed for a happy windows</span> +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "libc"; + window.playgroundUrl = "http://play.rust-lang.org/"; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + <script src="../../playpen.js"></script> + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/log/lib.rs.html b/src/log/lib.rs.html new file mode 100644 index 0000000..78cbf86 --- /dev/null +++ b/src/log/lib.rs.html @@ -0,0 +1,1643 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/log-0.3.1/src/lib.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>lib.rs.html -- source</title> + + <link rel="stylesheet" type="text/css" href="../../main.css"> + + <link rel="shortcut icon" href="http://www.rust-lang.org/favicon.ico"> + +</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"> + <a href='../../log/index.html'><img src='http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png' alt='' width='100'></a> + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +<span id="313">313</span> +<span id="314">314</span> +<span id="315">315</span> +<span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +<span id="326">326</span> +<span id="327">327</span> +<span id="328">328</span> +<span id="329">329</span> +<span id="330">330</span> +<span id="331">331</span> +<span id="332">332</span> +<span id="333">333</span> +<span id="334">334</span> +<span id="335">335</span> +<span id="336">336</span> +<span id="337">337</span> +<span id="338">338</span> +<span id="339">339</span> +<span id="340">340</span> +<span id="341">341</span> +<span id="342">342</span> +<span id="343">343</span> +<span id="344">344</span> +<span id="345">345</span> +<span id="346">346</span> +<span id="347">347</span> +<span id="348">348</span> +<span id="349">349</span> +<span id="350">350</span> +<span id="351">351</span> +<span id="352">352</span> +<span id="353">353</span> +<span id="354">354</span> +<span id="355">355</span> +<span id="356">356</span> +<span id="357">357</span> +<span id="358">358</span> +<span id="359">359</span> +<span id="360">360</span> +<span id="361">361</span> +<span id="362">362</span> +<span id="363">363</span> +<span id="364">364</span> +<span id="365">365</span> +<span id="366">366</span> +<span id="367">367</span> +<span id="368">368</span> +<span id="369">369</span> +<span id="370">370</span> +<span id="371">371</span> +<span id="372">372</span> +<span id="373">373</span> +<span id="374">374</span> +<span id="375">375</span> +<span id="376">376</span> +<span id="377">377</span> +<span id="378">378</span> +<span id="379">379</span> +<span id="380">380</span> +<span id="381">381</span> +<span id="382">382</span> +<span id="383">383</span> +<span id="384">384</span> +<span id="385">385</span> +<span id="386">386</span> +<span id="387">387</span> +<span id="388">388</span> +<span id="389">389</span> +<span id="390">390</span> +<span id="391">391</span> +<span id="392">392</span> +<span id="393">393</span> +<span id="394">394</span> +<span id="395">395</span> +<span id="396">396</span> +<span id="397">397</span> +<span id="398">398</span> +<span id="399">399</span> +<span id="400">400</span> +<span id="401">401</span> +<span id="402">402</span> +<span id="403">403</span> +<span id="404">404</span> +<span id="405">405</span> +<span id="406">406</span> +<span id="407">407</span> +<span id="408">408</span> +<span id="409">409</span> +<span id="410">410</span> +<span id="411">411</span> +<span id="412">412</span> +<span id="413">413</span> +<span id="414">414</span> +<span id="415">415</span> +<span id="416">416</span> +<span id="417">417</span> +<span id="418">418</span> +<span id="419">419</span> +<span id="420">420</span> +<span id="421">421</span> +<span id="422">422</span> +<span id="423">423</span> +<span id="424">424</span> +<span id="425">425</span> +<span id="426">426</span> +<span id="427">427</span> +<span id="428">428</span> +<span id="429">429</span> +<span id="430">430</span> +<span id="431">431</span> +<span id="432">432</span> +<span id="433">433</span> +<span id="434">434</span> +<span id="435">435</span> +<span id="436">436</span> +<span id="437">437</span> +<span id="438">438</span> +<span id="439">439</span> +<span id="440">440</span> +<span id="441">441</span> +<span id="442">442</span> +<span id="443">443</span> +<span id="444">444</span> +<span id="445">445</span> +<span id="446">446</span> +<span id="447">447</span> +<span id="448">448</span> +<span id="449">449</span> +<span id="450">450</span> +<span id="451">451</span> +<span id="452">452</span> +<span id="453">453</span> +<span id="454">454</span> +<span id="455">455</span> +<span id="456">456</span> +<span id="457">457</span> +<span id="458">458</span> +<span id="459">459</span> +<span id="460">460</span> +<span id="461">461</span> +<span id="462">462</span> +<span id="463">463</span> +<span id="464">464</span> +<span id="465">465</span> +<span id="466">466</span> +<span id="467">467</span> +<span id="468">468</span> +<span id="469">469</span> +<span id="470">470</span> +<span id="471">471</span> +<span id="472">472</span> +<span id="473">473</span> +<span id="474">474</span> +<span id="475">475</span> +<span id="476">476</span> +<span id="477">477</span> +<span id="478">478</span> +<span id="479">479</span> +<span id="480">480</span> +<span id="481">481</span> +<span id="482">482</span> +<span id="483">483</span> +<span id="484">484</span> +<span id="485">485</span> +<span id="486">486</span> +<span id="487">487</span> +<span id="488">488</span> +<span id="489">489</span> +<span id="490">490</span> +<span id="491">491</span> +<span id="492">492</span> +<span id="493">493</span> +<span id="494">494</span> +<span id="495">495</span> +<span id="496">496</span> +<span id="497">497</span> +<span id="498">498</span> +<span id="499">499</span> +<span id="500">500</span> +<span id="501">501</span> +<span id="502">502</span> +<span id="503">503</span> +<span id="504">504</span> +<span id="505">505</span> +<span id="506">506</span> +<span id="507">507</span> +<span id="508">508</span> +<span id="509">509</span> +<span id="510">510</span> +<span id="511">511</span> +<span id="512">512</span> +<span id="513">513</span> +<span id="514">514</span> +<span id="515">515</span> +<span id="516">516</span> +<span id="517">517</span> +<span id="518">518</span> +<span id="519">519</span> +<span id="520">520</span> +<span id="521">521</span> +<span id="522">522</span> +<span id="523">523</span> +<span id="524">524</span> +<span id="525">525</span> +<span id="526">526</span> +<span id="527">527</span> +<span id="528">528</span> +<span id="529">529</span> +<span id="530">530</span> +<span id="531">531</span> +<span id="532">532</span> +<span id="533">533</span> +<span id="534">534</span> +<span id="535">535</span> +<span id="536">536</span> +<span id="537">537</span> +<span id="538">538</span> +<span id="539">539</span> +<span id="540">540</span> +<span id="541">541</span> +<span id="542">542</span> +<span id="543">543</span> +<span id="544">544</span> +<span id="545">545</span> +<span id="546">546</span> +<span id="547">547</span> +<span id="548">548</span> +<span id="549">549</span> +<span id="550">550</span> +<span id="551">551</span> +<span id="552">552</span> +<span id="553">553</span> +<span id="554">554</span> +<span id="555">555</span> +<span id="556">556</span> +<span id="557">557</span> +<span id="558">558</span> +<span id="559">559</span> +<span id="560">560</span> +<span id="561">561</span> +<span id="562">562</span> +<span id="563">563</span> +<span id="564">564</span> +<span id="565">565</span> +<span id="566">566</span> +<span id="567">567</span> +<span id="568">568</span> +<span id="569">569</span> +<span id="570">570</span> +<span id="571">571</span> +<span id="572">572</span> +<span id="573">573</span> +<span id="574">574</span> +<span id="575">575</span> +<span id="576">576</span> +<span id="577">577</span> +<span id="578">578</span> +<span id="579">579</span> +<span id="580">580</span> +<span id="581">581</span> +<span id="582">582</span> +<span id="583">583</span> +<span id="584">584</span> +<span id="585">585</span> +<span id="586">586</span> +<span id="587">587</span> +<span id="588">588</span> +<span id="589">589</span> +<span id="590">590</span> +<span id="591">591</span> +<span id="592">592</span> +<span id="593">593</span> +<span id="594">594</span> +<span id="595">595</span> +<span id="596">596</span> +<span id="597">597</span> +<span id="598">598</span> +<span id="599">599</span> +<span id="600">600</span> +<span id="601">601</span> +<span id="602">602</span> +<span id="603">603</span> +<span id="604">604</span> +<span id="605">605</span> +<span id="606">606</span> +<span id="607">607</span> +<span id="608">608</span> +<span id="609">609</span> +<span id="610">610</span> +<span id="611">611</span> +<span id="612">612</span> +<span id="613">613</span> +<span id="614">614</span> +<span id="615">615</span> +<span id="616">616</span> +<span id="617">617</span> +<span id="618">618</span> +<span id="619">619</span> +<span id="620">620</span> +<span id="621">621</span> +<span id="622">622</span> +<span id="623">623</span> +<span id="624">624</span> +<span id="625">625</span> +<span id="626">626</span> +<span id="627">627</span> +<span id="628">628</span> +<span id="629">629</span> +<span id="630">630</span> +<span id="631">631</span> +<span id="632">632</span> +<span id="633">633</span> +<span id="634">634</span> +<span id="635">635</span> +<span id="636">636</span> +<span id="637">637</span> +<span id="638">638</span> +<span id="639">639</span> +<span id="640">640</span> +<span id="641">641</span> +<span id="642">642</span> +<span id="643">643</span> +<span id="644">644</span> +<span id="645">645</span> +<span id="646">646</span> +<span id="647">647</span> +<span id="648">648</span> +<span id="649">649</span> +<span id="650">650</span> +<span id="651">651</span> +<span id="652">652</span> +<span id="653">653</span> +<span id="654">654</span> +<span id="655">655</span> +<span id="656">656</span> +<span id="657">657</span> +<span id="658">658</span> +<span id="659">659</span> +<span id="660">660</span> +<span id="661">661</span> +<span id="662">662</span> +<span id="663">663</span> +<span id="664">664</span> +<span id="665">665</span> +<span id="666">666</span> +<span id="667">667</span> +<span id="668">668</span> +<span id="669">669</span> +<span id="670">670</span> +<span id="671">671</span> +<span id="672">672</span> +<span id="673">673</span> +<span id="674">674</span> +<span id="675">675</span> +<span id="676">676</span> +<span id="677">677</span> +<span id="678">678</span> +<span id="679">679</span> +<span id="680">680</span> +<span id="681">681</span> +<span id="682">682</span> +<span id="683">683</span> +<span id="684">684</span> +<span id="685">685</span> +<span id="686">686</span> +<span id="687">687</span> +<span id="688">688</span> +<span id="689">689</span> +<span id="690">690</span> +<span id="691">691</span> +<span id="692">692</span> +<span id="693">693</span> +<span id="694">694</span> +<span id="695">695</span> +<span id="696">696</span> +<span id="697">697</span> +<span id="698">698</span> +<span id="699">699</span> +<span id="700">700</span> +<span id="701">701</span> +<span id="702">702</span> +<span id="703">703</span> +<span id="704">704</span> +<span id="705">705</span> +<span id="706">706</span> +<span id="707">707</span> +<span id="708">708</span> +<span id="709">709</span> +<span id="710">710</span> +<span id="711">711</span> +<span id="712">712</span> +<span id="713">713</span> +<span id="714">714</span> +<span id="715">715</span> +<span id="716">716</span> +<span id="717">717</span> +<span id="718">718</span> +<span id="719">719</span> +<span id="720">720</span> +<span id="721">721</span> +<span id="722">722</span> +<span id="723">723</span> +<span id="724">724</span> +<span id="725">725</span> +<span id="726">726</span> +<span id="727">727</span> +<span id="728">728</span> +<span id="729">729</span> +<span id="730">730</span> +<span id="731">731</span> +<span id="732">732</span> +<span id="733">733</span> +<span id="734">734</span> +<span id="735">735</span> +<span id="736">736</span> +<span id="737">737</span> +<span id="738">738</span> +<span id="739">739</span> +<span id="740">740</span> +<span id="741">741</span> +<span id="742">742</span> +<span id="743">743</span> +<span id="744">744</span> +<span id="745">745</span> +<span id="746">746</span> +<span id="747">747</span> +<span id="748">748</span> +<span id="749">749</span> +<span id="750">750</span> +<span id="751">751</span> +<span id="752">752</span> +<span id="753">753</span> +<span id="754">754</span> +<span id="755">755</span> +<span id="756">756</span> +<span id="757">757</span> +<span id="758">758</span> +<span id="759">759</span> +<span id="760">760</span> +<span id="761">761</span> +<span id="762">762</span> +<span id="763">763</span> +<span id="764">764</span> +<span id="765">765</span> +<span id="766">766</span> +<span id="767">767</span> +<span id="768">768</span> +<span id="769">769</span> +<span id="770">770</span> +<span id="771">771</span> +<span id="772">772</span> +<span id="773">773</span> +</pre><pre class='rust '> +<span class='comment'>// Copyright 2015 The Rust Project Developers. See the COPYRIGHT</span> +<span class='comment'>// file at the top-level directory of this distribution and at</span> +<span class='comment'>// http://rust-lang.org/COPYRIGHT.</span> +<span class='comment'>//</span> +<span class='comment'>// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or</span> +<span class='comment'>// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license</span> +<span class='comment'>// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your</span> +<span class='comment'>// option. This file may not be copied, modified, or distributed</span> +<span class='comment'>// except according to those terms.</span> + +<span class='doccomment'>//! A lightweight logging facade.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! A logging facade provides a single logging API that abstracts over the</span> +<span class='doccomment'>//! actual logging implementation. Libraries can use the logging API provided</span> +<span class='doccomment'>//! by this crate, and the consumer of those libraries can choose the logging</span> +<span class='doccomment'>//! framework that is most suitable for its use case.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! If no logging implementation is selected, the facade falls back to a "noop"</span> +<span class='doccomment'>//! implementation that ignores all log messages. The overhead in this case</span> +<span class='doccomment'>//! is very small - just an integer load, comparison and jump.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! A log request consists of a target, a level, and a body. A target is a</span> +<span class='doccomment'>//! string which defaults to the module path of the location of the log</span> +<span class='doccomment'>//! request, though that default may be overridden. Logger implementations</span> +<span class='doccomment'>//! typically use the target to filter requests based on some user</span> +<span class='doccomment'>//! configuration.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # Use</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ## In libraries</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Libraries should link only to the `log` crate, and use the provided</span> +<span class='doccomment'>//! macros to log whatever information will be useful to downstream consumers.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ### Examples</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```rust</span> +<span class='doccomment'>//! # #![allow(unstable)]</span> +<span class='doccomment'>//! #[macro_use]</span> +<span class='doccomment'>//! extern crate log;</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # #[derive(Debug)] pub struct Yak(String);</span> +<span class='doccomment'>//! # impl Yak { fn shave(&self, _: u32) {} }</span> +<span class='doccomment'>//! # fn find_a_razor() -> Result<u32, u32> { Ok(1) }</span> +<span class='doccomment'>//! pub fn shave_the_yak(yak: &Yak) {</span> +<span class='doccomment'>//! info!(target: "yak_events", "Commencing yak shaving for {:?}", yak);</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! loop {</span> +<span class='doccomment'>//! match find_a_razor() {</span> +<span class='doccomment'>//! Ok(razor) => {</span> +<span class='doccomment'>//! info!("Razor located: {}", razor);</span> +<span class='doccomment'>//! yak.shave(razor);</span> +<span class='doccomment'>//! break;</span> +<span class='doccomment'>//! }</span> +<span class='doccomment'>//! Err(err) => {</span> +<span class='doccomment'>//! warn!("Unable to locate a razor: {}, retrying", err);</span> +<span class='doccomment'>//! }</span> +<span class='doccomment'>//! }</span> +<span class='doccomment'>//! }</span> +<span class='doccomment'>//! }</span> +<span class='doccomment'>//! # fn main() {}</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ## In executables</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Executables should chose a logging framework and initialize it early in the</span> +<span class='doccomment'>//! runtime of the program. Logging frameworks will typically include a</span> +<span class='doccomment'>//! function to do this. Any log messages generated before the framework is</span> +<span class='doccomment'>//! initialized will be ignored.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! The executable itself may use the `log` crate to log as well.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ### Warning</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! The logging system may only be initialized once.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ### Examples</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```rust,ignore</span> +<span class='doccomment'>//! #[macro_use]</span> +<span class='doccomment'>//! extern crate log;</span> +<span class='doccomment'>//! extern crate my_logger;</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! fn main() {</span> +<span class='doccomment'>//! my_logger::init();</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! info!("starting up");</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! // ...</span> +<span class='doccomment'>//! }</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # Logger implementations</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Loggers implement the `Log` trait. Here's a very basic example that simply</span> +<span class='doccomment'>//! logs all messages at the `Error`, `Warn` or `Info` levels to stdout:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```rust</span> +<span class='doccomment'>//! extern crate log;</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! use log::{LogRecord, LogLevel, LogMetadata};</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! struct SimpleLogger;</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! impl log::Log for SimpleLogger {</span> +<span class='doccomment'>//! fn enabled(&self, metadata: &LogMetadata) -> bool {</span> +<span class='doccomment'>//! metadata.level() <= LogLevel::Info</span> +<span class='doccomment'>//! }</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! fn log(&self, record: &LogRecord) {</span> +<span class='doccomment'>//! if self.enabled(record.metadata()) {</span> +<span class='doccomment'>//! println!("{} - {}", record.level(), record.args());</span> +<span class='doccomment'>//! }</span> +<span class='doccomment'>//! }</span> +<span class='doccomment'>//! }</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # fn main() {}</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Loggers are installed by calling the `set_logger` function. It takes a</span> +<span class='doccomment'>//! closure which is provided a `MaxLogLevel` token and returns a `Log` trait</span> +<span class='doccomment'>//! object. The `MaxLogLevel` token controls the global maximum log level. The</span> +<span class='doccomment'>//! logging facade uses this as an optimization to improve performance of log</span> +<span class='doccomment'>//! messages at levels that are disabled. In the case of our example logger,</span> +<span class='doccomment'>//! we'll want to set the maximum log level to `Info`, since we ignore any</span> +<span class='doccomment'>//! `Debug` or `Trace` level log messages. A logging framework should provide a</span> +<span class='doccomment'>//! function that wraps a call to `set_logger`, handling initialization of the</span> +<span class='doccomment'>//! logger:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```rust</span> +<span class='doccomment'>//! # extern crate log;</span> +<span class='doccomment'>//! # use log::{LogLevel, LogLevelFilter, SetLoggerError, LogMetadata};</span> +<span class='doccomment'>//! # struct SimpleLogger;</span> +<span class='doccomment'>//! # impl log::Log for SimpleLogger {</span> +<span class='doccomment'>//! # fn enabled(&self, _: &LogMetadata) -> bool { false }</span> +<span class='doccomment'>//! # fn log(&self, _: &log::LogRecord) {}</span> +<span class='doccomment'>//! # }</span> +<span class='doccomment'>//! # fn main() {}</span> +<span class='doccomment'>//! pub fn init() -> Result<(), SetLoggerError> {</span> +<span class='doccomment'>//! log::set_logger(|max_log_level| {</span> +<span class='doccomment'>//! max_log_level.set(LogLevelFilter::Info);</span> +<span class='doccomment'>//! Box::new(SimpleLogger)</span> +<span class='doccomment'>//! })</span> +<span class='doccomment'>//! }</span> +<span class='doccomment'>//! ```</span> + +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>doc</span>(<span class='ident'>html_logo_url</span> <span class='op'>=</span> <span class='string'>"http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png"</span>, + <span class='ident'>html_favicon_url</span> <span class='op'>=</span> <span class='string'>"http://www.rust-lang.org/favicon.ico"</span>, + <span class='ident'>html_root_url</span> <span class='op'>=</span> <span class='string'>"http://doc.rust-lang.org/log/"</span>)]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>warn</span>(<span class='ident'>missing_docs</span>)]</span> + +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>libc</span>; + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ascii</span>::<span class='ident'>AsciiExt</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>cmp</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>error</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>fmt</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>mem</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ops</span>::<span class='ident'>Deref</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>sync</span>::<span class='ident'>atomic</span>::{<span class='ident'>AtomicUsize</span>, <span class='ident'>ATOMIC_USIZE_INIT</span>, <span class='ident'>Ordering</span>}; +<span class='kw'>mod</span> <span class='ident'>macros</span>; + +<span class='comment'>// The setup here is a bit weird to make at_exit work.</span> +<span class='comment'>//</span> +<span class='comment'>// There are four different states that we care about: the logger's</span> +<span class='comment'>// uninitialized, the logger's initializing (set_logger's been called but</span> +<span class='comment'>// LOGGER hasn't actually been set yet), the logger's active, or the logger's</span> +<span class='comment'>// shutting down inside of at_exit.</span> +<span class='comment'>//</span> +<span class='comment'>// The LOGGER static is normally a Box<Box<Log>> with some special possible</span> +<span class='comment'>// values as well. The uninitialized and initializing states are represented by</span> +<span class='comment'>// the values 0 and 1 respectively. The shutting down state is also represented</span> +<span class='comment'>// by 1. Any other value is a valid pointer to the logger.</span> +<span class='comment'>//</span> +<span class='comment'>// The at_exit routine needs to make sure that no threads are actively logging</span> +<span class='comment'>// when it deallocates the logger. The number of actively logging threads is</span> +<span class='comment'>// tracked in the REFCOUNT static. The routine first sets LOGGER back to 1.</span> +<span class='comment'>// All logging calls past that point will immediately return without accessing</span> +<span class='comment'>// the logger. At that point, the at_exit routine just waits for the refcount</span> +<span class='comment'>// to reach 0 before deallocating the logger. Note that the refcount does not</span> +<span class='comment'>// necessarily monotonically decrease at this point, as new log calls still</span> +<span class='comment'>// increment and decrement it, but the interval in between is small enough that</span> +<span class='comment'>// the wait is really just for the active log calls to finish.</span> +<span class='kw'>static</span> <span class='ident'>LOGGER</span>: <span class='ident'>AtomicUsize</span> <span class='op'>=</span> <span class='ident'>ATOMIC_USIZE_INIT</span>; +<span class='kw'>static</span> <span class='ident'>REFCOUNT</span>: <span class='ident'>AtomicUsize</span> <span class='op'>=</span> <span class='ident'>ATOMIC_USIZE_INIT</span>; + +<span class='kw'>const</span> <span class='ident'>UNINITIALIZED</span>: <span class='ident'>usize</span> <span class='op'>=</span> <span class='number'>0</span>; +<span class='kw'>const</span> <span class='ident'>INITIALIZING</span>: <span class='ident'>usize</span> <span class='op'>=</span> <span class='number'>1</span>; + +<span class='kw'>static</span> <span class='ident'>MAX_LOG_LEVEL_FILTER</span>: <span class='ident'>AtomicUsize</span> <span class='op'>=</span> <span class='ident'>ATOMIC_USIZE_INIT</span>; + +<span class='kw'>static</span> <span class='ident'>LOG_LEVEL_NAMES</span>: [<span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>; <span class='number'>6</span>] <span class='op'>=</span> [<span class='string'>"OFF"</span>, <span class='string'>"ERROR"</span>, <span class='string'>"WARN"</span>, <span class='string'>"INFO"</span>, + <span class='string'>"DEBUG"</span>, <span class='string'>"TRACE"</span>]; + +<span class='doccomment'>/// An enum representing the available verbosity levels of the logging framework</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// A `LogLevel` may be compared directly to a `LogLevelFilter`.</span> +<span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>usize</span>)]</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Eq</span>, <span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>LogLevel</span> { + <span class='doccomment'>/// The "error" level.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Designates very serious errors.</span> + <span class='ident'>Error</span> <span class='op'>=</span> <span class='number'>1</span>, <span class='comment'>// This way these line up with the discriminants for LogLevelFilter below</span> + <span class='doccomment'>/// The "warn" level.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Designates hazardous situations.</span> + <span class='ident'>Warn</span>, + <span class='doccomment'>/// The "info" level.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Designates useful information.</span> + <span class='ident'>Info</span>, + <span class='doccomment'>/// The "debug" level.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Designates lower priority information.</span> + <span class='ident'>Debug</span>, + <span class='doccomment'>/// The "trace" level.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Designates very low priority, often extremely verbose, information.</span> + <span class='ident'>Trace</span>, +} + +<span class='kw'>impl</span> <span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>LogLevel</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>LogLevel</span> { + <span class='op'>*</span><span class='self'>self</span> + } +} + +<span class='kw'>impl</span> <span class='ident'>PartialEq</span> <span class='kw'>for</span> <span class='ident'>LogLevel</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>eq</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>LogLevel</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='op'>*</span><span class='self'>self</span> <span class='kw'>as</span> <span class='ident'>usize</span> <span class='op'>==</span> <span class='op'>*</span><span class='ident'>other</span> <span class='kw'>as</span> <span class='ident'>usize</span> + } +} + +<span class='kw'>impl</span> <span class='ident'>PartialEq</span><span class='op'><</span><span class='ident'>LogLevelFilter</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>LogLevel</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>eq</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>LogLevelFilter</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='op'>*</span><span class='self'>self</span> <span class='kw'>as</span> <span class='ident'>usize</span> <span class='op'>==</span> <span class='op'>*</span><span class='ident'>other</span> <span class='kw'>as</span> <span class='ident'>usize</span> + } +} + +<span class='kw'>impl</span> <span class='ident'>PartialOrd</span> <span class='kw'>for</span> <span class='ident'>LogLevel</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>partial_cmp</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>LogLevel</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>cmp</span>::<span class='ident'>Ordering</span><span class='op'>></span> { + <span class='prelude-val'>Some</span>(<span class='self'>self</span>.<span class='ident'>cmp</span>(<span class='ident'>other</span>)) + } +} + +<span class='kw'>impl</span> <span class='ident'>PartialOrd</span><span class='op'><</span><span class='ident'>LogLevelFilter</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>LogLevel</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>partial_cmp</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>LogLevelFilter</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>cmp</span>::<span class='ident'>Ordering</span><span class='op'>></span> { + <span class='prelude-val'>Some</span>((<span class='op'>*</span><span class='self'>self</span> <span class='kw'>as</span> <span class='ident'>usize</span>).<span class='ident'>cmp</span>(<span class='kw-2'>&</span>(<span class='op'>*</span><span class='ident'>other</span> <span class='kw'>as</span> <span class='ident'>usize</span>))) + } +} + +<span class='kw'>impl</span> <span class='ident'>Ord</span> <span class='kw'>for</span> <span class='ident'>LogLevel</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>cmp</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>LogLevel</span>) <span class='op'>-></span> <span class='ident'>cmp</span>::<span class='ident'>Ordering</span> { + (<span class='op'>*</span><span class='self'>self</span> <span class='kw'>as</span> <span class='ident'>usize</span>).<span class='ident'>cmp</span>(<span class='kw-2'>&</span>(<span class='op'>*</span><span class='ident'>other</span> <span class='kw'>as</span> <span class='ident'>usize</span>)) + } +} + +<span class='kw'>fn</span> <span class='ident'>ok_or</span><span class='op'><</span><span class='ident'>T</span>, <span class='ident'>E</span><span class='op'>></span>(<span class='ident'>t</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span>, <span class='ident'>e</span>: <span class='ident'>E</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>T</span>, <span class='ident'>E</span><span class='op'>></span> { + <span class='kw'>match</span> <span class='ident'>t</span> { + <span class='prelude-val'>Some</span>(<span class='ident'>t</span>) <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='ident'>t</span>), + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='prelude-val'>Err</span>(<span class='ident'>e</span>), + } +} + +<span class='kw'>impl</span> <span class='ident'>FromStr</span> <span class='kw'>for</span> <span class='ident'>LogLevel</span> { + <span class='kw'>type</span> <span class='prelude-val'>Err</span> <span class='op'>=</span> (); + <span class='kw'>fn</span> <span class='ident'>from_str</span>(<span class='ident'>level</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>LogLevel</span>, ()<span class='op'>></span> { + <span class='ident'>ok_or</span>(<span class='ident'>LOG_LEVEL_NAMES</span>.<span class='ident'>iter</span>() + .<span class='ident'>position</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>name</span><span class='op'>|</span> <span class='ident'>name</span>.<span class='ident'>eq_ignore_ascii_case</span>(<span class='ident'>level</span>)) + .<span class='ident'>into_iter</span>() + .<span class='ident'>filter</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>idx</span><span class='op'>|</span> <span class='ident'>idx</span> <span class='op'>!=</span> <span class='number'>0</span>) + .<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>idx</span><span class='op'>|</span> <span class='ident'>LogLevel</span>::<span class='ident'>from_usize</span>(<span class='ident'>idx</span>).<span class='ident'>unwrap</span>()) + .<span class='ident'>next</span>(), ()) + } +} + +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Display</span> <span class='kw'>for</span> <span class='ident'>LogLevel</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>fmt</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='ident'>fmt</span>.<span class='ident'>pad</span>(<span class='ident'>LOG_LEVEL_NAMES</span>[<span class='op'>*</span><span class='self'>self</span> <span class='kw'>as</span> <span class='ident'>usize</span>]) + } +} + +<span class='kw'>impl</span> <span class='ident'>LogLevel</span> { + <span class='kw'>fn</span> <span class='ident'>from_usize</span>(<span class='ident'>u</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>LogLevel</span><span class='op'>></span> { + <span class='kw'>match</span> <span class='ident'>u</span> { + <span class='number'>1</span> <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Error</span>), + <span class='number'>2</span> <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Warn</span>), + <span class='number'>3</span> <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Info</span>), + <span class='number'>4</span> <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Debug</span>), + <span class='number'>5</span> <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Trace</span>), + _ <span class='op'>=></span> <span class='prelude-val'>None</span> + } + } + + <span class='doccomment'>/// Returns the most verbose logging level.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>max</span>() <span class='op'>-></span> <span class='ident'>LogLevel</span> { + <span class='ident'>LogLevel</span>::<span class='ident'>Trace</span> + } + + <span class='doccomment'>/// Converts the `LogLevel` to the equivalent `LogLevelFilter`.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>to_log_level_filter</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>LogLevelFilter</span> { + <span class='ident'>LogLevelFilter</span>::<span class='ident'>from_usize</span>(<span class='op'>*</span><span class='self'>self</span> <span class='kw'>as</span> <span class='ident'>usize</span>).<span class='ident'>unwrap</span>() + } +} + +<span class='doccomment'>/// An enum representing the available verbosity level filters of the logging</span> +<span class='doccomment'>/// framework.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// A `LogLevelFilter` may be compared directly to a `LogLevel`.</span> +<span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>usize</span>)]</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Eq</span>, <span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>LogLevelFilter</span> { + <span class='doccomment'>/// A level lower than all log levels.</span> + <span class='ident'>Off</span>, + <span class='doccomment'>/// Corresponds to the `Error` log level.</span> + <span class='ident'>Error</span>, + <span class='doccomment'>/// Corresponds to the `Warn` log level.</span> + <span class='ident'>Warn</span>, + <span class='doccomment'>/// Corresponds to the `Trace` log level.</span> + <span class='ident'>Info</span>, + <span class='doccomment'>/// Corresponds to the `Debug` log level.</span> + <span class='ident'>Debug</span>, + <span class='doccomment'>/// Corresponds to the `Trace` log level.</span> + <span class='ident'>Trace</span>, +} + +<span class='comment'>// Deriving generates terrible impls of these traits</span> + +<span class='kw'>impl</span> <span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>LogLevelFilter</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>LogLevelFilter</span> { + <span class='op'>*</span><span class='self'>self</span> + } +} + +<span class='kw'>impl</span> <span class='ident'>PartialEq</span> <span class='kw'>for</span> <span class='ident'>LogLevelFilter</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>eq</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>LogLevelFilter</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='op'>*</span><span class='self'>self</span> <span class='kw'>as</span> <span class='ident'>usize</span> <span class='op'>==</span> <span class='op'>*</span><span class='ident'>other</span> <span class='kw'>as</span> <span class='ident'>usize</span> + } +} + +<span class='kw'>impl</span> <span class='ident'>PartialEq</span><span class='op'><</span><span class='ident'>LogLevel</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>LogLevelFilter</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>eq</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>LogLevel</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='ident'>other</span>.<span class='ident'>eq</span>(<span class='self'>self</span>) + } +} + +<span class='kw'>impl</span> <span class='ident'>PartialOrd</span> <span class='kw'>for</span> <span class='ident'>LogLevelFilter</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>partial_cmp</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>LogLevelFilter</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>cmp</span>::<span class='ident'>Ordering</span><span class='op'>></span> { + <span class='prelude-val'>Some</span>(<span class='self'>self</span>.<span class='ident'>cmp</span>(<span class='ident'>other</span>)) + } +} + +<span class='kw'>impl</span> <span class='ident'>PartialOrd</span><span class='op'><</span><span class='ident'>LogLevel</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>LogLevelFilter</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>partial_cmp</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>LogLevel</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>cmp</span>::<span class='ident'>Ordering</span><span class='op'>></span> { + <span class='ident'>other</span>.<span class='ident'>partial_cmp</span>(<span class='self'>self</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> <span class='ident'>x</span>.<span class='ident'>reverse</span>()) + } +} + +<span class='kw'>impl</span> <span class='ident'>Ord</span> <span class='kw'>for</span> <span class='ident'>LogLevelFilter</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>cmp</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>LogLevelFilter</span>) <span class='op'>-></span> <span class='ident'>cmp</span>::<span class='ident'>Ordering</span> { + (<span class='op'>*</span><span class='self'>self</span> <span class='kw'>as</span> <span class='ident'>usize</span>).<span class='ident'>cmp</span>(<span class='kw-2'>&</span>(<span class='op'>*</span><span class='ident'>other</span> <span class='kw'>as</span> <span class='ident'>usize</span>)) + } +} + +<span class='kw'>impl</span> <span class='ident'>FromStr</span> <span class='kw'>for</span> <span class='ident'>LogLevelFilter</span> { + <span class='kw'>type</span> <span class='prelude-val'>Err</span> <span class='op'>=</span> (); + <span class='kw'>fn</span> <span class='ident'>from_str</span>(<span class='ident'>level</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>LogLevelFilter</span>, ()<span class='op'>></span> { + <span class='ident'>ok_or</span>(<span class='ident'>LOG_LEVEL_NAMES</span>.<span class='ident'>iter</span>() + .<span class='ident'>position</span>(<span class='op'>|</span><span class='kw-2'>&</span><span class='ident'>name</span><span class='op'>|</span> <span class='ident'>name</span>.<span class='ident'>eq_ignore_ascii_case</span>(<span class='ident'>level</span>)) + .<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>p</span><span class='op'>|</span> <span class='ident'>LogLevelFilter</span>::<span class='ident'>from_usize</span>(<span class='ident'>p</span>).<span class='ident'>unwrap</span>()), ()) + } +} + +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Display</span> <span class='kw'>for</span> <span class='ident'>LogLevelFilter</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>fmt</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>fmt</span>, <span class='string'>"{}"</span>, <span class='ident'>LOG_LEVEL_NAMES</span>[<span class='op'>*</span><span class='self'>self</span> <span class='kw'>as</span> <span class='ident'>usize</span>]) + } +} + +<span class='kw'>impl</span> <span class='ident'>LogLevelFilter</span> { + <span class='kw'>fn</span> <span class='ident'>from_usize</span>(<span class='ident'>u</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>LogLevelFilter</span><span class='op'>></span> { + <span class='kw'>match</span> <span class='ident'>u</span> { + <span class='number'>0</span> <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Off</span>), + <span class='number'>1</span> <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Error</span>), + <span class='number'>2</span> <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Warn</span>), + <span class='number'>3</span> <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Info</span>), + <span class='number'>4</span> <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Debug</span>), + <span class='number'>5</span> <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Trace</span>), + _ <span class='op'>=></span> <span class='prelude-val'>None</span> + } + } + <span class='doccomment'>/// Returns the most verbose logging level filter.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>max</span>() <span class='op'>-></span> <span class='ident'>LogLevelFilter</span> { + <span class='ident'>LogLevelFilter</span>::<span class='ident'>Trace</span> + } + + <span class='doccomment'>/// Converts `self` to the equivalent `LogLevel`.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Returns `None` if `self` is `LogLevelFilter::Off`.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>to_log_level</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>LogLevel</span><span class='op'>></span> { + <span class='ident'>LogLevel</span>::<span class='ident'>from_usize</span>(<span class='op'>*</span><span class='self'>self</span> <span class='kw'>as</span> <span class='ident'>usize</span>) + } +} + +<span class='doccomment'>/// The "payload" of a log message.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>LogRecord</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='ident'>metadata</span>: <span class='ident'>LogMetadata</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, + <span class='ident'>location</span>: <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>LogLocation</span>, + <span class='ident'>args</span>: <span class='ident'>fmt</span>::<span class='ident'>Arguments</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>LogRecord</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='doccomment'>/// The message body.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>args</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>fmt</span>::<span class='ident'>Arguments</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>args</span> + } + + <span class='doccomment'>/// Metadata about the log directive.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>metadata</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>LogMetadata</span> { + <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>metadata</span> + } + + <span class='doccomment'>/// The location of the log directive.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>location</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>LogLocation</span> { + <span class='self'>self</span>.<span class='ident'>location</span> + } + + <span class='doccomment'>/// The verbosity level of the message.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>level</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>LogLevel</span> { + <span class='self'>self</span>.<span class='ident'>metadata</span>.<span class='ident'>level</span>() + } + + <span class='doccomment'>/// The name of the target of the directive.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>target</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>str</span> { + <span class='self'>self</span>.<span class='ident'>metadata</span>.<span class='ident'>target</span>() + } +} + +<span class='doccomment'>/// Metadata about a log message.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>LogMetadata</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='ident'>level</span>: <span class='ident'>LogLevel</span>, + <span class='ident'>target</span>: <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>str</span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>LogMetadata</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='doccomment'>/// The verbosity level of the message.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>level</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>LogLevel</span> { + <span class='self'>self</span>.<span class='ident'>level</span> + } + + <span class='doccomment'>/// The name of the target of the directive.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>target</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>str</span> { + <span class='self'>self</span>.<span class='ident'>target</span> + } +} + +<span class='doccomment'>/// A trait encapsulating the operations required of a logger</span> +<span class='kw'>pub</span> <span class='kw'>trait</span> <span class='ident'>Log</span>: <span class='ident'>Sync</span><span class='op'>+</span><span class='ident'>Send</span> { + <span class='doccomment'>/// Determines if a log message with the specified metadata would be</span> + <span class='doccomment'>/// logged.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This is used by the `log_enabled!` macro to allow callers to avoid</span> + <span class='doccomment'>/// expensive computation of log message arguments if the message would be</span> + <span class='doccomment'>/// discarded anyway.</span> + <span class='kw'>fn</span> <span class='ident'>enabled</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>metadata</span>: <span class='kw-2'>&</span><span class='ident'>LogMetadata</span>) <span class='op'>-></span> <span class='ident'>bool</span>; + + <span class='doccomment'>/// Logs the `LogRecord`.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Note that `enabled` is *not* necessarily called before this method.</span> + <span class='doccomment'>/// Implementations of `log` should perform all necessary filtering</span> + <span class='doccomment'>/// internally.</span> + <span class='kw'>fn</span> <span class='ident'>log</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>record</span>: <span class='kw-2'>&</span><span class='ident'>LogRecord</span>); +} + +<span class='doccomment'>/// The location of a log message.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Warning</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The fields of this struct are public so that they may be initialized by the</span> +<span class='doccomment'>/// `log!` macro. They are subject to change at any time and should never be</span> +<span class='doccomment'>/// accessed directly.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>, <span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>LogLocation</span> { + <span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> + <span class='kw'>pub</span> <span class='ident'>__module_path</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>, + <span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> + <span class='kw'>pub</span> <span class='ident'>__file</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>, + <span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> + <span class='kw'>pub</span> <span class='ident'>__line</span>: <span class='ident'>u32</span>, +} + +<span class='kw'>impl</span> <span class='ident'>LogLocation</span> { + <span class='doccomment'>/// The module path of the message.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>module_path</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>str</span> { + <span class='self'>self</span>.<span class='ident'>__module_path</span> + } + + <span class='doccomment'>/// The source file containing the message.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>file</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>str</span> { + <span class='self'>self</span>.<span class='ident'>__file</span> + } + + <span class='doccomment'>/// The line containing the message.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>line</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>u32</span> { + <span class='self'>self</span>.<span class='ident'>__line</span> + } +} + +<span class='doccomment'>/// A token providing read and write access to the global maximum log level</span> +<span class='doccomment'>/// filter.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The maximum log level is used as an optimization to avoid evaluating log</span> +<span class='doccomment'>/// messages that will be ignored by the logger. Any message with a level</span> +<span class='doccomment'>/// higher than the maximum log level filter will be ignored. A logger should</span> +<span class='doccomment'>/// make sure to keep the maximum log level filter in sync with its current</span> +<span class='doccomment'>/// configuration.</span> +<span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>missing_copy_implementations</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>MaxLogLevelFilter</span>(()); + +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Debug</span> <span class='kw'>for</span> <span class='ident'>MaxLogLevelFilter</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>fmt</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>fmt</span>, <span class='string'>"MaxLogLevelFilter"</span>) + } +} + +<span class='kw'>impl</span> <span class='ident'>MaxLogLevelFilter</span> { + <span class='doccomment'>/// Gets the current maximum log level filter.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>LogLevelFilter</span> { + <span class='ident'>max_log_level</span>() + } + + <span class='doccomment'>/// Sets the maximum log level.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>level</span>: <span class='ident'>LogLevelFilter</span>) { + <span class='ident'>MAX_LOG_LEVEL_FILTER</span>.<span class='ident'>store</span>(<span class='ident'>level</span> <span class='kw'>as</span> <span class='ident'>usize</span>, <span class='ident'>Ordering</span>::<span class='ident'>SeqCst</span>) + } +} + +<span class='doccomment'>/// Returns the current maximum log level.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The `log!`, `error!`, `warn!`, `info!`, `debug!`, and `trace!` macros check</span> +<span class='doccomment'>/// this value and discard any message logged at a higher level. The maximum</span> +<span class='doccomment'>/// log level is set by the `MaxLogLevel` token passed to loggers.</span> +<span class='attribute'>#[<span class='ident'>inline</span>(<span class='ident'>always</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>max_log_level</span>() <span class='op'>-></span> <span class='ident'>LogLevelFilter</span> { + <span class='kw'>unsafe</span> { <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='ident'>MAX_LOG_LEVEL_FILTER</span>.<span class='ident'>load</span>(<span class='ident'>Ordering</span>::<span class='ident'>Relaxed</span>)) } +} + +<span class='doccomment'>/// Sets the global logger.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The `make_logger` closure is passed a `MaxLogLevel` object, which the</span> +<span class='doccomment'>/// logger should use to keep the global maximum log level in sync with the</span> +<span class='doccomment'>/// highest log level that the logger will not ignore.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This function may only be called once in the lifetime of a program. Any log</span> +<span class='doccomment'>/// events that occur before the call to `set_logger` completes will be</span> +<span class='doccomment'>/// ignored.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This function does not typically need to be called manually. Logger</span> +<span class='doccomment'>/// implementations should provide an initialization method that calls</span> +<span class='doccomment'>/// `set_logger` internally.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_logger</span><span class='op'><</span><span class='ident'>M</span><span class='op'>></span>(<span class='ident'>make_logger</span>: <span class='ident'>M</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(), <span class='ident'>SetLoggerError</span><span class='op'>></span> + <span class='kw'>where</span> <span class='ident'>M</span>: <span class='ident'>FnOnce</span>(<span class='ident'>MaxLogLevelFilter</span>) <span class='op'>-></span> <span class='ident'>Box</span><span class='op'><</span><span class='ident'>Log</span><span class='op'>></span> { + <span class='kw'>if</span> <span class='ident'>LOGGER</span>.<span class='ident'>compare_and_swap</span>(<span class='ident'>UNINITIALIZED</span>, <span class='ident'>INITIALIZING</span>, + <span class='ident'>Ordering</span>::<span class='ident'>SeqCst</span>) <span class='op'>!=</span> <span class='ident'>UNINITIALIZED</span> { + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='ident'>SetLoggerError</span>(())); + } + + <span class='kw'>let</span> <span class='ident'>logger</span> <span class='op'>=</span> <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>make_logger</span>(<span class='ident'>MaxLogLevelFilter</span>(()))); + <span class='kw'>let</span> <span class='ident'>logger</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>mem</span>::<span class='ident'>transmute</span>::<span class='op'><</span><span class='ident'>Box</span><span class='op'><</span><span class='ident'>Box</span><span class='op'><</span><span class='ident'>Log</span><span class='op'>>></span>, <span class='ident'>usize</span><span class='op'>></span>(<span class='ident'>logger</span>) }; + <span class='ident'>LOGGER</span>.<span class='ident'>store</span>(<span class='ident'>logger</span>, <span class='ident'>Ordering</span>::<span class='ident'>SeqCst</span>); + + <span class='kw'>unsafe</span> { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>libc</span>::<span class='ident'>atexit</span>(<span class='ident'>shutdown</span>), <span class='number'>0</span>); + } + <span class='kw'>return</span> <span class='prelude-val'>Ok</span>(()); + + <span class='kw'>extern</span> <span class='kw'>fn</span> <span class='ident'>shutdown</span>() { + <span class='comment'>// Set to INITIALIZING to prevent re-initialization after</span> + <span class='kw'>let</span> <span class='ident'>logger</span> <span class='op'>=</span> <span class='ident'>LOGGER</span>.<span class='ident'>swap</span>(<span class='ident'>INITIALIZING</span>, <span class='ident'>Ordering</span>::<span class='ident'>SeqCst</span>); + + <span class='kw'>while</span> <span class='ident'>REFCOUNT</span>.<span class='ident'>load</span>(<span class='ident'>Ordering</span>::<span class='ident'>SeqCst</span>) <span class='op'>!=</span> <span class='number'>0</span> { + <span class='comment'>// FIXME add a sleep here when it doesn't involve timers</span> + } + + <span class='kw'>unsafe</span> { <span class='ident'>mem</span>::<span class='ident'>transmute</span>::<span class='op'><</span><span class='ident'>usize</span>, <span class='ident'>Box</span><span class='op'><</span><span class='ident'>Box</span><span class='op'><</span><span class='ident'>Log</span><span class='op'>>></span><span class='op'>></span>(<span class='ident'>logger</span>); } + } +} + +<span class='doccomment'>/// The type returned by `set_logger` if `set_logger` has already been called.</span> +<span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>missing_copy_implementations</span>)]</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>SetLoggerError</span>(()); + +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Display</span> <span class='kw'>for</span> <span class='ident'>SetLoggerError</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>fmt</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>fmt</span>, <span class='string'>"attempted to set a logger after the logging system \ + was already initialized"</span>) + } +} + +<span class='kw'>impl</span> <span class='ident'>error</span>::<span class='ident'>Error</span> <span class='kw'>for</span> <span class='ident'>SetLoggerError</span> { + <span class='kw'>fn</span> <span class='ident'>description</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>str</span> { <span class='string'>"set_logger() called multiple times"</span> } +} + +<span class='kw'>struct</span> <span class='ident'>LoggerGuard</span>(<span class='ident'>usize</span>); + +<span class='kw'>impl</span> <span class='ident'>Drop</span> <span class='kw'>for</span> <span class='ident'>LoggerGuard</span> { + <span class='kw'>fn</span> <span class='ident'>drop</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='ident'>REFCOUNT</span>.<span class='ident'>fetch_sub</span>(<span class='number'>1</span>, <span class='ident'>Ordering</span>::<span class='ident'>SeqCst</span>); + } +} + +<span class='kw'>impl</span> <span class='ident'>Deref</span> <span class='kw'>for</span> <span class='ident'>LoggerGuard</span> { + <span class='kw'>type</span> <span class='ident'>Target</span> <span class='op'>=</span> <span class='ident'>Box</span><span class='op'><</span><span class='ident'>Log</span><span class='op'>></span>; + + <span class='kw'>fn</span> <span class='ident'>deref</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>Box</span><span class='op'><</span><span class='ident'>Log</span><span class='op'>+</span><span class='lifetime'>'static</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='self'>self</span>.<span class='number'>0</span>) } + } +} + +<span class='kw'>fn</span> <span class='ident'>logger</span>() <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>LoggerGuard</span><span class='op'>></span> { + <span class='ident'>REFCOUNT</span>.<span class='ident'>fetch_add</span>(<span class='number'>1</span>, <span class='ident'>Ordering</span>::<span class='ident'>SeqCst</span>); + <span class='kw'>let</span> <span class='ident'>logger</span> <span class='op'>=</span> <span class='ident'>LOGGER</span>.<span class='ident'>load</span>(<span class='ident'>Ordering</span>::<span class='ident'>SeqCst</span>); + <span class='kw'>if</span> <span class='ident'>logger</span> <span class='op'>==</span> <span class='ident'>UNINITIALIZED</span> <span class='op'>||</span> <span class='ident'>logger</span> <span class='op'>==</span> <span class='ident'>INITIALIZING</span> { + <span class='ident'>REFCOUNT</span>.<span class='ident'>fetch_sub</span>(<span class='number'>1</span>, <span class='ident'>Ordering</span>::<span class='ident'>SeqCst</span>); + <span class='prelude-val'>None</span> + } <span class='kw'>else</span> { + <span class='prelude-val'>Some</span>(<span class='ident'>LoggerGuard</span>(<span class='ident'>logger</span>)) + } +} + +<span class='comment'>// WARNING</span> +<span class='comment'>// This is not considered part of the crate's public API. It is subject to</span> +<span class='comment'>// change at any time.</span> +<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>__enabled</span>(<span class='ident'>level</span>: <span class='ident'>LogLevel</span>, <span class='ident'>target</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>logger</span>) <span class='op'>=</span> <span class='ident'>logger</span>() { + <span class='ident'>logger</span>.<span class='ident'>enabled</span>(<span class='kw-2'>&</span><span class='ident'>LogMetadata</span> { <span class='ident'>level</span>: <span class='ident'>level</span>, <span class='ident'>target</span>: <span class='ident'>target</span> }) + } <span class='kw'>else</span> { + <span class='boolval'>false</span> + } +} + +<span class='comment'>// WARNING</span> +<span class='comment'>// This is not considered part of the crate's public API. It is subject to</span> +<span class='comment'>// change at any time.</span> +<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>__log</span>(<span class='ident'>level</span>: <span class='ident'>LogLevel</span>, <span class='ident'>target</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>loc</span>: <span class='kw-2'>&</span><span class='ident'>LogLocation</span>, + <span class='ident'>args</span>: <span class='ident'>fmt</span>::<span class='ident'>Arguments</span>) { + <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>logger</span>) <span class='op'>=</span> <span class='ident'>logger</span>() { + <span class='kw'>let</span> <span class='ident'>record</span> <span class='op'>=</span> <span class='ident'>LogRecord</span> { + <span class='ident'>metadata</span>: <span class='ident'>LogMetadata</span> { + <span class='ident'>level</span>: <span class='ident'>level</span>, + <span class='ident'>target</span>: <span class='ident'>target</span>, + }, + <span class='ident'>location</span>: <span class='ident'>loc</span>, + <span class='ident'>args</span>: <span class='ident'>args</span> + }; + <span class='ident'>logger</span>.<span class='ident'>log</span>(<span class='kw-2'>&</span><span class='ident'>record</span>) + } +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>tests</span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>error</span>::<span class='ident'>Error</span>; + <span class='kw'>use</span> <span class='ident'>super</span>::{<span class='ident'>LogLevel</span>, <span class='ident'>LogLevelFilter</span>, <span class='ident'>SetLoggerError</span>}; + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_loglevelfilter_from_str</span>() { + <span class='kw'>let</span> <span class='ident'>tests</span> <span class='op'>=</span> [ + (<span class='string'>"off"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Off</span>)), + (<span class='string'>"error"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Error</span>)), + (<span class='string'>"warn"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Warn</span>)), + (<span class='string'>"info"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Info</span>)), + (<span class='string'>"debug"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Debug</span>)), + (<span class='string'>"trace"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Trace</span>)), + (<span class='string'>"OFF"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Off</span>)), + (<span class='string'>"ERROR"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Error</span>)), + (<span class='string'>"WARN"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Warn</span>)), + (<span class='string'>"INFO"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Info</span>)), + (<span class='string'>"DEBUG"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Debug</span>)), + (<span class='string'>"TRACE"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Trace</span>)), + (<span class='string'>"asdf"</span>, <span class='prelude-val'>Err</span>(())), + ]; + <span class='kw'>for</span> <span class='kw-2'>&</span>(<span class='ident'>s</span>, <span class='kw-2'>ref</span> <span class='ident'>expected</span>) <span class='kw'>in</span> <span class='kw-2'>&</span><span class='ident'>tests</span> { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>expected</span>, <span class='kw-2'>&</span><span class='ident'>s</span>.<span class='ident'>parse</span>()); + } + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_loglevel_from_str</span>() { + <span class='kw'>let</span> <span class='ident'>tests</span> <span class='op'>=</span> [ + (<span class='string'>"OFF"</span>, <span class='prelude-val'>Err</span>(())), + (<span class='string'>"error"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Error</span>)), + (<span class='string'>"warn"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Warn</span>)), + (<span class='string'>"info"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Info</span>)), + (<span class='string'>"debug"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Debug</span>)), + (<span class='string'>"trace"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Trace</span>)), + (<span class='string'>"ERROR"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Error</span>)), + (<span class='string'>"WARN"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Warn</span>)), + (<span class='string'>"INFO"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Info</span>)), + (<span class='string'>"DEBUG"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Debug</span>)), + (<span class='string'>"TRACE"</span>, <span class='prelude-val'>Ok</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Trace</span>)), + (<span class='string'>"asdf"</span>, <span class='prelude-val'>Err</span>(())), + ]; + <span class='kw'>for</span> <span class='kw-2'>&</span>(<span class='ident'>s</span>, <span class='kw-2'>ref</span> <span class='ident'>expected</span>) <span class='kw'>in</span> <span class='kw-2'>&</span><span class='ident'>tests</span> { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>expected</span>, <span class='kw-2'>&</span><span class='ident'>s</span>.<span class='ident'>parse</span>()); + } + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_loglevel_show</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>"INFO"</span>, <span class='ident'>LogLevel</span>::<span class='ident'>Info</span>.<span class='ident'>to_string</span>()); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>"ERROR"</span>, <span class='ident'>LogLevel</span>::<span class='ident'>Error</span>.<span class='ident'>to_string</span>()); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_loglevelfilter_show</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>"OFF"</span>, <span class='ident'>LogLevelFilter</span>::<span class='ident'>Off</span>.<span class='ident'>to_string</span>()); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>"ERROR"</span>, <span class='ident'>LogLevelFilter</span>::<span class='ident'>Error</span>.<span class='ident'>to_string</span>()); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_cross_cmp</span>() { + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Debug</span> <span class='op'>></span> <span class='ident'>LogLevelFilter</span>::<span class='ident'>Error</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Warn</span> <span class='op'><</span> <span class='ident'>LogLevel</span>::<span class='ident'>Trace</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Off</span> <span class='op'><</span> <span class='ident'>LogLevel</span>::<span class='ident'>Error</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_cross_eq</span>() { + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Error</span> <span class='op'>==</span> <span class='ident'>LogLevelFilter</span>::<span class='ident'>Error</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Off</span> <span class='op'>!=</span> <span class='ident'>LogLevel</span>::<span class='ident'>Error</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Trace</span> <span class='op'>==</span> <span class='ident'>LogLevelFilter</span>::<span class='ident'>Trace</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_to_log_level</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Error</span>), <span class='ident'>LogLevelFilter</span>::<span class='ident'>Error</span>.<span class='ident'>to_log_level</span>()); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>None</span>, <span class='ident'>LogLevelFilter</span>::<span class='ident'>Off</span>.<span class='ident'>to_log_level</span>()); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='ident'>LogLevel</span>::<span class='ident'>Debug</span>), <span class='ident'>LogLevelFilter</span>::<span class='ident'>Debug</span>.<span class='ident'>to_log_level</span>()); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_to_log_level_filter</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Error</span>, <span class='ident'>LogLevel</span>::<span class='ident'>Error</span>.<span class='ident'>to_log_level_filter</span>()); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>LogLevelFilter</span>::<span class='ident'>Trace</span>, <span class='ident'>LogLevel</span>::<span class='ident'>Trace</span>.<span class='ident'>to_log_level_filter</span>()); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_error_trait</span>() { + <span class='kw'>let</span> <span class='ident'>e</span> <span class='op'>=</span> <span class='ident'>SetLoggerError</span>(()); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>e</span>.<span class='ident'>description</span>(), <span class='string'>"set_logger() called multiple times"</span>); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "log"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/log/macros.rs.html b/src/log/macros.rs.html new file mode 100644 index 0000000..cd4dd2a --- /dev/null +++ b/src/log/macros.rs.html @@ -0,0 +1,387 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/log-0.3.1/src/macros.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>macros.rs.html -- source</title> + + <link rel="stylesheet" type="text/css" href="../../main.css"> + + <link rel="shortcut icon" href="http://www.rust-lang.org/favicon.ico"> + +</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"> + <a href='../../log/index.html'><img src='http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png' alt='' width='100'></a> + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +</pre><pre class='rust '> +<span class='comment'>// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT</span> +<span class='comment'>// file at the top-level directory of this distribution and at</span> +<span class='comment'>// http://rust-lang.org/COPYRIGHT.</span> +<span class='comment'>//</span> +<span class='comment'>// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or</span> +<span class='comment'>// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license</span> +<span class='comment'>// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your</span> +<span class='comment'>// option. This file may not be copied, modified, or distributed</span> +<span class='comment'>// except according to those terms.</span> +<span class='doccomment'>/// The standard logging macro.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This macro will generically log with the specified `LogLevel` and `format!`</span> +<span class='doccomment'>/// based argument list.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The `log_level` cfg can be used to statically disable logging at various</span> +<span class='doccomment'>/// levels.</span> +<span class='attribute'>#[<span class='ident'>macro_export</span>]</span> +<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>log</span> { + (<span class='ident'>target</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>target</span>:<span class='ident'>expr</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>lvl</span>:<span class='ident'>expr</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>:<span class='ident'>tt</span>)<span class='op'>+</span>) <span class='op'>=></span> ({ + <span class='kw'>static</span> <span class='ident'>LOC</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLocation</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLocation</span> { + <span class='ident'>__line</span>: <span class='macro'>line</span><span class='macro'>!</span>(), + <span class='ident'>__file</span>: <span class='macro'>file</span><span class='macro'>!</span>(), + <span class='ident'>__module_path</span>: <span class='macro'>module_path</span><span class='macro'>!</span>(), + }; + <span class='kw'>let</span> <span class='ident'>lvl</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>lvl</span>; + <span class='kw'>if</span> <span class='op'>!</span><span class='macro'>cfg</span><span class='macro'>!</span>(<span class='ident'>log_level</span> <span class='op'>=</span> <span class='string'>"off"</span>) <span class='op'>&&</span> + (<span class='ident'>lvl</span> <span class='op'><=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Error</span> <span class='op'>||</span> <span class='op'>!</span><span class='macro'>cfg</span><span class='macro'>!</span>(<span class='ident'>log_level</span> <span class='op'>=</span> <span class='string'>"error"</span>)) <span class='op'>&&</span> + (<span class='ident'>lvl</span> <span class='op'><=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Warn</span> <span class='op'>||</span> <span class='op'>!</span><span class='macro'>cfg</span><span class='macro'>!</span>(<span class='ident'>log_level</span> <span class='op'>=</span> <span class='string'>"warn"</span>)) <span class='op'>&&</span> + (<span class='ident'>lvl</span> <span class='op'><=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Debug</span> <span class='op'>||</span> <span class='op'>!</span><span class='macro'>cfg</span><span class='macro'>!</span>(<span class='ident'>log_level</span> <span class='op'>=</span> <span class='string'>"debug"</span>)) <span class='op'>&&</span> + (<span class='ident'>lvl</span> <span class='op'><=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Info</span> <span class='op'>||</span> <span class='op'>!</span><span class='macro'>cfg</span><span class='macro'>!</span>(<span class='ident'>log_level</span> <span class='op'>=</span> <span class='string'>"info"</span>)) <span class='op'>&&</span> + <span class='ident'>lvl</span> <span class='op'><=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>max_log_level</span>() { + <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>__log</span>(<span class='ident'>lvl</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>target</span>, <span class='kw-2'>&</span><span class='ident'>LOC</span>, <span class='macro'>format_args</span><span class='macro'>!</span>($(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>)<span class='op'>+</span>)) + } + }); + (<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>lvl</span>:<span class='ident'>expr</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>:<span class='ident'>tt</span>)<span class='op'>+</span>) <span class='op'>=></span> (<span class='macro'>log</span><span class='macro'>!</span>(<span class='ident'>target</span>: <span class='macro'>module_path</span><span class='macro'>!</span>(), <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>lvl</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>)<span class='op'>+</span>)) +} + +<span class='doccomment'>/// Logs a message at the error level.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Logging at this level is disabled if the `log_level = "off"` cfg is</span> +<span class='doccomment'>/// present.</span> +<span class='attribute'>#[<span class='ident'>macro_export</span>]</span> +<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>error</span> { + (<span class='ident'>target</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>target</span>:<span class='ident'>expr</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>:<span class='ident'>tt</span>)<span class='op'>*</span>) <span class='op'>=></span> ( + <span class='macro'>log</span><span class='macro'>!</span>(<span class='ident'>target</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>target</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Error</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>)<span class='op'>*</span>); + ); + ($(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>:<span class='ident'>tt</span>)<span class='op'>*</span>) <span class='op'>=></span> ( + <span class='macro'>log</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Error</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>)<span class='op'>*</span>); + ) +} + +<span class='doccomment'>/// Logs a message at the warn level.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Logging at this level is disabled if any of the following cfgs are present:</span> +<span class='doccomment'>/// `log_level = "off"` or `log_level = "error"`.</span> +<span class='attribute'>#[<span class='ident'>macro_export</span>]</span> +<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>warn</span> { + (<span class='ident'>target</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>target</span>:<span class='ident'>expr</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>:<span class='ident'>tt</span>)<span class='op'>*</span>) <span class='op'>=></span> ( + <span class='macro'>log</span><span class='macro'>!</span>(<span class='ident'>target</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>target</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Warn</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>)<span class='op'>*</span>); + ); + ($(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>:<span class='ident'>tt</span>)<span class='op'>*</span>) <span class='op'>=></span> ( + <span class='macro'>log</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Warn</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>)<span class='op'>*</span>); + ) +} + +<span class='doccomment'>/// Logs a message at the info level.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Logging at this level is disabled if any of the following cfgs are present:</span> +<span class='doccomment'>/// `log_level = "off"`, `log_level = "error"`, or</span> +<span class='doccomment'>/// `log_level = "warn"`.</span> +<span class='attribute'>#[<span class='ident'>macro_export</span>]</span> +<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>info</span> { + (<span class='ident'>target</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>target</span>:<span class='ident'>expr</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>:<span class='ident'>tt</span>)<span class='op'>*</span>) <span class='op'>=></span> ( + <span class='macro'>log</span><span class='macro'>!</span>(<span class='ident'>target</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>target</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Info</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>)<span class='op'>*</span>); + ); + ($(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>:<span class='ident'>tt</span>)<span class='op'>*</span>) <span class='op'>=></span> ( + <span class='macro'>log</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Info</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>)<span class='op'>*</span>); + ) +} + +<span class='doccomment'>/// Logs a message at the debug level.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Logging at this level is disabled if any of the following cfgs are present:</span> +<span class='doccomment'>/// `log_level = "off"`, `log_level = "error"`, `log_level = "warn"`,</span> +<span class='doccomment'>/// or `log_level = "info"`.</span> +<span class='attribute'>#[<span class='ident'>macro_export</span>]</span> +<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>debug</span> { + (<span class='ident'>target</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>target</span>:<span class='ident'>expr</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>:<span class='ident'>tt</span>)<span class='op'>*</span>) <span class='op'>=></span> ( + <span class='macro'>log</span><span class='macro'>!</span>(<span class='ident'>target</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>target</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Debug</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>)<span class='op'>*</span>); + ); + ($(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>:<span class='ident'>tt</span>)<span class='op'>*</span>) <span class='op'>=></span> ( + <span class='macro'>log</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Debug</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>)<span class='op'>*</span>); + ) +} + +<span class='doccomment'>/// Logs a message at the trace level.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Logging at this level is disabled if any of the following cfgs are present:</span> +<span class='doccomment'>/// `log_level = "off"`, `log_level = "error"`, `log_level = "warn"`,</span> +<span class='doccomment'>/// `log_level = "info"`, or `log_level = "debug"`.</span> +<span class='attribute'>#[<span class='ident'>macro_export</span>]</span> +<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>trace</span> { + (<span class='ident'>target</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>target</span>:<span class='ident'>expr</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>:<span class='ident'>tt</span>)<span class='op'>*</span>) <span class='op'>=></span> ( + <span class='macro'>log</span><span class='macro'>!</span>(<span class='ident'>target</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>target</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Trace</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>)<span class='op'>*</span>); + ); + ($(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>:<span class='ident'>tt</span>)<span class='op'>*</span>) <span class='op'>=></span> ( + <span class='macro'>log</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Trace</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>arg</span>)<span class='op'>*</span>); + ) +} + +<span class='doccomment'>/// Determines if a message logged at the specified level in that module will</span> +<span class='doccomment'>/// be logged.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This can be used to avoid expensive computation of log message arguments if</span> +<span class='doccomment'>/// the message would be ignored anyway.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Examples</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ```rust</span> +<span class='doccomment'>/// # #[macro_use]</span> +<span class='doccomment'>/// # extern crate log;</span> +<span class='doccomment'>/// use log::LogLevel::Debug;</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # fn foo() {</span> +<span class='doccomment'>/// if log_enabled!(Debug) {</span> +<span class='doccomment'>/// debug!("expensive debug data: {}", expensive_call());</span> +<span class='doccomment'>/// }</span> +<span class='doccomment'>/// # }</span> +<span class='doccomment'>/// # fn expensive_call() -> u32 { 0 }</span> +<span class='doccomment'>/// # fn main() {}</span> +<span class='doccomment'>/// ```</span> +<span class='attribute'>#[<span class='ident'>macro_export</span>]</span> +<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>log_enabled</span> { + (<span class='ident'>target</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>target</span>:<span class='ident'>expr</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>lvl</span>:<span class='ident'>expr</span>) <span class='op'>=></span> ({ + <span class='kw'>let</span> <span class='ident'>lvl</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>lvl</span>; + <span class='op'>!</span><span class='macro'>cfg</span><span class='macro'>!</span>(<span class='ident'>log_level</span> <span class='op'>=</span> <span class='string'>"off"</span>) <span class='op'>&&</span> + (<span class='ident'>lvl</span> <span class='op'><=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Error</span> <span class='op'>||</span> <span class='op'>!</span><span class='macro'>cfg</span><span class='macro'>!</span>(<span class='ident'>log_level</span> <span class='op'>=</span> <span class='string'>"error"</span>)) <span class='op'>&&</span> + (<span class='ident'>lvl</span> <span class='op'><=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Warn</span> <span class='op'>||</span> <span class='op'>!</span><span class='macro'>cfg</span><span class='macro'>!</span>(<span class='ident'>log_level</span> <span class='op'>=</span> <span class='string'>"warn"</span>)) <span class='op'>&&</span> + (<span class='ident'>lvl</span> <span class='op'><=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Debug</span> <span class='op'>||</span> <span class='op'>!</span><span class='macro'>cfg</span><span class='macro'>!</span>(<span class='ident'>log_level</span> <span class='op'>=</span> <span class='string'>"debug"</span>)) <span class='op'>&&</span> + (<span class='ident'>lvl</span> <span class='op'><=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>LogLevel</span>::<span class='ident'>Info</span> <span class='op'>||</span> <span class='op'>!</span><span class='macro'>cfg</span><span class='macro'>!</span>(<span class='ident'>log_level</span> <span class='op'>=</span> <span class='string'>"info"</span>)) <span class='op'>&&</span> + <span class='ident'>lvl</span> <span class='op'><=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>max_log_level</span>() <span class='op'>&&</span> + <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>crate</span>::<span class='ident'>__enabled</span>(<span class='ident'>lvl</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>target</span>) + }); + (<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>lvl</span>:<span class='ident'>expr</span>) <span class='op'>=></span> (<span class='macro'>log_enabled</span><span class='macro'>!</span>(<span class='ident'>target</span>: <span class='macro'>module_path</span><span class='macro'>!</span>(), <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>lvl</span>)) +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "log"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/memchr/lib.rs.html b/src/memchr/lib.rs.html new file mode 100644 index 0000000..0e3568c --- /dev/null +++ b/src/memchr/lib.rs.html @@ -0,0 +1,287 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/memchr-0.1.3/src/lib.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>lib.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10">10</span> +<span id="11">11</span> +<span id="12">12</span> +<span id="13">13</span> +<span id="14">14</span> +<span id="15">15</span> +<span id="16">16</span> +<span id="17">17</span> +<span id="18">18</span> +<span id="19">19</span> +<span id="20">20</span> +<span id="21">21</span> +<span id="22">22</span> +<span id="23">23</span> +<span id="24">24</span> +<span id="25">25</span> +<span id="26">26</span> +<span id="27">27</span> +<span id="28">28</span> +<span id="29">29</span> +<span id="30">30</span> +<span id="31">31</span> +<span id="32">32</span> +<span id="33">33</span> +<span id="34">34</span> +<span id="35">35</span> +<span id="36">36</span> +<span id="37">37</span> +<span id="38">38</span> +<span id="39">39</span> +<span id="40">40</span> +<span id="41">41</span> +<span id="42">42</span> +<span id="43">43</span> +<span id="44">44</span> +<span id="45">45</span> +<span id="46">46</span> +<span id="47">47</span> +<span id="48">48</span> +<span id="49">49</span> +<span id="50">50</span> +<span id="51">51</span> +<span id="52">52</span> +<span id="53">53</span> +<span id="54">54</span> +<span id="55">55</span> +<span id="56">56</span> +<span id="57">57</span> +<span id="58">58</span> +<span id="59">59</span> +<span id="60">60</span> +<span id="61">61</span> +<span id="62">62</span> +<span id="63">63</span> +<span id="64">64</span> +<span id="65">65</span> +<span id="66">66</span> +<span id="67">67</span> +<span id="68">68</span> +<span id="69">69</span> +<span id="70">70</span> +<span id="71">71</span> +<span id="72">72</span> +<span id="73">73</span> +<span id="74">74</span> +<span id="75">75</span> +<span id="76">76</span> +<span id="77">77</span> +<span id="78">78</span> +<span id="79">79</span> +<span id="80">80</span> +<span id="81">81</span> +<span id="82">82</span> +<span id="83">83</span> +<span id="84">84</span> +<span id="85">85</span> +<span id="86">86</span> +<span id="87">87</span> +<span id="88">88</span> +<span id="89">89</span> +<span id="90">90</span> +<span id="91">91</span> +<span id="92">92</span> +<span id="93">93</span> +<span id="94">94</span> +<span id="95">95</span> +</pre><pre class='rust '> +<span class='doccomment'>/*! +This crate defines a single function, `memchr`, which exposes a safe interface +to the corresponding function in `libc`. +*/</span> + +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>deny</span>(<span class='ident'>missing_docs</span>)]</span> + +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>libc</span>; + +<span class='kw'>use</span> <span class='ident'>libc</span>::<span class='ident'>funcs</span>::<span class='ident'>c95</span>::<span class='ident'>string</span>; +<span class='kw'>use</span> <span class='ident'>libc</span>::<span class='ident'>types</span>::<span class='ident'>common</span>::<span class='ident'>c95</span>::<span class='ident'>c_void</span>; +<span class='kw'>use</span> <span class='ident'>libc</span>::<span class='ident'>types</span>::<span class='ident'>os</span>::<span class='ident'>arch</span>::<span class='ident'>c95</span>::{<span class='ident'>c_int</span>, <span class='ident'>size_t</span>}; + +<span class='doccomment'>/// A safe interface to `memchr`.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Returns the index corresponding to the first occurrence of `needle` in</span> +<span class='doccomment'>/// `haystack`, or `None` if one is not found.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// memchr reduces to super-optimized machine code at around an order of</span> +<span class='doccomment'>/// magnitude faster than `haystack.iter().position(|&b| b == needle)`.</span> +<span class='doccomment'>/// (See benchmarks.)</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Example</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This shows how to find the first position of a byte in a byte string.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ```rust</span> +<span class='doccomment'>/// use memchr::memchr;</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// let haystack = b"the quick brown fox";</span> +<span class='doccomment'>/// assert_eq!(memchr(b'k', haystack), Some(8));</span> +<span class='doccomment'>/// ```</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>memchr</span>(<span class='ident'>needle</span>: <span class='ident'>u8</span>, <span class='ident'>haystack</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>p</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { + <span class='ident'>string</span>::<span class='ident'>memchr</span>( + <span class='ident'>haystack</span>.<span class='ident'>as_ptr</span>() <span class='kw'>as</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, + <span class='ident'>needle</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, + <span class='ident'>haystack</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>size_t</span>) + }; + <span class='kw'>if</span> <span class='ident'>p</span>.<span class='ident'>is_null</span>() { + <span class='prelude-val'>None</span> + } <span class='kw'>else</span> { + <span class='prelude-val'>Some</span>(<span class='ident'>p</span> <span class='kw'>as</span> <span class='ident'>usize</span> <span class='op'>-</span> (<span class='ident'>haystack</span>.<span class='ident'>as_ptr</span>() <span class='kw'>as</span> <span class='ident'>usize</span>)) + } +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>tests</span> { + <span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>quickcheck</span>; + + <span class='kw'>use</span> <span class='ident'>super</span>::<span class='ident'>memchr</span>; + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>matches_one</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='number'>0</span>), <span class='ident'>memchr</span>(<span class='string'>b'a'</span>, <span class='string'>b"a"</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>matches_begin</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='number'>0</span>), <span class='ident'>memchr</span>(<span class='string'>b'a'</span>, <span class='string'>b"aaaa"</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>matches_end</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='number'>4</span>), <span class='ident'>memchr</span>(<span class='string'>b'z'</span>, <span class='string'>b"aaaaz"</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>matches_nul</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='number'>4</span>), <span class='ident'>memchr</span>(<span class='string'>b'\x00'</span>, <span class='string'>b"aaaa\x00"</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>matches_past_nul</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>Some</span>(<span class='number'>5</span>), <span class='ident'>memchr</span>(<span class='string'>b'z'</span>, <span class='string'>b"aaaa\x00z"</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>no_match_empty</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>None</span>, <span class='ident'>memchr</span>(<span class='string'>b'a'</span>, <span class='string'>b""</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>no_match</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='prelude-val'>None</span>, <span class='ident'>memchr</span>(<span class='string'>b'a'</span>, <span class='string'>b"xyz"</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>qc_never_fail</span>() { + <span class='kw'>fn</span> <span class='ident'>prop</span>(<span class='ident'>needle</span>: <span class='ident'>u8</span>, <span class='ident'>haystack</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='ident'>memchr</span>(<span class='ident'>needle</span>, <span class='kw-2'>&</span><span class='ident'>haystack</span>); <span class='boolval'>true</span> + } + <span class='ident'>quickcheck</span>::<span class='ident'>quickcheck</span>(<span class='ident'>prop</span> <span class='kw'>as</span> <span class='kw'>fn</span>(<span class='ident'>u8</span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>bool</span>); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "memchr"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl/asn1/mod.rs.html b/src/openssl/asn1/mod.rs.html new file mode 100644 index 0000000..5d7d165 --- /dev/null +++ b/src/openssl/asn1/mod.rs.html @@ -0,0 +1,195 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-0.6.3/src/asn1/mod.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>mod.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10">10</span> +<span id="11">11</span> +<span id="12">12</span> +<span id="13">13</span> +<span id="14">14</span> +<span id="15">15</span> +<span id="16">16</span> +<span id="17">17</span> +<span id="18">18</span> +<span id="19">19</span> +<span id="20">20</span> +<span id="21">21</span> +<span id="22">22</span> +<span id="23">23</span> +<span id="24">24</span> +<span id="25">25</span> +<span id="26">26</span> +<span id="27">27</span> +<span id="28">28</span> +<span id="29">29</span> +<span id="30">30</span> +<span id="31">31</span> +<span id="32">32</span> +<span id="33">33</span> +<span id="34">34</span> +<span id="35">35</span> +<span id="36">36</span> +<span id="37">37</span> +<span id="38">38</span> +<span id="39">39</span> +<span id="40">40</span> +<span id="41">41</span> +<span id="42">42</span> +<span id="43">43</span> +<span id="44">44</span> +<span id="45">45</span> +<span id="46">46</span> +<span id="47">47</span> +<span id="48">48</span> +<span id="49">49</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>libc</span>::{<span class='ident'>c_long</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ptr</span>; + +<span class='kw'>use</span> <span class='ident'>ffi</span>; +<span class='kw'>use</span> <span class='ident'>ssl</span>::<span class='ident'>error</span>::{<span class='ident'>SslError</span>}; + + +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Asn1Time</span> { + <span class='ident'>handle</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>ASN1_TIME</span>, + <span class='ident'>owned</span>: <span class='ident'>bool</span> +} + +<span class='kw'>impl</span> <span class='ident'>Asn1Time</span> { + <span class='doccomment'>/// Wraps existing ASN1_TIME and takes ownership</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>handle</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>ASN1_TIME</span>) <span class='op'>-></span> <span class='ident'>Asn1Time</span> { + <span class='ident'>Asn1Time</span> { + <span class='ident'>handle</span>: <span class='ident'>handle</span>, + <span class='ident'>owned</span>: <span class='boolval'>true</span> + } + } + + <span class='kw'>fn</span> <span class='ident'>new_with_period</span>(<span class='ident'>period</span>: <span class='ident'>u64</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Asn1Time</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='ident'>ffi</span>::<span class='ident'>init</span>(); + + <span class='kw'>let</span> <span class='ident'>handle</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { + <span class='macro'>try_ssl_null</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>X509_gmtime_adj</span>(<span class='ident'>ptr</span>::<span class='ident'>null_mut</span>(), + <span class='ident'>period</span> <span class='kw'>as</span> <span class='ident'>c_long</span>)) + }; + <span class='prelude-val'>Ok</span>(<span class='ident'>Asn1Time</span>::<span class='ident'>new</span>(<span class='ident'>handle</span>)) + } + + <span class='doccomment'>/// Creates a new time on specified interval in days from now</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>days_from_now</span>(<span class='ident'>days</span>: <span class='ident'>u32</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Asn1Time</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='ident'>Asn1Time</span>::<span class='ident'>new_with_period</span>(<span class='ident'>days</span> <span class='kw'>as</span> <span class='ident'>u64</span> <span class='op'>*</span> <span class='number'>60</span> <span class='op'>*</span> <span class='number'>60</span> <span class='op'>*</span> <span class='number'>24</span>) + } + + <span class='doccomment'>/// Returns raw handle</span> + <span class='kw'>pub</span> <span class='kw'>unsafe</span> <span class='kw'>fn</span> <span class='ident'>get_handle</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>ASN1_TIME</span> { + <span class='kw'>return</span> <span class='self'>self</span>.<span class='ident'>handle</span> + } +} + +<span class='kw'>impl</span> <span class='ident'>Drop</span> <span class='kw'>for</span> <span class='ident'>Asn1Time</span> { + <span class='kw'>fn</span> <span class='ident'>drop</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>owned</span> { + <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>ASN1_TIME_free</span>(<span class='self'>self</span>.<span class='ident'>handle</span>) }; + } + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl"; + window.playgroundUrl = ""; + </script> + <script src="../../../jquery.js"></script> + <script src="../../../main.js"></script> + + <script async src="../../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl/bio/mod.rs.html b/src/openssl/bio/mod.rs.html new file mode 100644 index 0000000..0d8a555 --- /dev/null +++ b/src/openssl/bio/mod.rs.html @@ -0,0 +1,309 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-0.6.3/src/bio/mod.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>mod.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>libc</span>::{<span class='ident'>c_void</span>, <span class='ident'>c_int</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>::<span class='ident'>prelude</span>::<span class='op'>*</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ptr</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>cmp</span>; + +<span class='kw'>use</span> <span class='ident'>ffi</span>; +<span class='kw'>use</span> <span class='ident'>ssl</span>::<span class='ident'>error</span>::{<span class='ident'>SslError</span>}; + +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>MemBio</span> { + <span class='ident'>bio</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>BIO</span>, + <span class='ident'>owned</span>: <span class='ident'>bool</span> +} + +<span class='kw'>impl</span> <span class='ident'>Drop</span> <span class='kw'>for</span> <span class='ident'>MemBio</span> { + <span class='kw'>fn</span> <span class='ident'>drop</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>owned</span> { + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>BIO_free_all</span>(<span class='self'>self</span>.<span class='ident'>bio</span>); + } + } + } +} + +<span class='kw'>impl</span> <span class='ident'>MemBio</span> { + <span class='doccomment'>/// Creates a new owned memory based BIO</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>() <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>MemBio</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='ident'>ffi</span>::<span class='ident'>init</span>(); + + <span class='kw'>let</span> <span class='ident'>bio</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>BIO_new</span>(<span class='ident'>ffi</span>::<span class='ident'>BIO_s_mem</span>()) }; + <span class='macro'>try_ssl_null</span><span class='macro'>!</span>(<span class='ident'>bio</span>); + + <span class='prelude-val'>Ok</span>(<span class='ident'>MemBio</span> { + <span class='ident'>bio</span>: <span class='ident'>bio</span>, + <span class='ident'>owned</span>: <span class='boolval'>true</span> + }) + } + + <span class='doccomment'>/// Returns a "borrow", i.e. it has no ownership</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>borrowed</span>(<span class='ident'>bio</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>BIO</span>) <span class='op'>-></span> <span class='ident'>MemBio</span> { + <span class='ident'>MemBio</span> { + <span class='ident'>bio</span>: <span class='ident'>bio</span>, + <span class='ident'>owned</span>: <span class='boolval'>false</span> + } + } + + <span class='doccomment'>/// Consumes current bio and returns wrapped value</span> + <span class='doccomment'>/// Note that data ownership is lost and</span> + <span class='doccomment'>/// should be managed manually</span> + <span class='kw'>pub</span> <span class='kw'>unsafe</span> <span class='kw'>fn</span> <span class='ident'>unwrap</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>BIO</span> { + <span class='self'>self</span>.<span class='ident'>owned</span> <span class='op'>=</span> <span class='boolval'>false</span>; + <span class='self'>self</span>.<span class='ident'>bio</span> + } + + <span class='doccomment'>/// Temporarily gets wrapped value</span> + <span class='kw'>pub</span> <span class='kw'>unsafe</span> <span class='kw'>fn</span> <span class='ident'>get_handle</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>BIO</span> { + <span class='self'>self</span>.<span class='ident'>bio</span> + } + + <span class='doccomment'>/// Sets the BIO's EOF state.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_eof</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>eof</span>: <span class='ident'>bool</span>) { + <span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='ident'>eof</span> { <span class='number'>0</span> } <span class='kw'>else</span> { <span class='op'>-</span><span class='number'>1</span> }; + <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>BIO_set_mem_eof_return</span>(<span class='self'>self</span>.<span class='ident'>bio</span>, <span class='ident'>v</span>); } + } +} + +<span class='kw'>impl</span> <span class='ident'>Read</span> <span class='kw'>for</span> <span class='ident'>MemBio</span> { + <span class='kw'>fn</span> <span class='ident'>read</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>buf</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> [<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='ident'>cmp</span>::<span class='ident'>min</span>(<span class='ident'>c_int</span>::<span class='ident'>max_value</span>() <span class='kw'>as</span> <span class='ident'>usize</span>, <span class='ident'>buf</span>.<span class='ident'>len</span>()) <span class='kw'>as</span> <span class='ident'>c_int</span>; + <span class='kw'>let</span> <span class='ident'>ret</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>BIO_read</span>(<span class='self'>self</span>.<span class='ident'>bio</span>, <span class='ident'>buf</span>.<span class='ident'>as_ptr</span>() <span class='kw'>as</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>) + }; + + <span class='kw'>if</span> <span class='ident'>ret</span> <span class='op'><=</span> <span class='number'>0</span> { + <span class='kw'>let</span> <span class='ident'>is_eof</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>BIO_eof</span>(<span class='self'>self</span>.<span class='ident'>bio</span>) }; + <span class='kw'>if</span> <span class='ident'>is_eof</span> { + <span class='prelude-val'>Ok</span>(<span class='number'>0</span>) + } <span class='kw'>else</span> { + <span class='prelude-val'>Err</span>(<span class='ident'>io</span>::<span class='ident'>Error</span>::<span class='ident'>new</span>(<span class='ident'>io</span>::<span class='ident'>ErrorKind</span>::<span class='ident'>Other</span>, + <span class='ident'>SslError</span>::<span class='ident'>get</span>())) + } + } <span class='kw'>else</span> { + <span class='prelude-val'>Ok</span>(<span class='ident'>ret</span> <span class='kw'>as</span> <span class='ident'>usize</span>) + } + } +} + +<span class='kw'>impl</span> <span class='ident'>Write</span> <span class='kw'>for</span> <span class='ident'>MemBio</span> { + <span class='kw'>fn</span> <span class='ident'>write</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>buf</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='ident'>cmp</span>::<span class='ident'>min</span>(<span class='ident'>c_int</span>::<span class='ident'>max_value</span>() <span class='kw'>as</span> <span class='ident'>usize</span>, <span class='ident'>buf</span>.<span class='ident'>len</span>()) <span class='kw'>as</span> <span class='ident'>c_int</span>; + <span class='kw'>let</span> <span class='ident'>ret</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>BIO_write</span>(<span class='self'>self</span>.<span class='ident'>bio</span>, <span class='ident'>buf</span>.<span class='ident'>as_ptr</span>() <span class='kw'>as</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>) + }; + + <span class='kw'>if</span> <span class='ident'>ret</span> <span class='op'><</span> <span class='number'>0</span> { + <span class='prelude-val'>Err</span>(<span class='ident'>io</span>::<span class='ident'>Error</span>::<span class='ident'>new</span>(<span class='ident'>io</span>::<span class='ident'>ErrorKind</span>::<span class='ident'>Other</span>, + <span class='ident'>SslError</span>::<span class='ident'>get</span>())) + } <span class='kw'>else</span> { + <span class='prelude-val'>Ok</span>(<span class='ident'>ret</span> <span class='kw'>as</span> <span class='ident'>usize</span>) + } + } + + <span class='kw'>fn</span> <span class='ident'>flush</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='prelude-val'>Ok</span>(()) + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl"; + window.playgroundUrl = ""; + </script> + <script src="../../../jquery.js"></script> + <script src="../../../main.js"></script> + + <script async src="../../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl/bn/mod.rs.html b/src/openssl/bn/mod.rs.html new file mode 100644 index 0000000..f57f83e --- /dev/null +++ b/src/openssl/bn/mod.rs.html @@ -0,0 +1,1305 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-0.6.3/src/bn/mod.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>mod.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +<span id="313">313</span> +<span id="314">314</span> +<span id="315">315</span> +<span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +<span id="326">326</span> +<span id="327">327</span> +<span id="328">328</span> +<span id="329">329</span> +<span id="330">330</span> +<span id="331">331</span> +<span id="332">332</span> +<span id="333">333</span> +<span id="334">334</span> +<span id="335">335</span> +<span id="336">336</span> +<span id="337">337</span> +<span id="338">338</span> +<span id="339">339</span> +<span id="340">340</span> +<span id="341">341</span> +<span id="342">342</span> +<span id="343">343</span> +<span id="344">344</span> +<span id="345">345</span> +<span id="346">346</span> +<span id="347">347</span> +<span id="348">348</span> +<span id="349">349</span> +<span id="350">350</span> +<span id="351">351</span> +<span id="352">352</span> +<span id="353">353</span> +<span id="354">354</span> +<span id="355">355</span> +<span id="356">356</span> +<span id="357">357</span> +<span id="358">358</span> +<span id="359">359</span> +<span id="360">360</span> +<span id="361">361</span> +<span id="362">362</span> +<span id="363">363</span> +<span id="364">364</span> +<span id="365">365</span> +<span id="366">366</span> +<span id="367">367</span> +<span id="368">368</span> +<span id="369">369</span> +<span id="370">370</span> +<span id="371">371</span> +<span id="372">372</span> +<span id="373">373</span> +<span id="374">374</span> +<span id="375">375</span> +<span id="376">376</span> +<span id="377">377</span> +<span id="378">378</span> +<span id="379">379</span> +<span id="380">380</span> +<span id="381">381</span> +<span id="382">382</span> +<span id="383">383</span> +<span id="384">384</span> +<span id="385">385</span> +<span id="386">386</span> +<span id="387">387</span> +<span id="388">388</span> +<span id="389">389</span> +<span id="390">390</span> +<span id="391">391</span> +<span id="392">392</span> +<span id="393">393</span> +<span id="394">394</span> +<span id="395">395</span> +<span id="396">396</span> +<span id="397">397</span> +<span id="398">398</span> +<span id="399">399</span> +<span id="400">400</span> +<span id="401">401</span> +<span id="402">402</span> +<span id="403">403</span> +<span id="404">404</span> +<span id="405">405</span> +<span id="406">406</span> +<span id="407">407</span> +<span id="408">408</span> +<span id="409">409</span> +<span id="410">410</span> +<span id="411">411</span> +<span id="412">412</span> +<span id="413">413</span> +<span id="414">414</span> +<span id="415">415</span> +<span id="416">416</span> +<span id="417">417</span> +<span id="418">418</span> +<span id="419">419</span> +<span id="420">420</span> +<span id="421">421</span> +<span id="422">422</span> +<span id="423">423</span> +<span id="424">424</span> +<span id="425">425</span> +<span id="426">426</span> +<span id="427">427</span> +<span id="428">428</span> +<span id="429">429</span> +<span id="430">430</span> +<span id="431">431</span> +<span id="432">432</span> +<span id="433">433</span> +<span id="434">434</span> +<span id="435">435</span> +<span id="436">436</span> +<span id="437">437</span> +<span id="438">438</span> +<span id="439">439</span> +<span id="440">440</span> +<span id="441">441</span> +<span id="442">442</span> +<span id="443">443</span> +<span id="444">444</span> +<span id="445">445</span> +<span id="446">446</span> +<span id="447">447</span> +<span id="448">448</span> +<span id="449">449</span> +<span id="450">450</span> +<span id="451">451</span> +<span id="452">452</span> +<span id="453">453</span> +<span id="454">454</span> +<span id="455">455</span> +<span id="456">456</span> +<span id="457">457</span> +<span id="458">458</span> +<span id="459">459</span> +<span id="460">460</span> +<span id="461">461</span> +<span id="462">462</span> +<span id="463">463</span> +<span id="464">464</span> +<span id="465">465</span> +<span id="466">466</span> +<span id="467">467</span> +<span id="468">468</span> +<span id="469">469</span> +<span id="470">470</span> +<span id="471">471</span> +<span id="472">472</span> +<span id="473">473</span> +<span id="474">474</span> +<span id="475">475</span> +<span id="476">476</span> +<span id="477">477</span> +<span id="478">478</span> +<span id="479">479</span> +<span id="480">480</span> +<span id="481">481</span> +<span id="482">482</span> +<span id="483">483</span> +<span id="484">484</span> +<span id="485">485</span> +<span id="486">486</span> +<span id="487">487</span> +<span id="488">488</span> +<span id="489">489</span> +<span id="490">490</span> +<span id="491">491</span> +<span id="492">492</span> +<span id="493">493</span> +<span id="494">494</span> +<span id="495">495</span> +<span id="496">496</span> +<span id="497">497</span> +<span id="498">498</span> +<span id="499">499</span> +<span id="500">500</span> +<span id="501">501</span> +<span id="502">502</span> +<span id="503">503</span> +<span id="504">504</span> +<span id="505">505</span> +<span id="506">506</span> +<span id="507">507</span> +<span id="508">508</span> +<span id="509">509</span> +<span id="510">510</span> +<span id="511">511</span> +<span id="512">512</span> +<span id="513">513</span> +<span id="514">514</span> +<span id="515">515</span> +<span id="516">516</span> +<span id="517">517</span> +<span id="518">518</span> +<span id="519">519</span> +<span id="520">520</span> +<span id="521">521</span> +<span id="522">522</span> +<span id="523">523</span> +<span id="524">524</span> +<span id="525">525</span> +<span id="526">526</span> +<span id="527">527</span> +<span id="528">528</span> +<span id="529">529</span> +<span id="530">530</span> +<span id="531">531</span> +<span id="532">532</span> +<span id="533">533</span> +<span id="534">534</span> +<span id="535">535</span> +<span id="536">536</span> +<span id="537">537</span> +<span id="538">538</span> +<span id="539">539</span> +<span id="540">540</span> +<span id="541">541</span> +<span id="542">542</span> +<span id="543">543</span> +<span id="544">544</span> +<span id="545">545</span> +<span id="546">546</span> +<span id="547">547</span> +<span id="548">548</span> +<span id="549">549</span> +<span id="550">550</span> +<span id="551">551</span> +<span id="552">552</span> +<span id="553">553</span> +<span id="554">554</span> +<span id="555">555</span> +<span id="556">556</span> +<span id="557">557</span> +<span id="558">558</span> +<span id="559">559</span> +<span id="560">560</span> +<span id="561">561</span> +<span id="562">562</span> +<span id="563">563</span> +<span id="564">564</span> +<span id="565">565</span> +<span id="566">566</span> +<span id="567">567</span> +<span id="568">568</span> +<span id="569">569</span> +<span id="570">570</span> +<span id="571">571</span> +<span id="572">572</span> +<span id="573">573</span> +<span id="574">574</span> +<span id="575">575</span> +<span id="576">576</span> +<span id="577">577</span> +<span id="578">578</span> +<span id="579">579</span> +<span id="580">580</span> +<span id="581">581</span> +<span id="582">582</span> +<span id="583">583</span> +<span id="584">584</span> +<span id="585">585</span> +<span id="586">586</span> +<span id="587">587</span> +<span id="588">588</span> +<span id="589">589</span> +<span id="590">590</span> +<span id="591">591</span> +<span id="592">592</span> +<span id="593">593</span> +<span id="594">594</span> +<span id="595">595</span> +<span id="596">596</span> +<span id="597">597</span> +<span id="598">598</span> +<span id="599">599</span> +<span id="600">600</span> +<span id="601">601</span> +<span id="602">602</span> +<span id="603">603</span> +<span id="604">604</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>libc</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_ulong</span>, <span class='ident'>c_void</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ffi</span>::{<span class='ident'>CStr</span>, <span class='ident'>CString</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>cmp</span>::<span class='ident'>Ordering</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::{<span class='ident'>fmt</span>, <span class='ident'>ptr</span>}; + +<span class='kw'>use</span> <span class='ident'>ffi</span>; +<span class='kw'>use</span> <span class='ident'>ssl</span>::<span class='ident'>error</span>::<span class='ident'>SslError</span>; + +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>BigNum</span>(<span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>BIGNUM</span>); + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> +<span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>RNGProperty</span> { + <span class='ident'>MsbMaybeZero</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>1</span>, + <span class='ident'>MsbOne</span> <span class='op'>=</span> <span class='number'>0</span>, + <span class='ident'>TwoMsbOne</span> <span class='op'>=</span> <span class='number'>1</span>, +} + +<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>with_ctx</span>( + (<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>name</span>:<span class='ident'>ident</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>action</span>:<span class='ident'>block</span>) <span class='op'>=></span> ({ + <span class='kw'>let</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>name</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>BN_CTX_new</span>(); + <span class='kw'>if</span> (<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>name</span>).<span class='ident'>is_null</span>() { + <span class='prelude-val'>Err</span>(<span class='ident'>SslError</span>::<span class='ident'>get</span>()) + } <span class='kw'>else</span> { + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>action</span>; + <span class='ident'>ffi</span>::<span class='ident'>BN_CTX_free</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>name</span>); + <span class='ident'>r</span> + } + }); +); + +<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>with_bn</span>( + (<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>name</span>:<span class='ident'>ident</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>action</span>:<span class='ident'>block</span>) <span class='op'>=></span> ({ + <span class='kw'>let</span> <span class='ident'>tmp</span> <span class='op'>=</span> <span class='ident'>BigNum</span>::<span class='ident'>new</span>(); + <span class='kw'>match</span> <span class='ident'>tmp</span> { + <span class='prelude-val'>Ok</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>name</span>) <span class='op'>=></span> { + <span class='kw'>if</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>action</span> { + <span class='prelude-val'>Ok</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>name</span>) + } <span class='kw'>else</span> { + <span class='prelude-val'>Err</span>(<span class='ident'>SslError</span>::<span class='ident'>get</span>()) + } + }, + <span class='prelude-val'>Err</span>(<span class='ident'>err</span>) <span class='op'>=></span> <span class='prelude-val'>Err</span>(<span class='ident'>err</span>), + } + }); +); + +<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>with_bn_in_ctx</span>( + (<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>name</span>:<span class='ident'>ident</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>ctx_name</span>:<span class='ident'>ident</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>action</span>:<span class='ident'>block</span>) <span class='op'>=></span> ({ + <span class='kw'>let</span> <span class='ident'>tmp</span> <span class='op'>=</span> <span class='ident'>BigNum</span>::<span class='ident'>new</span>(); + <span class='kw'>match</span> <span class='ident'>tmp</span> { + <span class='prelude-val'>Ok</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>name</span>) <span class='op'>=></span> { + <span class='kw'>let</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>ctx_name</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>BN_CTX_new</span>(); + <span class='kw'>if</span> (<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>ctx_name</span>).<span class='ident'>is_null</span>() { + <span class='prelude-val'>Err</span>(<span class='ident'>SslError</span>::<span class='ident'>get</span>()) + } <span class='kw'>else</span> { + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> + <span class='kw'>if</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>action</span> { + <span class='prelude-val'>Ok</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>name</span>) + } <span class='kw'>else</span> { + <span class='prelude-val'>Err</span>(<span class='ident'>SslError</span>::<span class='ident'>get</span>()) + }; + <span class='ident'>ffi</span>::<span class='ident'>BN_CTX_free</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>ctx_name</span>); + <span class='ident'>r</span> + } + }, + <span class='prelude-val'>Err</span>(<span class='ident'>err</span>) <span class='op'>=></span> <span class='prelude-val'>Err</span>(<span class='ident'>err</span>), + } + }); +); + +<span class='kw'>impl</span> <span class='ident'>BigNum</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>() <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>init</span>(); + + <span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='macro'>try_ssl_null</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>BN_new</span>()); + <span class='prelude-val'>Ok</span>(<span class='ident'>BigNum</span>(<span class='ident'>v</span>)) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new_from</span>(<span class='ident'>n</span>: <span class='ident'>u64</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='ident'>BigNum</span>::<span class='ident'>new</span>().<span class='ident'>and_then</span>(<span class='op'>|</span><span class='ident'>v</span><span class='op'>|</span> <span class='kw'>unsafe</span> { + <span class='macro'>try_ssl</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>BN_set_word</span>(<span class='ident'>v</span>.<span class='ident'>raw</span>(), <span class='ident'>n</span> <span class='kw'>as</span> <span class='ident'>c_ulong</span>)); + <span class='prelude-val'>Ok</span>(<span class='ident'>v</span>) + }) + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>from_dec_str</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='ident'>BigNum</span>::<span class='ident'>new</span>().<span class='ident'>and_then</span>(<span class='op'>|</span><span class='ident'>v</span><span class='op'>|</span> <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>c_str</span> <span class='op'>=</span> <span class='ident'>CString</span>::<span class='ident'>new</span>(<span class='ident'>s</span>.<span class='ident'>as_bytes</span>()).<span class='ident'>unwrap</span>(); + <span class='macro'>try_ssl</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>BN_dec2bn</span>(<span class='ident'>v</span>.<span class='ident'>raw_ptr</span>(), <span class='ident'>c_str</span>.<span class='ident'>as_ptr</span>())); + <span class='prelude-val'>Ok</span>(<span class='ident'>v</span>) + }) + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>from_hex_str</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='ident'>BigNum</span>::<span class='ident'>new</span>().<span class='ident'>and_then</span>(<span class='op'>|</span><span class='ident'>v</span><span class='op'>|</span> <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>c_str</span> <span class='op'>=</span> <span class='ident'>CString</span>::<span class='ident'>new</span>(<span class='ident'>s</span>.<span class='ident'>as_bytes</span>()).<span class='ident'>unwrap</span>(); + <span class='macro'>try_ssl</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>BN_hex2bn</span>(<span class='ident'>v</span>.<span class='ident'>raw_ptr</span>(), <span class='ident'>c_str</span>.<span class='ident'>as_ptr</span>())); + <span class='prelude-val'>Ok</span>(<span class='ident'>v</span>) + }) + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new_from_slice</span>(<span class='ident'>n</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='ident'>BigNum</span>::<span class='ident'>new</span>().<span class='ident'>and_then</span>(<span class='op'>|</span><span class='ident'>v</span><span class='op'>|</span> <span class='kw'>unsafe</span> { + <span class='macro'>try_ssl_null</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>BN_bin2bn</span>(<span class='ident'>n</span>.<span class='ident'>as_ptr</span>(), <span class='ident'>n</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>c_int</span>, <span class='ident'>v</span>.<span class='ident'>raw</span>())); + <span class='prelude-val'>Ok</span>(<span class='ident'>v</span>) + }) + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_sqr</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_sqr</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>ctx</span>) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_nnmod</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>n</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_nnmod</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>n</span>.<span class='ident'>raw</span>(), <span class='ident'>ctx</span>) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_mod_add</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>a</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>, <span class='ident'>n</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_mod_add</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>a</span>.<span class='ident'>raw</span>(), <span class='ident'>n</span>.<span class='ident'>raw</span>(), <span class='ident'>ctx</span>) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_mod_sub</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>a</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>, <span class='ident'>n</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_mod_sub</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>a</span>.<span class='ident'>raw</span>(), <span class='ident'>n</span>.<span class='ident'>raw</span>(), <span class='ident'>ctx</span>) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_mod_mul</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>a</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>, <span class='ident'>n</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_mod_mul</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>a</span>.<span class='ident'>raw</span>(), <span class='ident'>n</span>.<span class='ident'>raw</span>(), <span class='ident'>ctx</span>) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_mod_sqr</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>n</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_mod_sqr</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>n</span>.<span class='ident'>raw</span>(), <span class='ident'>ctx</span>) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_exp</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>p</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_exp</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>p</span>.<span class='ident'>raw</span>(), <span class='ident'>ctx</span>) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_mod_exp</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>p</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>, <span class='ident'>n</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_mod_exp</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>p</span>.<span class='ident'>raw</span>(), <span class='ident'>n</span>.<span class='ident'>raw</span>(), <span class='ident'>ctx</span>) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_mod_inv</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>n</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { <span class='op'>!</span><span class='ident'>ffi</span>::<span class='ident'>BN_mod_inverse</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>n</span>.<span class='ident'>raw</span>(), <span class='ident'>ctx</span>).<span class='ident'>is_null</span>() }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>add_word</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>w</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(), <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>if</span> <span class='ident'>ffi</span>::<span class='ident'>BN_add_word</span>(<span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>w</span>) <span class='op'>==</span> <span class='number'>1</span> { + <span class='prelude-val'>Ok</span>(()) + } <span class='kw'>else</span> { + <span class='prelude-val'>Err</span>(<span class='ident'>SslError</span>::<span class='ident'>get</span>()) + } + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>sub_word</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>w</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(), <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>if</span> <span class='ident'>ffi</span>::<span class='ident'>BN_sub_word</span>(<span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>w</span>) <span class='op'>==</span> <span class='number'>1</span> { + <span class='prelude-val'>Ok</span>(()) + } <span class='kw'>else</span> { + <span class='prelude-val'>Err</span>(<span class='ident'>SslError</span>::<span class='ident'>get</span>()) + } + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mul_word</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>w</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(), <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>if</span> <span class='ident'>ffi</span>::<span class='ident'>BN_mul_word</span>(<span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>w</span>) <span class='op'>==</span> <span class='number'>1</span> { + <span class='prelude-val'>Ok</span>(()) + } <span class='kw'>else</span> { + <span class='prelude-val'>Err</span>(<span class='ident'>SslError</span>::<span class='ident'>get</span>()) + } + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>div_word</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>w</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>c_ulong</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>result</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>BN_div_word</span>(<span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>w</span>); + <span class='kw'>if</span> <span class='ident'>result</span> <span class='op'>!=</span> <span class='op'>!</span><span class='number'>0</span> <span class='kw'>as</span> <span class='ident'>c_ulong</span> { + <span class='prelude-val'>Ok</span>(<span class='ident'>result</span>) + } <span class='kw'>else</span> { + <span class='prelude-val'>Err</span>(<span class='ident'>SslError</span>::<span class='ident'>get</span>()) + } + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mod_word</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>w</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>c_ulong</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>result</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>BN_mod_word</span>(<span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>w</span>); + <span class='kw'>if</span> <span class='ident'>result</span> <span class='op'>!=</span> <span class='op'>!</span><span class='number'>0</span> <span class='kw'>as</span> <span class='ident'>c_ulong</span> { + <span class='prelude-val'>Ok</span>(<span class='ident'>result</span>) + } <span class='kw'>else</span> { + <span class='prelude-val'>Err</span>(<span class='ident'>SslError</span>::<span class='ident'>get</span>()) + } + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_gcd</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>a</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_gcd</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>a</span>.<span class='ident'>raw</span>(), <span class='ident'>ctx</span>) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_generate_prime</span>(<span class='ident'>bits</span>: <span class='ident'>i32</span>, <span class='ident'>safe</span>: <span class='ident'>bool</span>, <span class='ident'>add</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='ident'>BigNum</span><span class='op'>></span>, <span class='ident'>rem</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='ident'>BigNum</span><span class='op'>></span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { + <span class='kw'>let</span> <span class='ident'>add_arg</span> <span class='op'>=</span> <span class='ident'>add</span>.<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>a</span><span class='op'>|</span> <span class='ident'>a</span>.<span class='ident'>raw</span>()).<span class='ident'>unwrap_or</span>(<span class='ident'>ptr</span>::<span class='ident'>null_mut</span>()); + <span class='kw'>let</span> <span class='ident'>rem_arg</span> <span class='op'>=</span> <span class='ident'>rem</span>.<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>r</span><span class='op'>|</span> <span class='ident'>r</span>.<span class='ident'>raw</span>()).<span class='ident'>unwrap_or</span>(<span class='ident'>ptr</span>::<span class='ident'>null_mut</span>()); + + <span class='ident'>ffi</span>::<span class='ident'>BN_generate_prime_ex</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='ident'>bits</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, <span class='ident'>safe</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, <span class='ident'>add_arg</span>, <span class='ident'>rem_arg</span>, <span class='ident'>ptr</span>::<span class='ident'>null</span>()) <span class='op'>==</span> <span class='number'>1</span> + }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_prime</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>checks</span>: <span class='ident'>i32</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>bool</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_ctx</span><span class='macro'>!</span>(<span class='ident'>ctx</span>, { + <span class='prelude-val'>Ok</span>(<span class='ident'>ffi</span>::<span class='ident'>BN_is_prime_ex</span>(<span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>checks</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, <span class='ident'>ctx</span>, <span class='ident'>ptr</span>::<span class='ident'>null</span>()) <span class='op'>==</span> <span class='number'>1</span>) + }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_prime_fast</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>checks</span>: <span class='ident'>i32</span>, <span class='ident'>do_trial_division</span>: <span class='ident'>bool</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>bool</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_ctx</span><span class='macro'>!</span>(<span class='ident'>ctx</span>, { + <span class='prelude-val'>Ok</span>(<span class='ident'>ffi</span>::<span class='ident'>BN_is_prime_fasttest_ex</span>(<span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>checks</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, <span class='ident'>ctx</span>, <span class='ident'>do_trial_division</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, <span class='ident'>ptr</span>::<span class='ident'>null</span>()) <span class='op'>==</span> <span class='number'>1</span>) + }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_new_random</span>(<span class='ident'>bits</span>: <span class='ident'>i32</span>, <span class='ident'>prop</span>: <span class='ident'>RNGProperty</span>, <span class='ident'>odd</span>: <span class='ident'>bool</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_rand</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='ident'>bits</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, <span class='ident'>prop</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, <span class='ident'>odd</span> <span class='kw'>as</span> <span class='ident'>c_int</span>) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_new_pseudo_random</span>(<span class='ident'>bits</span>: <span class='ident'>i32</span>, <span class='ident'>prop</span>: <span class='ident'>RNGProperty</span>, <span class='ident'>odd</span>: <span class='ident'>bool</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_pseudo_rand</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='ident'>bits</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, <span class='ident'>prop</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, <span class='ident'>odd</span> <span class='kw'>as</span> <span class='ident'>c_int</span>) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_rand_in_range</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_rand_range</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>()) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_pseudo_rand_in_range</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_pseudo_rand_range</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>()) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_bit</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>n</span>: <span class='ident'>i32</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(), <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>if</span> <span class='ident'>ffi</span>::<span class='ident'>BN_set_bit</span>(<span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>n</span> <span class='kw'>as</span> <span class='ident'>c_int</span>) <span class='op'>==</span> <span class='number'>1</span> { + <span class='prelude-val'>Ok</span>(()) + } <span class='kw'>else</span> { + <span class='prelude-val'>Err</span>(<span class='ident'>SslError</span>::<span class='ident'>get</span>()) + } + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>clear_bit</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>n</span>: <span class='ident'>i32</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(), <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>if</span> <span class='ident'>ffi</span>::<span class='ident'>BN_clear_bit</span>(<span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>n</span> <span class='kw'>as</span> <span class='ident'>c_int</span>) <span class='op'>==</span> <span class='number'>1</span> { + <span class='prelude-val'>Ok</span>(()) + } <span class='kw'>else</span> { + <span class='prelude-val'>Err</span>(<span class='ident'>SslError</span>::<span class='ident'>get</span>()) + } + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_bit_set</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>n</span>: <span class='ident'>i32</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>BN_is_bit_set</span>(<span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>n</span> <span class='kw'>as</span> <span class='ident'>c_int</span>) <span class='op'>==</span> <span class='number'>1</span> + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mask_bits</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>n</span>: <span class='ident'>i32</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(), <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>if</span> <span class='ident'>ffi</span>::<span class='ident'>BN_mask_bits</span>(<span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>n</span> <span class='kw'>as</span> <span class='ident'>c_int</span>) <span class='op'>==</span> <span class='number'>1</span> { + <span class='prelude-val'>Ok</span>(()) + } <span class='kw'>else</span> { + <span class='prelude-val'>Err</span>(<span class='ident'>SslError</span>::<span class='ident'>get</span>()) + } + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_shl1</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn</span><span class='macro'>!</span>(<span class='ident'>r</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_lshift1</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>()) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_shr1</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn</span><span class='macro'>!</span>(<span class='ident'>r</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_rshift1</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>()) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_add</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>a</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn</span><span class='macro'>!</span>(<span class='ident'>r</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_add</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>a</span>.<span class='ident'>raw</span>()) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_sub</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>a</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn</span><span class='macro'>!</span>(<span class='ident'>r</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_sub</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>a</span>.<span class='ident'>raw</span>()) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_mul</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>a</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_mul</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>a</span>.<span class='ident'>raw</span>(), <span class='ident'>ctx</span>) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_div</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>a</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_div</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>a</span>.<span class='ident'>raw</span>(), <span class='ident'>ctx</span>) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_mod</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>a</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn_in_ctx</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='ident'>ctx</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_div</span>(<span class='ident'>ptr</span>::<span class='ident'>null_mut</span>(), <span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>a</span>.<span class='ident'>raw</span>(), <span class='ident'>ctx</span>) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_shl</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>a</span>: <span class='kw-2'>&</span><span class='ident'>i32</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn</span><span class='macro'>!</span>(<span class='ident'>r</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_lshift</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='op'>*</span><span class='ident'>a</span> <span class='kw'>as</span> <span class='ident'>c_int</span>) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>checked_shr</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>a</span>: <span class='kw-2'>&</span><span class='ident'>i32</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>BigNum</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>with_bn</span><span class='macro'>!</span>(<span class='ident'>r</span>, { <span class='ident'>ffi</span>::<span class='ident'>BN_rshift</span>(<span class='ident'>r</span>.<span class='ident'>raw</span>(), <span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='op'>*</span><span class='ident'>a</span> <span class='kw'>as</span> <span class='ident'>c_int</span>) <span class='op'>==</span> <span class='number'>1</span> }) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>negate</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>BN_set_negative</span>(<span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>is_negative</span>() <span class='kw'>as</span> <span class='ident'>c_int</span>) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>abs_cmp</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>oth</span>: <span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='ident'>Ordering</span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>BN_ucmp</span>(<span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>oth</span>.<span class='ident'>raw</span>()) <span class='kw'>as</span> <span class='ident'>i32</span>; + <span class='kw'>if</span> <span class='ident'>res</span> <span class='op'><</span> <span class='number'>0</span> { + <span class='ident'>Ordering</span>::<span class='ident'>Less</span> + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>res</span> <span class='op'>></span> <span class='number'>0</span> { + <span class='ident'>Ordering</span>::<span class='ident'>Greater</span> + } <span class='kw'>else</span> { + <span class='ident'>Ordering</span>::<span class='ident'>Equal</span> + } + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_negative</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>unsafe</span> { + (<span class='op'>*</span><span class='self'>self</span>.<span class='ident'>raw</span>()).<span class='ident'>neg</span> <span class='op'>==</span> <span class='number'>1</span> + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>num_bits</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>i32</span> { + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>BN_num_bits</span>(<span class='self'>self</span>.<span class='ident'>raw</span>()) <span class='kw'>as</span> <span class='ident'>i32</span> + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>num_bytes</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>i32</span> { + (<span class='self'>self</span>.<span class='ident'>num_bits</span>() <span class='op'>+</span> <span class='number'>7</span>) <span class='op'>/</span> <span class='number'>8</span> + } + + <span class='kw'>unsafe</span> <span class='kw'>fn</span> <span class='ident'>raw</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>BIGNUM</span> { + <span class='kw'>let</span> <span class='ident'>BigNum</span>(<span class='ident'>n</span>) <span class='op'>=</span> <span class='op'>*</span><span class='self'>self</span>; + <span class='ident'>n</span> + } + + <span class='kw'>unsafe</span> <span class='kw'>fn</span> <span class='ident'>raw_ptr</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>BIGNUM</span> { + <span class='kw'>let</span> <span class='ident'>BigNum</span>(<span class='kw-2'>ref</span> <span class='ident'>n</span>) <span class='op'>=</span> <span class='op'>*</span><span class='self'>self</span>; + <span class='ident'>n</span> + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>to_vec</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>size</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>num_bytes</span>() <span class='kw'>as</span> <span class='ident'>usize</span>; + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='ident'>Vec</span>::<span class='ident'>with_capacity</span>(<span class='ident'>size</span>); + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>BN_bn2bin</span>(<span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>v</span>.<span class='ident'>as_mut_ptr</span>()); + <span class='ident'>v</span>.<span class='ident'>set_len</span>(<span class='ident'>size</span>); + } + <span class='ident'>v</span> + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>to_dec_str</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>buf</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>BN_bn2dec</span>(<span class='self'>self</span>.<span class='ident'>raw</span>()); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>buf</span>.<span class='ident'>is_null</span>()); + <span class='kw'>let</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from_utf8</span>(<span class='ident'>CStr</span>::<span class='ident'>from_ptr</span>(<span class='ident'>buf</span>).<span class='ident'>to_bytes</span>().<span class='ident'>to_vec</span>()).<span class='ident'>unwrap</span>(); + <span class='ident'>ffi</span>::<span class='ident'>CRYPTO_free</span>(<span class='ident'>buf</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>); + <span class='ident'>str</span> + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>to_hex_str</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>buf</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>BN_bn2hex</span>(<span class='self'>self</span>.<span class='ident'>raw</span>()); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>buf</span>.<span class='ident'>is_null</span>()); + <span class='kw'>let</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from_utf8</span>(<span class='ident'>CStr</span>::<span class='ident'>from_ptr</span>(<span class='ident'>buf</span>).<span class='ident'>to_bytes</span>().<span class='ident'>to_vec</span>()).<span class='ident'>unwrap</span>(); + <span class='ident'>ffi</span>::<span class='ident'>CRYPTO_free</span>(<span class='ident'>buf</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>); + <span class='ident'>str</span> + } + } +} + +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Debug</span> <span class='kw'>for</span> <span class='ident'>BigNum</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"{}"</span>, <span class='self'>self</span>.<span class='ident'>to_dec_str</span>()) + } +} + +<span class='kw'>impl</span> <span class='ident'>Eq</span> <span class='kw'>for</span> <span class='ident'>BigNum</span> { } +<span class='kw'>impl</span> <span class='ident'>PartialEq</span> <span class='kw'>for</span> <span class='ident'>BigNum</span> { + <span class='kw'>fn</span> <span class='ident'>eq</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>oth</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>BN_cmp</span>(<span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>oth</span>.<span class='ident'>raw</span>()) <span class='op'>==</span> <span class='number'>0</span> + } + } +} + +<span class='kw'>impl</span> <span class='ident'>Ord</span> <span class='kw'>for</span> <span class='ident'>BigNum</span> { + <span class='kw'>fn</span> <span class='ident'>cmp</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>oth</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='ident'>Ordering</span> { + <span class='self'>self</span>.<span class='ident'>partial_cmp</span>(<span class='ident'>oth</span>).<span class='ident'>unwrap</span>() + } +} + +<span class='kw'>impl</span> <span class='ident'>PartialOrd</span> <span class='kw'>for</span> <span class='ident'>BigNum</span> { + <span class='kw'>fn</span> <span class='ident'>partial_cmp</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>oth</span>: <span class='kw-2'>&</span><span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Ordering</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>BN_cmp</span>(<span class='self'>self</span>.<span class='ident'>raw</span>(), <span class='ident'>oth</span>.<span class='ident'>raw</span>()); + <span class='kw'>let</span> <span class='ident'>ret</span> <span class='op'>=</span> + <span class='kw'>if</span> <span class='ident'>v</span> <span class='op'>==</span> <span class='number'>0</span> { + <span class='ident'>Ordering</span>::<span class='ident'>Equal</span> + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>v</span> <span class='op'><</span> <span class='number'>0</span> { + <span class='ident'>Ordering</span>::<span class='ident'>Less</span> + } <span class='kw'>else</span> { + <span class='ident'>Ordering</span>::<span class='ident'>Greater</span> + }; + <span class='prelude-val'>Some</span>(<span class='ident'>ret</span>) + } + } +} + +<span class='kw'>impl</span> <span class='ident'>Drop</span> <span class='kw'>for</span> <span class='ident'>BigNum</span> { + <span class='kw'>fn</span> <span class='ident'>drop</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>unsafe</span> { + <span class='kw'>if</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>raw</span>().<span class='ident'>is_null</span>() { + <span class='ident'>ffi</span>::<span class='ident'>BN_clear_free</span>(<span class='self'>self</span>.<span class='ident'>raw</span>()); + } + } + } +} + +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>unchecked</span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ops</span>::{<span class='ident'>Add</span>, <span class='ident'>Div</span>, <span class='ident'>Mul</span>, <span class='ident'>Neg</span>, <span class='ident'>Rem</span>, <span class='ident'>Shl</span>, <span class='ident'>Shr</span>, <span class='ident'>Sub</span>}; + <span class='kw'>use</span> <span class='ident'>ffi</span>; + <span class='kw'>use</span> <span class='ident'>super</span>::{<span class='ident'>BigNum</span>}; + + <span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>Add</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>BigNum</span><span class='op'>></span> <span class='kw'>for</span> <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>BigNum</span> { + <span class='kw'>type</span> <span class='ident'>Output</span> <span class='op'>=</span> <span class='ident'>BigNum</span>; + + <span class='kw'>fn</span> <span class='ident'>add</span>(<span class='self'>self</span>, <span class='ident'>oth</span>: <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='ident'>BigNum</span> { + <span class='self'>self</span>.<span class='ident'>checked_add</span>(<span class='ident'>oth</span>).<span class='ident'>unwrap</span>() + } + } + + <span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>Sub</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>BigNum</span><span class='op'>></span> <span class='kw'>for</span> <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>BigNum</span> { + <span class='kw'>type</span> <span class='ident'>Output</span> <span class='op'>=</span> <span class='ident'>BigNum</span>; + + <span class='kw'>fn</span> <span class='ident'>sub</span>(<span class='self'>self</span>, <span class='ident'>oth</span>: <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='ident'>BigNum</span> { + <span class='self'>self</span>.<span class='ident'>checked_sub</span>(<span class='ident'>oth</span>).<span class='ident'>unwrap</span>() + } + } + + <span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>Mul</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>BigNum</span><span class='op'>></span> <span class='kw'>for</span> <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>BigNum</span> { + <span class='kw'>type</span> <span class='ident'>Output</span> <span class='op'>=</span> <span class='ident'>BigNum</span>; + + <span class='kw'>fn</span> <span class='ident'>mul</span>(<span class='self'>self</span>, <span class='ident'>oth</span>: <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='ident'>BigNum</span> { + <span class='self'>self</span>.<span class='ident'>checked_mul</span>(<span class='ident'>oth</span>).<span class='ident'>unwrap</span>() + } + } + + <span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>Div</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>BigNum</span><span class='op'>></span> <span class='kw'>for</span> <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>BigNum</span> { + <span class='kw'>type</span> <span class='ident'>Output</span> <span class='op'>=</span> <span class='ident'>BigNum</span>; + + <span class='kw'>fn</span> <span class='ident'>div</span>(<span class='self'>self</span>, <span class='ident'>oth</span>: <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='ident'>BigNum</span> { + <span class='self'>self</span>.<span class='ident'>checked_div</span>(<span class='ident'>oth</span>).<span class='ident'>unwrap</span>() + } + } + + <span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>Rem</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>BigNum</span><span class='op'>></span> <span class='kw'>for</span> <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>BigNum</span> { + <span class='kw'>type</span> <span class='ident'>Output</span> <span class='op'>=</span> <span class='ident'>BigNum</span>; + + <span class='kw'>fn</span> <span class='ident'>rem</span>(<span class='self'>self</span>, <span class='ident'>oth</span>: <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>BigNum</span>) <span class='op'>-></span> <span class='ident'>BigNum</span> { + <span class='self'>self</span>.<span class='ident'>checked_mod</span>(<span class='ident'>oth</span>).<span class='ident'>unwrap</span>() + } + } + + <span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>Shl</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span> <span class='kw'>for</span> <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>BigNum</span> { + <span class='kw'>type</span> <span class='ident'>Output</span> <span class='op'>=</span> <span class='ident'>BigNum</span>; + + <span class='kw'>fn</span> <span class='ident'>shl</span>(<span class='self'>self</span>, <span class='ident'>n</span>: <span class='ident'>i32</span>) <span class='op'>-></span> <span class='ident'>BigNum</span> { + <span class='self'>self</span>.<span class='ident'>checked_shl</span>(<span class='kw-2'>&</span><span class='ident'>n</span>).<span class='ident'>unwrap</span>() + } + } + + <span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>Shr</span><span class='op'><</span><span class='ident'>i32</span><span class='op'>></span> <span class='kw'>for</span> <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>BigNum</span> { + <span class='kw'>type</span> <span class='ident'>Output</span> <span class='op'>=</span> <span class='ident'>BigNum</span>; + + <span class='kw'>fn</span> <span class='ident'>shr</span>(<span class='self'>self</span>, <span class='ident'>n</span>: <span class='ident'>i32</span>) <span class='op'>-></span> <span class='ident'>BigNum</span> { + <span class='self'>self</span>.<span class='ident'>checked_shr</span>(<span class='kw-2'>&</span><span class='ident'>n</span>).<span class='ident'>unwrap</span>() + } + } + + <span class='kw'>impl</span> <span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>BigNum</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>BigNum</span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>BN_dup</span>(<span class='self'>self</span>.<span class='ident'>raw</span>()); + <span class='kw'>if</span> <span class='ident'>r</span>.<span class='ident'>is_null</span>() { + <span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>"Unexpected null pointer from BN_dup(..)"</span>) + } <span class='kw'>else</span> { + <span class='ident'>BigNum</span>(<span class='ident'>r</span>) + } + } + } + } + + <span class='kw'>impl</span> <span class='ident'>Neg</span> <span class='kw'>for</span> <span class='ident'>BigNum</span> { + <span class='kw'>type</span> <span class='ident'>Output</span> <span class='op'>=</span> <span class='ident'>BigNum</span>; + + <span class='kw'>fn</span> <span class='ident'>neg</span>(<span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>BigNum</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>n</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>clone</span>(); + <span class='ident'>n</span>.<span class='ident'>negate</span>(); + <span class='ident'>n</span> + } + } +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>tests</span> { + <span class='kw'>use</span> <span class='ident'>bn</span>::<span class='ident'>BigNum</span>; + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_to_from_slice</span>() { + <span class='kw'>let</span> <span class='ident'>v0</span> <span class='op'>=</span> <span class='ident'>BigNum</span>::<span class='ident'>new_from</span>(<span class='number'>10203004_u64</span>).<span class='ident'>unwrap</span>(); + <span class='kw'>let</span> <span class='ident'>vec</span> <span class='op'>=</span> <span class='ident'>v0</span>.<span class='ident'>to_vec</span>(); + <span class='kw'>let</span> <span class='ident'>v1</span> <span class='op'>=</span> <span class='ident'>BigNum</span>::<span class='ident'>new_from_slice</span>(<span class='kw-2'>&</span><span class='ident'>vec</span>).<span class='ident'>unwrap</span>(); + + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>v0</span> <span class='op'>==</span> <span class='ident'>v1</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_negation</span>() { + <span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>BigNum</span>::<span class='ident'>new_from</span>(<span class='number'>909829283_u64</span>).<span class='ident'>unwrap</span>(); + + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>a</span>.<span class='ident'>is_negative</span>()); + <span class='macro'>assert</span><span class='macro'>!</span>((<span class='op'>-</span><span class='ident'>a</span>).<span class='ident'>is_negative</span>()); + } + + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_prime_numbers</span>() { + <span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>BigNum</span>::<span class='ident'>new_from</span>(<span class='number'>19029017_u64</span>).<span class='ident'>unwrap</span>(); + <span class='kw'>let</span> <span class='ident'>p</span> <span class='op'>=</span> <span class='ident'>BigNum</span>::<span class='ident'>checked_generate_prime</span>(<span class='number'>128</span>, <span class='boolval'>true</span>, <span class='prelude-val'>None</span>, <span class='prelude-val'>Some</span>(<span class='kw-2'>&</span><span class='ident'>a</span>)).<span class='ident'>unwrap</span>(); + + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>p</span>.<span class='ident'>is_prime</span>(<span class='number'>100</span>).<span class='ident'>unwrap</span>()); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>p</span>.<span class='ident'>is_prime_fast</span>(<span class='number'>100</span>, <span class='boolval'>true</span>).<span class='ident'>unwrap</span>()); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl"; + window.playgroundUrl = ""; + </script> + <script src="../../../jquery.js"></script> + <script src="../../../main.js"></script> + + <script async src="../../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl/crypto/hash.rs.html b/src/openssl/crypto/hash.rs.html new file mode 100644 index 0000000..3acc27b --- /dev/null +++ b/src/openssl/crypto/hash.rs.html @@ -0,0 +1,773 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-0.6.3/src/crypto/hash.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>hash.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +<span id="313">313</span> +<span id="314">314</span> +<span id="315">315</span> +<span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +<span id="326">326</span> +<span id="327">327</span> +<span id="328">328</span> +<span id="329">329</span> +<span id="330">330</span> +<span id="331">331</span> +<span id="332">332</span> +<span id="333">333</span> +<span id="334">334</span> +<span id="335">335</span> +<span id="336">336</span> +<span id="337">337</span> +<span id="338">338</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>libc</span>::<span class='ident'>c_uint</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>iter</span>::<span class='ident'>repeat</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>::<span class='ident'>prelude</span>::<span class='op'>*</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>; + +<span class='kw'>use</span> <span class='ident'>ffi</span>; + +<span class='doccomment'>/// Message digest (hash) type.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Type</span> { + <span class='ident'>MD5</span>, + <span class='ident'>SHA1</span>, + <span class='ident'>SHA224</span>, + <span class='ident'>SHA256</span>, + <span class='ident'>SHA384</span>, + <span class='ident'>SHA512</span>, + <span class='ident'>RIPEMD160</span> +} + +<span class='kw'>impl</span> <span class='ident'>Type</span> { + <span class='doccomment'>/// Returns the length of the message digest.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>md_len</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>Type</span>::<span class='op'>*</span>; + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>MD5</span> <span class='op'>=></span> <span class='number'>16</span>, + <span class='ident'>SHA1</span> <span class='op'>=></span> <span class='number'>20</span>, + <span class='ident'>SHA224</span> <span class='op'>=></span> <span class='number'>28</span>, + <span class='ident'>SHA256</span> <span class='op'>=></span> <span class='number'>32</span>, + <span class='ident'>SHA384</span> <span class='op'>=></span> <span class='number'>48</span>, + <span class='ident'>SHA512</span> <span class='op'>=></span> <span class='number'>64</span>, + <span class='ident'>RIPEMD160</span> <span class='op'>=></span> <span class='number'>20</span>, + } + } + + <span class='doccomment'>/// Internal interface subject to removal.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>evp_md</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_MD</span> { + <span class='kw'>unsafe</span> { + <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>Type</span>::<span class='op'>*</span>; + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>MD5</span> <span class='op'>=></span> <span class='ident'>ffi</span>::<span class='ident'>EVP_md5</span>(), + <span class='ident'>SHA1</span> <span class='op'>=></span> <span class='ident'>ffi</span>::<span class='ident'>EVP_sha1</span>(), + <span class='ident'>SHA224</span> <span class='op'>=></span> <span class='ident'>ffi</span>::<span class='ident'>EVP_sha224</span>(), + <span class='ident'>SHA256</span> <span class='op'>=></span> <span class='ident'>ffi</span>::<span class='ident'>EVP_sha256</span>(), + <span class='ident'>SHA384</span> <span class='op'>=></span> <span class='ident'>ffi</span>::<span class='ident'>EVP_sha384</span>(), + <span class='ident'>SHA512</span> <span class='op'>=></span> <span class='ident'>ffi</span>::<span class='ident'>EVP_sha512</span>(), + <span class='ident'>RIPEMD160</span> <span class='op'>=></span> <span class='ident'>ffi</span>::<span class='ident'>EVP_ripemd160</span>(), + } + } + } +} + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>PartialEq</span>, <span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> +<span class='kw'>enum</span> <span class='ident'>State</span> { + <span class='ident'>Reset</span>, + <span class='ident'>Updated</span>, + <span class='ident'>Finalized</span>, +} + +<span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>State</span>::<span class='op'>*</span>; + +<span class='doccomment'>/// Provides message digest (hash) computation.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Examples</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Calculate a hash in one go.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ```</span> +<span class='doccomment'>/// use openssl::crypto::hash::{hash, Type};</span> +<span class='doccomment'>/// let data = b"\x42\xF4\x97\xE0";</span> +<span class='doccomment'>/// let spec = b"\x7c\x43\x0f\x17\x8a\xef\xdf\x14\x87\xfe\xe7\x14\x4e\x96\x41\xe2";</span> +<span class='doccomment'>/// let res = hash(Type::MD5, data);</span> +<span class='doccomment'>/// assert_eq!(res, spec);</span> +<span class='doccomment'>/// ```</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Use the `Write` trait to supply the input in chunks.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ```</span> +<span class='doccomment'>/// use std::io::prelude::*;</span> +<span class='doccomment'>/// use openssl::crypto::hash::{Hasher, Type};</span> +<span class='doccomment'>/// let data = [b"\x42\xF4", b"\x97\xE0"];</span> +<span class='doccomment'>/// let spec = b"\x7c\x43\x0f\x17\x8a\xef\xdf\x14\x87\xfe\xe7\x14\x4e\x96\x41\xe2";</span> +<span class='doccomment'>/// let mut h = Hasher::new(Type::MD5);</span> +<span class='doccomment'>/// h.write_all(data[0]);</span> +<span class='doccomment'>/// h.write_all(data[1]);</span> +<span class='doccomment'>/// let res = h.finish();</span> +<span class='doccomment'>/// assert_eq!(res, spec);</span> +<span class='doccomment'>/// ```</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Warning</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Don't actually use MD5 and SHA-1 hashes, they're not secure anymore.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Don't ever hash passwords, use `crypto::pkcs5` or bcrypt/scrypt instead.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Hasher</span> { + <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_MD_CTX</span>, + <span class='ident'>md</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_MD</span>, + <span class='ident'>type_</span>: <span class='ident'>Type</span>, + <span class='ident'>state</span>: <span class='ident'>State</span>, +} + +<span class='kw'>impl</span> <span class='ident'>Hasher</span> { + <span class='doccomment'>/// Creates a new `Hasher` with the specified hash type.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>ty</span>: <span class='ident'>Type</span>) <span class='op'>-></span> <span class='ident'>Hasher</span> { + <span class='ident'>ffi</span>::<span class='ident'>init</span>(); + + <span class='kw'>let</span> <span class='ident'>ctx</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_MD_CTX_create</span>(); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>r</span>.<span class='ident'>is_null</span>()); + <span class='ident'>r</span> + }; + <span class='kw'>let</span> <span class='ident'>md</span> <span class='op'>=</span> <span class='ident'>ty</span>.<span class='ident'>evp_md</span>(); + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>h</span> <span class='op'>=</span> <span class='ident'>Hasher</span> { <span class='ident'>ctx</span>: <span class='ident'>ctx</span>, <span class='ident'>md</span>: <span class='ident'>md</span>, <span class='ident'>type_</span>: <span class='ident'>ty</span>, <span class='ident'>state</span>: <span class='ident'>Finalized</span> }; + <span class='ident'>h</span>.<span class='ident'>init</span>(); + <span class='ident'>h</span> + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>init</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>state</span> { + <span class='ident'>Reset</span> <span class='op'>=></span> <span class='kw'>return</span>, + <span class='ident'>Updated</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>finalize</span>(); }, + <span class='ident'>Finalized</span> <span class='op'>=></span> (), + } + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_DigestInit_ex</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='self'>self</span>.<span class='ident'>md</span>, <span class='number'>0</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw'>const</span> _); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='number'>1</span>); + } + <span class='self'>self</span>.<span class='ident'>state</span> <span class='op'>=</span> <span class='ident'>Reset</span>; + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>update</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>data</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>state</span> <span class='op'>==</span> <span class='ident'>Finalized</span> { + <span class='self'>self</span>.<span class='ident'>init</span>(); + } + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_DigestUpdate</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>data</span>.<span class='ident'>as_ptr</span>(), + <span class='ident'>data</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>c_uint</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='number'>1</span>); + } + <span class='self'>self</span>.<span class='ident'>state</span> <span class='op'>=</span> <span class='ident'>Updated</span>; + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>finalize</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>state</span> <span class='op'>==</span> <span class='ident'>Finalized</span> { + <span class='self'>self</span>.<span class='ident'>init</span>(); + } + <span class='kw'>let</span> <span class='ident'>md_len</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>type_</span>.<span class='ident'>md_len</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>res</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>repeat</span>(<span class='number'>0</span>).<span class='ident'>take</span>(<span class='ident'>md_len</span>).<span class='ident'>collect</span>(); + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_DigestFinal_ex</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>res</span>.<span class='ident'>as_mut_ptr</span>(), <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>len</span>); + <span class='self'>self</span>.<span class='ident'>state</span> <span class='op'>=</span> <span class='ident'>Finalized</span>; + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>len</span> <span class='kw'>as</span> <span class='ident'>usize</span>, <span class='ident'>md_len</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='number'>1</span>); + } + <span class='ident'>res</span> + } + + <span class='doccomment'>/// Returns the hash of the data written since creation or</span> + <span class='doccomment'>/// the last `finish` and resets the hasher.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>finish</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>finalize</span>() + } +} + +<span class='kw'>impl</span> <span class='ident'>Write</span> <span class='kw'>for</span> <span class='ident'>Hasher</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>write</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>buf</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>update</span>(<span class='ident'>buf</span>); + <span class='prelude-val'>Ok</span>(<span class='ident'>buf</span>.<span class='ident'>len</span>()) + } + + <span class='kw'>fn</span> <span class='ident'>flush</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='prelude-val'>Ok</span>(()) + } +} + +<span class='kw'>impl</span> <span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>Hasher</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Hasher</span> { + <span class='kw'>let</span> <span class='ident'>ctx</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>ctx</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_MD_CTX_create</span>(); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>ctx</span>.<span class='ident'>is_null</span>()); + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_MD_CTX_copy_ex</span>(<span class='ident'>ctx</span>, <span class='self'>self</span>.<span class='ident'>ctx</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='number'>1</span>); + <span class='ident'>ctx</span> + }; + <span class='ident'>Hasher</span> { <span class='ident'>ctx</span>: <span class='ident'>ctx</span>, <span class='ident'>md</span>: <span class='self'>self</span>.<span class='ident'>md</span>, <span class='ident'>type_</span>: <span class='self'>self</span>.<span class='ident'>type_</span>, <span class='ident'>state</span>: <span class='self'>self</span>.<span class='ident'>state</span> } + } +} + +<span class='kw'>impl</span> <span class='ident'>Drop</span> <span class='kw'>for</span> <span class='ident'>Hasher</span> { + <span class='kw'>fn</span> <span class='ident'>drop</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>unsafe</span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>state</span> <span class='op'>!=</span> <span class='ident'>Finalized</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>buf</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>repeat</span>(<span class='number'>0</span>).<span class='ident'>take</span>(<span class='self'>self</span>.<span class='ident'>type_</span>.<span class='ident'>md_len</span>()).<span class='ident'>collect</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='ident'>ffi</span>::<span class='ident'>EVP_DigestFinal_ex</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>buf</span>.<span class='ident'>as_mut_ptr</span>(), <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>len</span>); + } + <span class='ident'>ffi</span>::<span class='ident'>EVP_MD_CTX_destroy</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>); + } + } +} + +<span class='doccomment'>/// Computes the hash of the `data` with the hash `t`.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>hash</span>(<span class='ident'>t</span>: <span class='ident'>Type</span>, <span class='ident'>data</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>h</span> <span class='op'>=</span> <span class='ident'>Hasher</span>::<span class='ident'>new</span>(<span class='ident'>t</span>); + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>h</span>.<span class='ident'>write_all</span>(<span class='ident'>data</span>); + <span class='ident'>h</span>.<span class='ident'>finish</span>() +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>tests</span> { + <span class='kw'>use</span> <span class='ident'>serialize</span>::<span class='ident'>hex</span>::{<span class='ident'>FromHex</span>, <span class='ident'>ToHex</span>}; + <span class='kw'>use</span> <span class='ident'>super</span>::{<span class='ident'>hash</span>, <span class='ident'>Hasher</span>, <span class='ident'>Type</span>}; + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>::<span class='ident'>prelude</span>::<span class='op'>*</span>; + + <span class='kw'>fn</span> <span class='ident'>hash_test</span>(<span class='ident'>hashtype</span>: <span class='ident'>Type</span>, <span class='ident'>hashtest</span>: <span class='kw-2'>&</span>(<span class='kw-2'>&</span><span class='ident'>str</span>, <span class='kw-2'>&</span><span class='ident'>str</span>)) { + <span class='kw'>let</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='ident'>hash</span>(<span class='ident'>hashtype</span>, <span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>hashtest</span>.<span class='number'>0</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>res</span>.<span class='ident'>to_hex</span>(), <span class='ident'>hashtest</span>.<span class='number'>1</span>); + } + + <span class='kw'>fn</span> <span class='ident'>hash_recycle_test</span>(<span class='ident'>h</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Hasher</span>, <span class='ident'>hashtest</span>: <span class='kw-2'>&</span>(<span class='kw-2'>&</span><span class='ident'>str</span>, <span class='kw-2'>&</span><span class='ident'>str</span>)) { + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>h</span>.<span class='ident'>write_all</span>(<span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>hashtest</span>.<span class='number'>0</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()); + <span class='kw'>let</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='ident'>h</span>.<span class='ident'>finish</span>(); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>res</span>.<span class='ident'>to_hex</span>(), <span class='ident'>hashtest</span>.<span class='number'>1</span>); + } + + <span class='comment'>// Test vectors from http://www.nsrl.nist.gov/testdata/</span> + <span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>non_upper_case_globals</span>)]</span> + <span class='kw'>const</span> <span class='ident'>md5_tests</span>: [(<span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>, <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>); <span class='number'>13</span>] <span class='op'>=</span> [ + (<span class='string'>""</span>, <span class='string'>"d41d8cd98f00b204e9800998ecf8427e"</span>), + (<span class='string'>"7F"</span>, <span class='string'>"83acb6e67e50e31db6ed341dd2de1595"</span>), + (<span class='string'>"EC9C"</span>, <span class='string'>"0b07f0d4ca797d8ac58874f887cb0b68"</span>), + (<span class='string'>"FEE57A"</span>, <span class='string'>"e0d583171eb06d56198fc0ef22173907"</span>), + (<span class='string'>"42F497E0"</span>, <span class='string'>"7c430f178aefdf1487fee7144e9641e2"</span>), + (<span class='string'>"C53B777F1C"</span>, <span class='string'>"75ef141d64cb37ec423da2d9d440c925"</span>), + (<span class='string'>"89D5B576327B"</span>, <span class='string'>"ebbaf15eb0ed784c6faa9dc32831bf33"</span>), + (<span class='string'>"5D4CCE781EB190"</span>, <span class='string'>"ce175c4b08172019f05e6b5279889f2c"</span>), + (<span class='string'>"81901FE94932D7B9"</span>, <span class='string'>"cd4d2f62b8cdb3a0cf968a735a239281"</span>), + (<span class='string'>"C9FFDEE7788EFB4EC9"</span>, <span class='string'>"e0841a231ab698db30c6c0f3f246c014"</span>), + (<span class='string'>"66AC4B7EBA95E53DC10B"</span>, <span class='string'>"a3b3cea71910d9af56742aa0bb2fe329"</span>), + (<span class='string'>"A510CD18F7A56852EB0319"</span>, <span class='string'>"577e216843dd11573574d3fb209b97d8"</span>), + (<span class='string'>"AAED18DBE8938C19ED734A8D"</span>, <span class='string'>"6f80fb775f27e0a4ce5c2f42fc72c5f1"</span>) + ]; + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_md5</span>() { + <span class='kw'>for</span> <span class='ident'>test</span> <span class='kw'>in</span> <span class='ident'>md5_tests</span>.<span class='ident'>iter</span>() { + <span class='ident'>hash_test</span>(<span class='ident'>Type</span>::<span class='ident'>MD5</span>, <span class='ident'>test</span>); + } + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_md5_recycle</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>h</span> <span class='op'>=</span> <span class='ident'>Hasher</span>::<span class='ident'>new</span>(<span class='ident'>Type</span>::<span class='ident'>MD5</span>); + <span class='kw'>for</span> <span class='ident'>test</span> <span class='kw'>in</span> <span class='ident'>md5_tests</span>.<span class='ident'>iter</span>() { + <span class='ident'>hash_recycle_test</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>h</span>, <span class='ident'>test</span>); + } + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_finish_twice</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>h</span> <span class='op'>=</span> <span class='ident'>Hasher</span>::<span class='ident'>new</span>(<span class='ident'>Type</span>::<span class='ident'>MD5</span>); + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>h</span>.<span class='ident'>write_all</span>(<span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>md5_tests</span>[<span class='number'>6</span>].<span class='number'>0</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()); + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>h</span>.<span class='ident'>finish</span>(); + <span class='kw'>let</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='ident'>h</span>.<span class='ident'>finish</span>(); + <span class='kw'>let</span> <span class='ident'>null</span> <span class='op'>=</span> <span class='ident'>hash</span>(<span class='ident'>Type</span>::<span class='ident'>MD5</span>, <span class='kw-2'>&</span>[]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>res</span>, <span class='ident'>null</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_clone</span>() { + <span class='kw'>let</span> <span class='ident'>i</span> <span class='op'>=</span> <span class='number'>7</span>; + <span class='kw'>let</span> <span class='ident'>inp</span> <span class='op'>=</span> <span class='ident'>md5_tests</span>[<span class='ident'>i</span>].<span class='number'>0</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>inp</span>.<span class='ident'>len</span>() <span class='op'>></span> <span class='number'>2</span>); + <span class='kw'>let</span> <span class='ident'>p</span> <span class='op'>=</span> <span class='ident'>inp</span>.<span class='ident'>len</span>() <span class='op'>/</span> <span class='number'>2</span>; + <span class='kw'>let</span> <span class='ident'>h0</span> <span class='op'>=</span> <span class='ident'>Hasher</span>::<span class='ident'>new</span>(<span class='ident'>Type</span>::<span class='ident'>MD5</span>); + + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Clone a new hasher"</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>h1</span> <span class='op'>=</span> <span class='ident'>h0</span>.<span class='ident'>clone</span>(); + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>h1</span>.<span class='ident'>write_all</span>(<span class='kw-2'>&</span><span class='ident'>inp</span>[..<span class='ident'>p</span>]); + { + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Clone an updated hasher"</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>h2</span> <span class='op'>=</span> <span class='ident'>h1</span>.<span class='ident'>clone</span>(); + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>h2</span>.<span class='ident'>write_all</span>(<span class='kw-2'>&</span><span class='ident'>inp</span>[<span class='ident'>p</span>..]); + <span class='kw'>let</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='ident'>h2</span>.<span class='ident'>finish</span>(); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>res</span>.<span class='ident'>to_hex</span>(), <span class='ident'>md5_tests</span>[<span class='ident'>i</span>].<span class='number'>1</span>); + } + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>h1</span>.<span class='ident'>write_all</span>(<span class='kw-2'>&</span><span class='ident'>inp</span>[<span class='ident'>p</span>..]); + <span class='kw'>let</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='ident'>h1</span>.<span class='ident'>finish</span>(); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>res</span>.<span class='ident'>to_hex</span>(), <span class='ident'>md5_tests</span>[<span class='ident'>i</span>].<span class='number'>1</span>); + + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Clone a finished hasher"</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>h3</span> <span class='op'>=</span> <span class='ident'>h1</span>.<span class='ident'>clone</span>(); + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>h3</span>.<span class='ident'>write_all</span>(<span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>md5_tests</span>[<span class='ident'>i</span> <span class='op'>+</span> <span class='number'>1</span>].<span class='number'>0</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()); + <span class='kw'>let</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='ident'>h3</span>.<span class='ident'>finish</span>(); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>res</span>.<span class='ident'>to_hex</span>(), <span class='ident'>md5_tests</span>[<span class='ident'>i</span> <span class='op'>+</span> <span class='number'>1</span>].<span class='number'>1</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_sha1</span>() { + <span class='kw'>let</span> <span class='ident'>tests</span> <span class='op'>=</span> [ + (<span class='string'>"616263"</span>, <span class='string'>"a9993e364706816aba3e25717850c26c9cd0d89d"</span>), + ]; + + <span class='kw'>for</span> <span class='ident'>test</span> <span class='kw'>in</span> <span class='ident'>tests</span>.<span class='ident'>iter</span>() { + <span class='ident'>hash_test</span>(<span class='ident'>Type</span>::<span class='ident'>SHA1</span>, <span class='ident'>test</span>); + } + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_sha256</span>() { + <span class='kw'>let</span> <span class='ident'>tests</span> <span class='op'>=</span> [ + (<span class='string'>"616263"</span>, <span class='string'>"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"</span>) + ]; + + <span class='kw'>for</span> <span class='ident'>test</span> <span class='kw'>in</span> <span class='ident'>tests</span>.<span class='ident'>iter</span>() { + <span class='ident'>hash_test</span>(<span class='ident'>Type</span>::<span class='ident'>SHA256</span>, <span class='ident'>test</span>); + } + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_ripemd160</span>() { + <span class='kw'>let</span> <span class='ident'>tests</span> <span class='op'>=</span> [ + (<span class='string'>"616263"</span>, <span class='string'>"8eb208f7e05d987a9b044a8e98c6b087f15a0bfc"</span>) + ]; + + <span class='kw'>for</span> <span class='ident'>test</span> <span class='kw'>in</span> <span class='ident'>tests</span>.<span class='ident'>iter</span>() { + <span class='ident'>hash_test</span>(<span class='ident'>Type</span>::<span class='ident'>RIPEMD160</span>, <span class='ident'>test</span>); + } + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl"; + window.playgroundUrl = ""; + </script> + <script src="../../../jquery.js"></script> + <script src="../../../main.js"></script> + + <script async src="../../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl/crypto/hmac.rs.html b/src/openssl/crypto/hmac.rs.html new file mode 100644 index 0000000..e63ec32 --- /dev/null +++ b/src/openssl/crypto/hmac.rs.html @@ -0,0 +1,1053 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-0.6.3/src/crypto/hmac.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>hmac.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +<span id="313">313</span> +<span id="314">314</span> +<span id="315">315</span> +<span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +<span id="326">326</span> +<span id="327">327</span> +<span id="328">328</span> +<span id="329">329</span> +<span id="330">330</span> +<span id="331">331</span> +<span id="332">332</span> +<span id="333">333</span> +<span id="334">334</span> +<span id="335">335</span> +<span id="336">336</span> +<span id="337">337</span> +<span id="338">338</span> +<span id="339">339</span> +<span id="340">340</span> +<span id="341">341</span> +<span id="342">342</span> +<span id="343">343</span> +<span id="344">344</span> +<span id="345">345</span> +<span id="346">346</span> +<span id="347">347</span> +<span id="348">348</span> +<span id="349">349</span> +<span id="350">350</span> +<span id="351">351</span> +<span id="352">352</span> +<span id="353">353</span> +<span id="354">354</span> +<span id="355">355</span> +<span id="356">356</span> +<span id="357">357</span> +<span id="358">358</span> +<span id="359">359</span> +<span id="360">360</span> +<span id="361">361</span> +<span id="362">362</span> +<span id="363">363</span> +<span id="364">364</span> +<span id="365">365</span> +<span id="366">366</span> +<span id="367">367</span> +<span id="368">368</span> +<span id="369">369</span> +<span id="370">370</span> +<span id="371">371</span> +<span id="372">372</span> +<span id="373">373</span> +<span id="374">374</span> +<span id="375">375</span> +<span id="376">376</span> +<span id="377">377</span> +<span id="378">378</span> +<span id="379">379</span> +<span id="380">380</span> +<span id="381">381</span> +<span id="382">382</span> +<span id="383">383</span> +<span id="384">384</span> +<span id="385">385</span> +<span id="386">386</span> +<span id="387">387</span> +<span id="388">388</span> +<span id="389">389</span> +<span id="390">390</span> +<span id="391">391</span> +<span id="392">392</span> +<span id="393">393</span> +<span id="394">394</span> +<span id="395">395</span> +<span id="396">396</span> +<span id="397">397</span> +<span id="398">398</span> +<span id="399">399</span> +<span id="400">400</span> +<span id="401">401</span> +<span id="402">402</span> +<span id="403">403</span> +<span id="404">404</span> +<span id="405">405</span> +<span id="406">406</span> +<span id="407">407</span> +<span id="408">408</span> +<span id="409">409</span> +<span id="410">410</span> +<span id="411">411</span> +<span id="412">412</span> +<span id="413">413</span> +<span id="414">414</span> +<span id="415">415</span> +<span id="416">416</span> +<span id="417">417</span> +<span id="418">418</span> +<span id="419">419</span> +<span id="420">420</span> +<span id="421">421</span> +<span id="422">422</span> +<span id="423">423</span> +<span id="424">424</span> +<span id="425">425</span> +<span id="426">426</span> +<span id="427">427</span> +<span id="428">428</span> +<span id="429">429</span> +<span id="430">430</span> +<span id="431">431</span> +<span id="432">432</span> +<span id="433">433</span> +<span id="434">434</span> +<span id="435">435</span> +<span id="436">436</span> +<span id="437">437</span> +<span id="438">438</span> +<span id="439">439</span> +<span id="440">440</span> +<span id="441">441</span> +<span id="442">442</span> +<span id="443">443</span> +<span id="444">444</span> +<span id="445">445</span> +<span id="446">446</span> +<span id="447">447</span> +<span id="448">448</span> +<span id="449">449</span> +<span id="450">450</span> +<span id="451">451</span> +<span id="452">452</span> +<span id="453">453</span> +<span id="454">454</span> +<span id="455">455</span> +<span id="456">456</span> +<span id="457">457</span> +<span id="458">458</span> +<span id="459">459</span> +<span id="460">460</span> +<span id="461">461</span> +<span id="462">462</span> +<span id="463">463</span> +<span id="464">464</span> +<span id="465">465</span> +<span id="466">466</span> +<span id="467">467</span> +<span id="468">468</span> +<span id="469">469</span> +<span id="470">470</span> +<span id="471">471</span> +<span id="472">472</span> +<span id="473">473</span> +<span id="474">474</span> +<span id="475">475</span> +<span id="476">476</span> +<span id="477">477</span> +<span id="478">478</span> +</pre><pre class='rust '> +<span class='comment'>/* + * Copyright 2013 Jack Lloyd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */</span> + +<span class='kw'>use</span> <span class='ident'>libc</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_uint</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>iter</span>::<span class='ident'>repeat</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>::<span class='ident'>prelude</span>::<span class='op'>*</span>; + +<span class='kw'>use</span> <span class='ident'>crypto</span>::<span class='ident'>hash</span>::<span class='ident'>Type</span>; +<span class='kw'>use</span> <span class='ident'>ffi</span>; + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>PartialEq</span>, <span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> +<span class='kw'>enum</span> <span class='ident'>State</span> { + <span class='ident'>Reset</span>, + <span class='ident'>Updated</span>, + <span class='ident'>Finalized</span>, +} + +<span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>State</span>::<span class='op'>*</span>; + +<span class='doccomment'>/// Provides HMAC computation.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Examples</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Calculate a HMAC in one go.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ```</span> +<span class='doccomment'>/// use openssl::crypto::hash::Type;</span> +<span class='doccomment'>/// use openssl::crypto::hmac::hmac;</span> +<span class='doccomment'>/// let key = b"Jefe";</span> +<span class='doccomment'>/// let data = b"what do ya want for nothing?";</span> +<span class='doccomment'>/// let spec = b"\x75\x0c\x78\x3e\x6a\xb0\xb5\x03\xea\xa8\x6e\x31\x0a\x5d\xb7\x38";</span> +<span class='doccomment'>/// let res = hmac(Type::MD5, key, data);</span> +<span class='doccomment'>/// assert_eq!(res, spec);</span> +<span class='doccomment'>/// ```</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Use the `Write` trait to supply the input in chunks.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ```</span> +<span class='doccomment'>/// use std::io::prelude::*;</span> +<span class='doccomment'>/// use openssl::crypto::hash::Type;</span> +<span class='doccomment'>/// use openssl::crypto::hmac::HMAC;</span> +<span class='doccomment'>/// let key = b"Jefe";</span> +<span class='doccomment'>/// let data: &[&[u8]] = &[b"what do ya ", b"want for nothing?"];</span> +<span class='doccomment'>/// let spec = b"\x75\x0c\x78\x3e\x6a\xb0\xb5\x03\xea\xa8\x6e\x31\x0a\x5d\xb7\x38";</span> +<span class='doccomment'>/// let mut h = HMAC::new(Type::MD5, &*key);</span> +<span class='doccomment'>/// h.write_all(data[0]);</span> +<span class='doccomment'>/// h.write_all(data[1]);</span> +<span class='doccomment'>/// let res = h.finish();</span> +<span class='doccomment'>/// assert_eq!(res, spec);</span> +<span class='doccomment'>/// ```</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>HMAC</span> { + <span class='ident'>ctx</span>: <span class='ident'>ffi</span>::<span class='ident'>HMAC_CTX</span>, + <span class='ident'>type_</span>: <span class='ident'>Type</span>, + <span class='ident'>state</span>: <span class='ident'>State</span>, +} + +<span class='kw'>impl</span> <span class='ident'>HMAC</span> { + <span class='doccomment'>/// Creates a new `HMAC` with the specified hash type using the `key`.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>ty</span>: <span class='ident'>Type</span>, <span class='ident'>key</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>HMAC</span> { + <span class='ident'>ffi</span>::<span class='ident'>init</span>(); + + <span class='kw'>let</span> <span class='ident'>ctx</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>ctx</span> <span class='op'>=</span> ::<span class='ident'>std</span>::<span class='ident'>mem</span>::<span class='ident'>uninitialized</span>(); + <span class='ident'>ffi</span>::<span class='ident'>HMAC_CTX_init</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>ctx</span>); + <span class='ident'>ctx</span> + }; + <span class='kw'>let</span> <span class='ident'>md</span> <span class='op'>=</span> <span class='ident'>ty</span>.<span class='ident'>evp_md</span>(); + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>h</span> <span class='op'>=</span> <span class='ident'>HMAC</span> { <span class='ident'>ctx</span>: <span class='ident'>ctx</span>, <span class='ident'>type_</span>: <span class='ident'>ty</span>, <span class='ident'>state</span>: <span class='ident'>Finalized</span> }; + <span class='ident'>h</span>.<span class='ident'>init_once</span>(<span class='ident'>md</span>, <span class='ident'>key</span>); + <span class='ident'>h</span> + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>init_once</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>md</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_MD</span>, <span class='ident'>key</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>HMAC_Init_ex_shim</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>ctx</span>, + <span class='ident'>key</span>.<span class='ident'>as_ptr</span>(), <span class='ident'>key</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>c_int</span>, + <span class='ident'>md</span>, <span class='number'>0</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw'>const</span> _); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='number'>1</span>); + } + <span class='self'>self</span>.<span class='ident'>state</span> <span class='op'>=</span> <span class='ident'>Reset</span>; + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>init</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>state</span> { + <span class='ident'>Reset</span> <span class='op'>=></span> <span class='kw'>return</span>, + <span class='ident'>Updated</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>finalize</span>(); }, + <span class='ident'>Finalized</span> <span class='op'>=></span> (), + } + <span class='comment'>// If the key and/or md is not supplied it's reused from the last time</span> + <span class='comment'>// avoiding redundant initializations</span> + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>HMAC_Init_ex_shim</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>ctx</span>, + <span class='number'>0</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw'>const</span> _, <span class='number'>0</span>, + <span class='number'>0</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw'>const</span> _, <span class='number'>0</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw'>const</span> _); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='number'>1</span>); + } + <span class='self'>self</span>.<span class='ident'>state</span> <span class='op'>=</span> <span class='ident'>Reset</span>; + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>update</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>data</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>state</span> <span class='op'>==</span> <span class='ident'>Finalized</span> { + <span class='self'>self</span>.<span class='ident'>init</span>(); + } + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>HMAC_Update_shim</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>data</span>.<span class='ident'>as_ptr</span>(), <span class='ident'>data</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>c_uint</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='number'>1</span>); + } + <span class='self'>self</span>.<span class='ident'>state</span> <span class='op'>=</span> <span class='ident'>Updated</span>; + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>finalize</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>state</span> <span class='op'>==</span> <span class='ident'>Finalized</span> { + <span class='self'>self</span>.<span class='ident'>init</span>(); + } + <span class='kw'>let</span> <span class='ident'>md_len</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>type_</span>.<span class='ident'>md_len</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>res</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>repeat</span>(<span class='number'>0</span>).<span class='ident'>take</span>(<span class='ident'>md_len</span>).<span class='ident'>collect</span>(); + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>HMAC_Final_shim</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>res</span>.<span class='ident'>as_mut_ptr</span>(), <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>len</span>); + <span class='self'>self</span>.<span class='ident'>state</span> <span class='op'>=</span> <span class='ident'>Finalized</span>; + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>len</span> <span class='kw'>as</span> <span class='ident'>usize</span>, <span class='ident'>md_len</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='number'>1</span>); + } + <span class='ident'>res</span> + } + + <span class='doccomment'>/// Returns the hash of the data written since creation or</span> + <span class='doccomment'>/// the last `finish` and resets the hasher.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>finish</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>finalize</span>() + } +} + +<span class='kw'>impl</span> <span class='ident'>Write</span> <span class='kw'>for</span> <span class='ident'>HMAC</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>write</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>buf</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>update</span>(<span class='ident'>buf</span>); + <span class='prelude-val'>Ok</span>(<span class='ident'>buf</span>.<span class='ident'>len</span>()) + } + + <span class='kw'>fn</span> <span class='ident'>flush</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='prelude-val'>Ok</span>(()) + } +} + +<span class='kw'>impl</span> <span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>HMAC</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>HMAC</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>ctx</span>: <span class='ident'>ffi</span>::<span class='ident'>HMAC_CTX</span>; + <span class='kw'>unsafe</span> { + <span class='ident'>ctx</span> <span class='op'>=</span> ::<span class='ident'>std</span>::<span class='ident'>mem</span>::<span class='ident'>uninitialized</span>(); + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>HMAC_CTX_copy</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>ctx</span>, <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>ctx</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>r</span>, <span class='number'>1</span>); + } + <span class='ident'>HMAC</span> { <span class='ident'>ctx</span>: <span class='ident'>ctx</span>, <span class='ident'>type_</span>: <span class='self'>self</span>.<span class='ident'>type_</span>, <span class='ident'>state</span>: <span class='self'>self</span>.<span class='ident'>state</span> } + } +} + +<span class='kw'>impl</span> <span class='ident'>Drop</span> <span class='kw'>for</span> <span class='ident'>HMAC</span> { + <span class='kw'>fn</span> <span class='ident'>drop</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>unsafe</span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>state</span> <span class='op'>!=</span> <span class='ident'>Finalized</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>buf</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>repeat</span>(<span class='number'>0</span>).<span class='ident'>take</span>(<span class='self'>self</span>.<span class='ident'>type_</span>.<span class='ident'>md_len</span>()).<span class='ident'>collect</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='ident'>ffi</span>::<span class='ident'>HMAC_Final_shim</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>buf</span>.<span class='ident'>as_mut_ptr</span>(), <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>len</span>); + } + <span class='ident'>ffi</span>::<span class='ident'>HMAC_CTX_cleanup</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>ctx</span>); + } + } +} + +<span class='doccomment'>/// Computes the HMAC of the `data` with the hash `t` and `key`.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>hmac</span>(<span class='ident'>t</span>: <span class='ident'>Type</span>, <span class='ident'>key</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>], <span class='ident'>data</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>h</span> <span class='op'>=</span> <span class='ident'>HMAC</span>::<span class='ident'>new</span>(<span class='ident'>t</span>, <span class='ident'>key</span>); + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>h</span>.<span class='ident'>write_all</span>(<span class='ident'>data</span>); + <span class='ident'>h</span>.<span class='ident'>finish</span>() +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>tests</span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>iter</span>::<span class='ident'>repeat</span>; + <span class='kw'>use</span> <span class='ident'>serialize</span>::<span class='ident'>hex</span>::<span class='ident'>FromHex</span>; + <span class='kw'>use</span> <span class='ident'>crypto</span>::<span class='ident'>hash</span>::<span class='ident'>Type</span>; + <span class='kw'>use</span> <span class='ident'>crypto</span>::<span class='ident'>hash</span>::<span class='ident'>Type</span>::<span class='op'>*</span>; + <span class='kw'>use</span> <span class='ident'>super</span>::{<span class='ident'>hmac</span>, <span class='ident'>HMAC</span>}; + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>::<span class='ident'>prelude</span>::<span class='op'>*</span>; + + <span class='kw'>fn</span> <span class='ident'>test_hmac</span>(<span class='ident'>ty</span>: <span class='ident'>Type</span>, <span class='ident'>tests</span>: <span class='kw-2'>&</span>[(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>)]) { + <span class='kw'>for</span> <span class='kw-2'>&</span>(<span class='kw-2'>ref</span> <span class='ident'>key</span>, <span class='kw-2'>ref</span> <span class='ident'>data</span>, <span class='kw-2'>ref</span> <span class='ident'>res</span>) <span class='kw'>in</span> <span class='ident'>tests</span>.<span class='ident'>iter</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>hmac</span>(<span class='ident'>ty</span>, <span class='kw-2'>&</span><span class='op'>*</span><span class='op'>*</span><span class='ident'>key</span>, <span class='kw-2'>&</span><span class='op'>*</span><span class='op'>*</span><span class='ident'>data</span>), <span class='op'>*</span><span class='ident'>res</span>); + } + } + + <span class='kw'>fn</span> <span class='ident'>test_hmac_recycle</span>(<span class='ident'>h</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>HMAC</span>, <span class='ident'>test</span>: <span class='kw-2'>&</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>)) { + <span class='kw'>let</span> <span class='kw-2'>&</span>(_, <span class='kw-2'>ref</span> <span class='ident'>data</span>, <span class='kw-2'>ref</span> <span class='ident'>res</span>) <span class='op'>=</span> <span class='ident'>test</span>; + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>h</span>.<span class='ident'>write_all</span>(<span class='kw-2'>&</span><span class='op'>*</span><span class='op'>*</span><span class='ident'>data</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>h</span>.<span class='ident'>finish</span>(), <span class='op'>*</span><span class='ident'>res</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_hmac_md5</span>() { + <span class='comment'>// test vectors from RFC 2202</span> + <span class='kw'>let</span> <span class='ident'>tests</span>: [(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>); <span class='number'>7</span>] <span class='op'>=</span> [ + (<span class='ident'>repeat</span>(<span class='number'>0x0b_u8</span>).<span class='ident'>take</span>(<span class='number'>16</span>).<span class='ident'>collect</span>(), <span class='string'>b"Hi There"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>"9294727a3638bb1c13f48ef8158bfc9d"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()), + (<span class='string'>b"Jefe"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>b"what do ya want for nothing?"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>"750c783e6ab0b503eaa86e310a5db738"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()), + (<span class='ident'>repeat</span>(<span class='number'>0xaa_u8</span>).<span class='ident'>take</span>(<span class='number'>16</span>).<span class='ident'>collect</span>(), <span class='ident'>repeat</span>(<span class='number'>0xdd_u8</span>).<span class='ident'>take</span>(<span class='number'>50</span>).<span class='ident'>collect</span>(), + <span class='string'>"56be34521d144c88dbb8c733f0e8b3f6"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()), + (<span class='string'>"0102030405060708090a0b0c0d0e0f10111213141516171819"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='ident'>repeat</span>(<span class='number'>0xcd_u8</span>).<span class='ident'>take</span>(<span class='number'>50</span>).<span class='ident'>collect</span>(), + <span class='string'>"697eaf0aca3a3aea3a75164746ffaa79"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()), + (<span class='ident'>repeat</span>(<span class='number'>0x0c_u8</span>).<span class='ident'>take</span>(<span class='number'>16</span>).<span class='ident'>collect</span>(), + <span class='string'>b"Test With Truncation"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>"56461ef2342edc00f9bab995690efd4c"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()), + (<span class='ident'>repeat</span>(<span class='number'>0xaa_u8</span>).<span class='ident'>take</span>(<span class='number'>80</span>).<span class='ident'>collect</span>(), + <span class='string'>b"Test Using Larger Than Block-Size Key - Hash Key First"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>"6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()), + (<span class='ident'>repeat</span>(<span class='number'>0xaa_u8</span>).<span class='ident'>take</span>(<span class='number'>80</span>).<span class='ident'>collect</span>(), + <span class='string'>b"Test Using Larger Than Block-Size Key \ + and Larger Than One Block-Size Data"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>"6f630fad67cda0ee1fb1f562db3aa53e"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()) + ]; + + <span class='ident'>test_hmac</span>(<span class='ident'>MD5</span>, <span class='kw-2'>&</span><span class='ident'>tests</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_hmac_md5_recycle</span>() { + <span class='kw'>let</span> <span class='ident'>tests</span>: [(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>); <span class='number'>2</span>] <span class='op'>=</span> [ + (<span class='ident'>repeat</span>(<span class='number'>0xaa_u8</span>).<span class='ident'>take</span>(<span class='number'>80</span>).<span class='ident'>collect</span>(), + <span class='string'>b"Test Using Larger Than Block-Size Key - Hash Key First"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>"6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()), + (<span class='ident'>repeat</span>(<span class='number'>0xaa_u8</span>).<span class='ident'>take</span>(<span class='number'>80</span>).<span class='ident'>collect</span>(), + <span class='string'>b"Test Using Larger Than Block-Size Key \ + and Larger Than One Block-Size Data"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>"6f630fad67cda0ee1fb1f562db3aa53e"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()) + ]; + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>h</span> <span class='op'>=</span> <span class='ident'>HMAC</span>::<span class='ident'>new</span>(<span class='ident'>MD5</span>, <span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>tests</span>[<span class='number'>0</span>].<span class='number'>0</span>); + <span class='kw'>for</span> <span class='ident'>i</span> <span class='kw'>in</span> <span class='number'>0</span>..<span class='number'>100usize</span> { + <span class='kw'>let</span> <span class='ident'>test</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='ident'>tests</span>[<span class='ident'>i</span> <span class='op'>%</span> <span class='number'>2</span>]; + <span class='ident'>test_hmac_recycle</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>h</span>, <span class='ident'>test</span>); + } + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_finish_twice</span>() { + <span class='kw'>let</span> <span class='ident'>test</span>: (<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>) <span class='op'>=</span> + (<span class='ident'>repeat</span>(<span class='number'>0xaa_u8</span>).<span class='ident'>take</span>(<span class='number'>80</span>).<span class='ident'>collect</span>(), + <span class='string'>b"Test Using Larger Than Block-Size Key - Hash Key First"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>"6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()); + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>h</span> <span class='op'>=</span> <span class='ident'>HMAC</span>::<span class='ident'>new</span>(<span class='ident'>Type</span>::<span class='ident'>MD5</span>, <span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>test</span>.<span class='number'>0</span>); + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>h</span>.<span class='ident'>write_all</span>(<span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>test</span>.<span class='number'>1</span>); + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>h</span>.<span class='ident'>finish</span>(); + <span class='kw'>let</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='ident'>h</span>.<span class='ident'>finish</span>(); + <span class='kw'>let</span> <span class='ident'>null</span> <span class='op'>=</span> <span class='ident'>hmac</span>(<span class='ident'>Type</span>::<span class='ident'>MD5</span>, <span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>test</span>.<span class='number'>0</span>, <span class='kw-2'>&</span>[]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>res</span>, <span class='ident'>null</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_clone</span>() { + <span class='kw'>let</span> <span class='ident'>tests</span>: [(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>); <span class='number'>2</span>] <span class='op'>=</span> [ + (<span class='ident'>repeat</span>(<span class='number'>0xaa_u8</span>).<span class='ident'>take</span>(<span class='number'>80</span>).<span class='ident'>collect</span>(), + <span class='string'>b"Test Using Larger Than Block-Size Key - Hash Key First"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>"6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()), + (<span class='ident'>repeat</span>(<span class='number'>0xaa_u8</span>).<span class='ident'>take</span>(<span class='number'>80</span>).<span class='ident'>collect</span>(), + <span class='string'>b"Test Using Larger Than Block-Size Key \ + and Larger Than One Block-Size Data"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>"6f630fad67cda0ee1fb1f562db3aa53e"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()), + ]; + <span class='kw'>let</span> <span class='ident'>p</span> <span class='op'>=</span> <span class='ident'>tests</span>[<span class='number'>0</span>].<span class='number'>0</span>.<span class='ident'>len</span>() <span class='op'>/</span> <span class='number'>2</span>; + <span class='kw'>let</span> <span class='ident'>h0</span> <span class='op'>=</span> <span class='ident'>HMAC</span>::<span class='ident'>new</span>(<span class='ident'>Type</span>::<span class='ident'>MD5</span>, <span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>tests</span>[<span class='number'>0</span>].<span class='number'>0</span>); + + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Clone a new hmac"</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>h1</span> <span class='op'>=</span> <span class='ident'>h0</span>.<span class='ident'>clone</span>(); + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>h1</span>.<span class='ident'>write_all</span>(<span class='kw-2'>&</span><span class='ident'>tests</span>[<span class='number'>0</span>].<span class='number'>1</span>[..<span class='ident'>p</span>]); + { + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Clone an updated hmac"</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>h2</span> <span class='op'>=</span> <span class='ident'>h1</span>.<span class='ident'>clone</span>(); + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>h2</span>.<span class='ident'>write_all</span>(<span class='kw-2'>&</span><span class='ident'>tests</span>[<span class='number'>0</span>].<span class='number'>1</span>[<span class='ident'>p</span>..]); + <span class='kw'>let</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='ident'>h2</span>.<span class='ident'>finish</span>(); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>res</span>, <span class='ident'>tests</span>[<span class='number'>0</span>].<span class='number'>2</span>); + } + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>h1</span>.<span class='ident'>write_all</span>(<span class='kw-2'>&</span><span class='ident'>tests</span>[<span class='number'>0</span>].<span class='number'>1</span>[<span class='ident'>p</span>..]); + <span class='kw'>let</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='ident'>h1</span>.<span class='ident'>finish</span>(); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>res</span>, <span class='ident'>tests</span>[<span class='number'>0</span>].<span class='number'>2</span>); + + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Clone a finished hmac"</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>h3</span> <span class='op'>=</span> <span class='ident'>h1</span>.<span class='ident'>clone</span>(); + <span class='kw'>let</span> _ <span class='op'>=</span> <span class='ident'>h3</span>.<span class='ident'>write_all</span>(<span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>tests</span>[<span class='number'>1</span>].<span class='number'>1</span>); + <span class='kw'>let</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='ident'>h3</span>.<span class='ident'>finish</span>(); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>res</span>, <span class='ident'>tests</span>[<span class='number'>1</span>].<span class='number'>2</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_hmac_sha1</span>() { + <span class='comment'>// test vectors from RFC 2202</span> + <span class='kw'>let</span> <span class='ident'>tests</span>: [(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>); <span class='number'>7</span>] <span class='op'>=</span> [ + (<span class='ident'>repeat</span>(<span class='number'>0x0b_u8</span>).<span class='ident'>take</span>(<span class='number'>20</span>).<span class='ident'>collect</span>(), <span class='string'>b"Hi There"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>"b617318655057264e28bc0b6fb378c8ef146be00"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()), + (<span class='string'>b"Jefe"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>b"what do ya want for nothing?"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>"effcdf6ae5eb2fa2d27416d5f184df9c259a7c79"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()), + (<span class='ident'>repeat</span>(<span class='number'>0xaa_u8</span>).<span class='ident'>take</span>(<span class='number'>20</span>).<span class='ident'>collect</span>(), <span class='ident'>repeat</span>(<span class='number'>0xdd_u8</span>).<span class='ident'>take</span>(<span class='number'>50</span>).<span class='ident'>collect</span>(), + <span class='string'>"125d7342b9ac11cd91a39af48aa17b4f63f175d3"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()), + (<span class='string'>"0102030405060708090a0b0c0d0e0f10111213141516171819"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='ident'>repeat</span>(<span class='number'>0xcd_u8</span>).<span class='ident'>take</span>(<span class='number'>50</span>).<span class='ident'>collect</span>(), + <span class='string'>"4c9007f4026250c6bc8414f9bf50c86c2d7235da"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()), + (<span class='ident'>repeat</span>(<span class='number'>0x0c_u8</span>).<span class='ident'>take</span>(<span class='number'>20</span>).<span class='ident'>collect</span>(), + <span class='string'>b"Test With Truncation"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>"4c1a03424b55e07fe7f27be1d58bb9324a9a5a04"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()), + (<span class='ident'>repeat</span>(<span class='number'>0xaa_u8</span>).<span class='ident'>take</span>(<span class='number'>80</span>).<span class='ident'>collect</span>(), + <span class='string'>b"Test Using Larger Than Block-Size Key - Hash Key First"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>"aa4ae5e15272d00e95705637ce8a3b55ed402112"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()), + (<span class='ident'>repeat</span>(<span class='number'>0xaa_u8</span>).<span class='ident'>take</span>(<span class='number'>80</span>).<span class='ident'>collect</span>(), + <span class='string'>b"Test Using Larger Than Block-Size Key \ + and Larger Than One Block-Size Data"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>"e8e99d0f45237d786d6bbaa7965c7808bbff1a91"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()) + ]; + + <span class='ident'>test_hmac</span>(<span class='ident'>SHA1</span>, <span class='kw-2'>&</span><span class='ident'>tests</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_hmac_sha1_recycle</span>() { + <span class='kw'>let</span> <span class='ident'>tests</span>: [(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>); <span class='number'>2</span>] <span class='op'>=</span> [ + (<span class='ident'>repeat</span>(<span class='number'>0xaa_u8</span>).<span class='ident'>take</span>(<span class='number'>80</span>).<span class='ident'>collect</span>(), + <span class='string'>b"Test Using Larger Than Block-Size Key - Hash Key First"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>"aa4ae5e15272d00e95705637ce8a3b55ed402112"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()), + (<span class='ident'>repeat</span>(<span class='number'>0xaa_u8</span>).<span class='ident'>take</span>(<span class='number'>80</span>).<span class='ident'>collect</span>(), + <span class='string'>b"Test Using Larger Than Block-Size Key \ + and Larger Than One Block-Size Data"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>"e8e99d0f45237d786d6bbaa7965c7808bbff1a91"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()) + ]; + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>h</span> <span class='op'>=</span> <span class='ident'>HMAC</span>::<span class='ident'>new</span>(<span class='ident'>SHA1</span>, <span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>tests</span>[<span class='number'>0</span>].<span class='number'>0</span>); + <span class='kw'>for</span> <span class='ident'>i</span> <span class='kw'>in</span> <span class='number'>0</span>..<span class='number'>100usize</span> { + <span class='kw'>let</span> <span class='ident'>test</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='ident'>tests</span>[<span class='ident'>i</span> <span class='op'>%</span> <span class='number'>2</span>]; + <span class='ident'>test_hmac_recycle</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>h</span>, <span class='ident'>test</span>); + } + } + + + + <span class='kw'>fn</span> <span class='ident'>test_sha2</span>(<span class='ident'>ty</span>: <span class='ident'>Type</span>, <span class='ident'>results</span>: <span class='kw-2'>&</span>[<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>]) { + <span class='comment'>// test vectors from RFC 4231</span> + <span class='kw'>let</span> <span class='ident'>tests</span>: [(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>, <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span>); <span class='number'>6</span>] <span class='op'>=</span> [ + (<span class='ident'>repeat</span>(<span class='number'>0xb_u8</span>).<span class='ident'>take</span>(<span class='number'>20</span>).<span class='ident'>collect</span>(), <span class='string'>b"Hi There"</span>.<span class='ident'>to_vec</span>()), + (<span class='string'>b"Jefe"</span>.<span class='ident'>to_vec</span>(), + <span class='string'>b"what do ya want for nothing?"</span>.<span class='ident'>to_vec</span>()), + (<span class='ident'>repeat</span>(<span class='number'>0xaa_u8</span>).<span class='ident'>take</span>(<span class='number'>20</span>).<span class='ident'>collect</span>(), <span class='ident'>repeat</span>(<span class='number'>0xdd_u8</span>).<span class='ident'>take</span>(<span class='number'>50</span>).<span class='ident'>collect</span>()), + (<span class='string'>"0102030405060708090a0b0c0d0e0f10111213141516171819"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='ident'>repeat</span>(<span class='number'>0xcd_u8</span>).<span class='ident'>take</span>(<span class='number'>50</span>).<span class='ident'>collect</span>()), + (<span class='ident'>repeat</span>(<span class='number'>0xaa_u8</span>).<span class='ident'>take</span>(<span class='number'>131</span>).<span class='ident'>collect</span>(), + <span class='string'>b"Test Using Larger Than Block-Size Key - Hash Key First"</span>.<span class='ident'>to_vec</span>()), + (<span class='ident'>repeat</span>(<span class='number'>0xaa_u8</span>).<span class='ident'>take</span>(<span class='number'>131</span>).<span class='ident'>collect</span>(), + <span class='string'>b"This is a test using a larger than block-size key and a \ + larger than block-size data. The key needs to be hashed \ + before being used by the HMAC algorithm."</span>.<span class='ident'>to_vec</span>()) + ]; + + <span class='kw'>for</span> (<span class='kw-2'>&</span>(<span class='kw-2'>ref</span> <span class='ident'>key</span>, <span class='kw-2'>ref</span> <span class='ident'>data</span>), <span class='ident'>res</span>) <span class='kw'>in</span> <span class='ident'>tests</span>.<span class='ident'>iter</span>().<span class='ident'>zip</span>(<span class='ident'>results</span>.<span class='ident'>iter</span>()) { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>hmac</span>(<span class='ident'>ty</span>, <span class='kw-2'>&</span><span class='op'>*</span><span class='op'>*</span><span class='ident'>key</span>, <span class='kw-2'>&</span><span class='op'>*</span><span class='op'>*</span><span class='ident'>data</span>), <span class='op'>*</span><span class='ident'>res</span>); + } + + <span class='comment'>// recycle test</span> + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>h</span> <span class='op'>=</span> <span class='ident'>HMAC</span>::<span class='ident'>new</span>(<span class='ident'>ty</span>, <span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>tests</span>[<span class='number'>5</span>].<span class='number'>0</span>); + <span class='kw'>for</span> <span class='ident'>i</span> <span class='kw'>in</span> <span class='number'>0</span>..<span class='number'>100usize</span> { + <span class='kw'>let</span> <span class='ident'>test</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='ident'>tests</span>[<span class='number'>4</span> <span class='op'>+</span> <span class='ident'>i</span> <span class='op'>%</span> <span class='number'>2</span>]; + <span class='kw'>let</span> <span class='ident'>tup</span> <span class='op'>=</span> (<span class='ident'>test</span>.<span class='number'>0</span>.<span class='ident'>clone</span>(), <span class='ident'>test</span>.<span class='number'>1</span>.<span class='ident'>clone</span>(), <span class='ident'>results</span>[<span class='number'>4</span> <span class='op'>+</span> <span class='ident'>i</span> <span class='op'>%</span> <span class='number'>2</span>].<span class='ident'>clone</span>()); + <span class='ident'>test_hmac_recycle</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>h</span>, <span class='kw-2'>&</span><span class='ident'>tup</span>); + } + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_hmac_sha224</span>() { + <span class='kw'>let</span> <span class='ident'>results</span> <span class='op'>=</span> [ + <span class='string'>"896fb1128abbdf196832107cd49df33f47b4b1169912ba4f53684b22"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"7fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333ea"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"6c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"95e9a0db962095adaebe9b2d6f0dbce2d499f112f2d2b7273fa6870e"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"3a854166ac5d9f023f54d517d0b39dbd946770db9c2b95c9f6f565d1"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>() + ]; + <span class='ident'>test_sha2</span>(<span class='ident'>SHA224</span>, <span class='kw-2'>&</span><span class='ident'>results</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_hmac_sha256</span>() { + <span class='kw'>let</span> <span class='ident'>results</span> <span class='op'>=</span> [ + <span class='string'>"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>() + ]; + <span class='ident'>test_sha2</span>(<span class='ident'>SHA256</span>, <span class='kw-2'>&</span><span class='ident'>results</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_hmac_sha384</span>() { + <span class='kw'>let</span> <span class='ident'>results</span> <span class='op'>=</span> [ + <span class='string'>"afd03944d84895626b0825f4ab46907f\ + 15f9dadbe4101ec682aa034c7cebc59c\ + faea9ea9076ede7f4af152e8b2fa9cb6"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"af45d2e376484031617f78d2b58a6b1b\ + 9c7ef464f5a01b47e42ec3736322445e\ + 8e2240ca5e69e2c78b3239ecfab21649"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"88062608d3e6ad8a0aa2ace014c8a86f\ + 0aa635d947ac9febe83ef4e55966144b\ + 2a5ab39dc13814b94e3ab6e101a34f27"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"3e8a69b7783c25851933ab6290af6ca7\ + 7a9981480850009cc5577c6e1f573b4e\ + 6801dd23c4a7d679ccf8a386c674cffb"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"4ece084485813e9088d2c63a041bc5b4\ + 4f9ef1012a2b588f3cd11f05033ac4c6\ + 0c2ef6ab4030fe8296248df163f44952"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"6617178e941f020d351e2f254e8fd32c\ + 602420feb0b8fb9adccebb82461e99c5\ + a678cc31e799176d3860e6110c46523e"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>() + ]; + <span class='ident'>test_sha2</span>(<span class='ident'>SHA384</span>, <span class='kw-2'>&</span><span class='ident'>results</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_hmac_sha512</span>() { + <span class='kw'>let</span> <span class='ident'>results</span> <span class='op'>=</span> [ + <span class='string'>"87aa7cdea5ef619d4ff0b4241a1d6cb0\ + 2379f4e2ce4ec2787ad0b30545e17cde\ + daa833b7d6b8a702038b274eaea3f4e4\ + be9d914eeb61f1702e696c203a126854"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"164b7a7bfcf819e2e395fbe73b56e0a3\ + 87bd64222e831fd610270cd7ea250554\ + 9758bf75c05a994a6d034f65f8f0e6fd\ + caeab1a34d4a6b4b636e070a38bce737"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"fa73b0089d56a284efb0f0756c890be9\ + b1b5dbdd8ee81a3655f83e33b2279d39\ + bf3e848279a722c806b485a47e67c807\ + b946a337bee8942674278859e13292fb"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"b0ba465637458c6990e5a8c5f61d4af7\ + e576d97ff94b872de76f8050361ee3db\ + a91ca5c11aa25eb4d679275cc5788063\ + a5f19741120c4f2de2adebeb10a298dd"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"80b24263c7c1a3ebb71493c1dd7be8b4\ + 9b46d1f41b4aeec1121b013783f8f352\ + 6b56d037e05f2598bd0fd2215d6a1e52\ + 95e64f73f63f0aec8b915a985d786598"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), + <span class='string'>"e37b6a775dc87dbaa4dfa9f96e5e3ffd\ + debd71f8867289865df5a32d20cdc944\ + b6022cac3c4982b10d5eeb55c3e4de15\ + 134676fb6de0446065c97440fa8c6a58"</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>() + ]; + <span class='ident'>test_sha2</span>(<span class='ident'>SHA512</span>, <span class='kw-2'>&</span><span class='ident'>results</span>); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl"; + window.playgroundUrl = ""; + </script> + <script src="../../../jquery.js"></script> + <script src="../../../main.js"></script> + + <script async src="../../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl/crypto/memcmp.rs.html b/src/openssl/crypto/memcmp.rs.html new file mode 100644 index 0000000..ecc2b6d --- /dev/null +++ b/src/openssl/crypto/memcmp.rs.html @@ -0,0 +1,175 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-0.6.3/src/crypto/memcmp.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>memcmp.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10">10</span> +<span id="11">11</span> +<span id="12">12</span> +<span id="13">13</span> +<span id="14">14</span> +<span id="15">15</span> +<span id="16">16</span> +<span id="17">17</span> +<span id="18">18</span> +<span id="19">19</span> +<span id="20">20</span> +<span id="21">21</span> +<span id="22">22</span> +<span id="23">23</span> +<span id="24">24</span> +<span id="25">25</span> +<span id="26">26</span> +<span id="27">27</span> +<span id="28">28</span> +<span id="29">29</span> +<span id="30">30</span> +<span id="31">31</span> +<span id="32">32</span> +<span id="33">33</span> +<span id="34">34</span> +<span id="35">35</span> +<span id="36">36</span> +<span id="37">37</span> +<span id="38">38</span> +<span id="39">39</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>libc</span>::<span class='ident'>size_t</span>; +<span class='kw'>use</span> <span class='ident'>ffi</span>; + +<span class='doccomment'>/// Returns `true` iff `a` and `b` contain the same bytes.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This operation takes an amount of time dependent on the length of the two</span> +<span class='doccomment'>/// arrays given, but is independent of the contents of a and b.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Failure</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This function will panic the current task if `a` and `b` do not have the same</span> +<span class='doccomment'>/// length.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>eq</span>(<span class='ident'>a</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>], <span class='ident'>b</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>a</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='ident'>b</span>.<span class='ident'>len</span>()); + <span class='kw'>let</span> <span class='ident'>ret</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>CRYPTO_memcmp</span>(<span class='ident'>a</span>.<span class='ident'>as_ptr</span>() <span class='kw'>as</span> <span class='op'>*</span><span class='kw'>const</span> _, + <span class='ident'>b</span>.<span class='ident'>as_ptr</span>() <span class='kw'>as</span> <span class='op'>*</span><span class='kw'>const</span> _, + <span class='ident'>a</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>size_t</span>) + }; + <span class='ident'>ret</span> <span class='op'>==</span> <span class='number'>0</span> +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>tests</span> { + <span class='kw'>use</span> <span class='ident'>super</span>::<span class='ident'>eq</span>; + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_eq</span>() { + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>eq</span>(<span class='kw-2'>&</span>[], <span class='kw-2'>&</span>[])); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>eq</span>(<span class='kw-2'>&</span>[<span class='number'>1</span>], <span class='kw-2'>&</span>[<span class='number'>1</span>])); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>eq</span>(<span class='kw-2'>&</span>[<span class='number'>1</span>, <span class='number'>2</span>, <span class='number'>3</span>], <span class='kw-2'>&</span>[<span class='number'>1</span>, <span class='number'>2</span>, <span class='number'>4</span>])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='attribute'>#[<span class='ident'>should_panic</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_diff_lens</span>() { + <span class='ident'>eq</span>(<span class='kw-2'>&</span>[], <span class='kw-2'>&</span>[<span class='number'>1</span>]); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl"; + window.playgroundUrl = ""; + </script> + <script src="../../../jquery.js"></script> + <script src="../../../main.js"></script> + + <script async src="../../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl/crypto/mod.rs.html b/src/openssl/crypto/mod.rs.html new file mode 100644 index 0000000..47e1c77 --- /dev/null +++ b/src/openssl/crypto/mod.rs.html @@ -0,0 +1,145 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-0.6.3/src/crypto/mod.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>mod.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10">10</span> +<span id="11">11</span> +<span id="12">12</span> +<span id="13">13</span> +<span id="14">14</span> +<span id="15">15</span> +<span id="16">16</span> +<span id="17">17</span> +<span id="18">18</span> +<span id="19">19</span> +<span id="20">20</span> +<span id="21">21</span> +<span id="22">22</span> +<span id="23">23</span> +<span id="24">24</span> +</pre><pre class='rust '> +<span class='comment'>/* + * Copyright 2011 Google Inc. + * 2013 Jack Lloyd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */</span> + +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>hash</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>hmac</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>pkcs5</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>pkey</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>rand</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>symm</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>memcmp</span>; +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl"; + window.playgroundUrl = ""; + </script> + <script src="../../../jquery.js"></script> + <script src="../../../main.js"></script> + + <script async src="../../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl/crypto/pkcs5.rs.html b/src/openssl/crypto/pkcs5.rs.html new file mode 100644 index 0000000..5ac11c1 --- /dev/null +++ b/src/openssl/crypto/pkcs5.rs.html @@ -0,0 +1,335 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-0.6.3/src/crypto/pkcs5.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>pkcs5.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>libc</span>::<span class='ident'>c_int</span>; +<span class='kw'>use</span> <span class='ident'>ffi</span>; + +<span class='doccomment'>/// Derives a key from a password and salt using the PBKDF2-HMAC-SHA1 algorithm.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>pbkdf2_hmac_sha1</span>(<span class='ident'>pass</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>salt</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>], <span class='ident'>iter</span>: <span class='ident'>usize</span>, <span class='ident'>keylen</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>iter</span> <span class='op'>>=</span> <span class='number'>1</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>keylen</span> <span class='op'>>=</span> <span class='number'>1</span>); + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>out</span> <span class='op'>=</span> <span class='ident'>Vec</span>::<span class='ident'>with_capacity</span>(<span class='ident'>keylen</span>); + + <span class='ident'>ffi</span>::<span class='ident'>init</span>(); + + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>PKCS5_PBKDF2_HMAC_SHA1</span>( + <span class='ident'>pass</span>.<span class='ident'>as_ptr</span>(), <span class='ident'>pass</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>c_int</span>, + <span class='ident'>salt</span>.<span class='ident'>as_ptr</span>(), <span class='ident'>salt</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>c_int</span>, + <span class='ident'>iter</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, <span class='ident'>keylen</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, + <span class='ident'>out</span>.<span class='ident'>as_mut_ptr</span>()); + + <span class='kw'>if</span> <span class='ident'>r</span> <span class='op'>!=</span> <span class='number'>1</span> { <span class='macro'>panic</span><span class='macro'>!</span>(); } + + <span class='ident'>out</span>.<span class='ident'>set_len</span>(<span class='ident'>keylen</span>); + + <span class='ident'>out</span> + } +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>tests</span> { + <span class='comment'>// Test vectors from</span> + <span class='comment'>// http://tools.ietf.org/html/draft-josefsson-pbkdf2-test-vectors-06</span> + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_pbkdf2_hmac_sha1</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>( + <span class='ident'>super</span>::<span class='ident'>pbkdf2_hmac_sha1</span>( + <span class='string'>"password"</span>, + <span class='string'>"salt"</span>.<span class='ident'>as_bytes</span>(), + <span class='number'>1</span>, + <span class='number'>20</span> + ), + <span class='macro'>vec</span><span class='macro'>!</span>( + <span class='number'>0x0c_u8</span>, <span class='number'>0x60_u8</span>, <span class='number'>0xc8_u8</span>, <span class='number'>0x0f_u8</span>, <span class='number'>0x96_u8</span>, <span class='number'>0x1f_u8</span>, <span class='number'>0x0e_u8</span>, + <span class='number'>0x71_u8</span>, <span class='number'>0xf3_u8</span>, <span class='number'>0xa9_u8</span>, <span class='number'>0xb5_u8</span>, <span class='number'>0x24_u8</span>, <span class='number'>0xaf_u8</span>, <span class='number'>0x60_u8</span>, + <span class='number'>0x12_u8</span>, <span class='number'>0x06_u8</span>, <span class='number'>0x2f_u8</span>, <span class='number'>0xe0_u8</span>, <span class='number'>0x37_u8</span>, <span class='number'>0xa6_u8</span> + ) + ); + + <span class='macro'>assert_eq</span><span class='macro'>!</span>( + <span class='ident'>super</span>::<span class='ident'>pbkdf2_hmac_sha1</span>( + <span class='string'>"password"</span>, + <span class='string'>"salt"</span>.<span class='ident'>as_bytes</span>(), + <span class='number'>2</span>, + <span class='number'>20</span> + ), + <span class='macro'>vec</span><span class='macro'>!</span>( + <span class='number'>0xea_u8</span>, <span class='number'>0x6c_u8</span>, <span class='number'>0x01_u8</span>, <span class='number'>0x4d_u8</span>, <span class='number'>0xc7_u8</span>, <span class='number'>0x2d_u8</span>, <span class='number'>0x6f_u8</span>, + <span class='number'>0x8c_u8</span>, <span class='number'>0xcd_u8</span>, <span class='number'>0x1e_u8</span>, <span class='number'>0xd9_u8</span>, <span class='number'>0x2a_u8</span>, <span class='number'>0xce_u8</span>, <span class='number'>0x1d_u8</span>, + <span class='number'>0x41_u8</span>, <span class='number'>0xf0_u8</span>, <span class='number'>0xd8_u8</span>, <span class='number'>0xde_u8</span>, <span class='number'>0x89_u8</span>, <span class='number'>0x57_u8</span> + ) + ); + + <span class='macro'>assert_eq</span><span class='macro'>!</span>( + <span class='ident'>super</span>::<span class='ident'>pbkdf2_hmac_sha1</span>( + <span class='string'>"password"</span>, + <span class='string'>"salt"</span>.<span class='ident'>as_bytes</span>(), + <span class='number'>4096</span>, + <span class='number'>20</span> + ), + <span class='macro'>vec</span><span class='macro'>!</span>( + <span class='number'>0x4b_u8</span>, <span class='number'>0x00_u8</span>, <span class='number'>0x79_u8</span>, <span class='number'>0x01_u8</span>, <span class='number'>0xb7_u8</span>, <span class='number'>0x65_u8</span>, <span class='number'>0x48_u8</span>, + <span class='number'>0x9a_u8</span>, <span class='number'>0xbe_u8</span>, <span class='number'>0xad_u8</span>, <span class='number'>0x49_u8</span>, <span class='number'>0xd9_u8</span>, <span class='number'>0x26_u8</span>, <span class='number'>0xf7_u8</span>, + <span class='number'>0x21_u8</span>, <span class='number'>0xd0_u8</span>, <span class='number'>0x65_u8</span>, <span class='number'>0xa4_u8</span>, <span class='number'>0x29_u8</span>, <span class='number'>0xc1_u8</span> + ) + ); + + <span class='macro'>assert_eq</span><span class='macro'>!</span>( + <span class='ident'>super</span>::<span class='ident'>pbkdf2_hmac_sha1</span>( + <span class='string'>"password"</span>, + <span class='string'>"salt"</span>.<span class='ident'>as_bytes</span>(), + <span class='number'>16777216</span>, + <span class='number'>20</span> + ), + <span class='macro'>vec</span><span class='macro'>!</span>( + <span class='number'>0xee_u8</span>, <span class='number'>0xfe_u8</span>, <span class='number'>0x3d_u8</span>, <span class='number'>0x61_u8</span>, <span class='number'>0xcd_u8</span>, <span class='number'>0x4d_u8</span>, <span class='number'>0xa4_u8</span>, + <span class='number'>0xe4_u8</span>, <span class='number'>0xe9_u8</span>, <span class='number'>0x94_u8</span>, <span class='number'>0x5b_u8</span>, <span class='number'>0x3d_u8</span>, <span class='number'>0x6b_u8</span>, <span class='number'>0xa2_u8</span>, + <span class='number'>0x15_u8</span>, <span class='number'>0x8c_u8</span>, <span class='number'>0x26_u8</span>, <span class='number'>0x34_u8</span>, <span class='number'>0xe9_u8</span>, <span class='number'>0x84_u8</span> + ) + ); + + <span class='macro'>assert_eq</span><span class='macro'>!</span>( + <span class='ident'>super</span>::<span class='ident'>pbkdf2_hmac_sha1</span>( + <span class='string'>"passwordPASSWORDpassword"</span>, + <span class='string'>"saltSALTsaltSALTsaltSALTsaltSALTsalt"</span>.<span class='ident'>as_bytes</span>(), + <span class='number'>4096</span>, + <span class='number'>25</span> + ), + <span class='macro'>vec</span><span class='macro'>!</span>( + <span class='number'>0x3d_u8</span>, <span class='number'>0x2e_u8</span>, <span class='number'>0xec_u8</span>, <span class='number'>0x4f_u8</span>, <span class='number'>0xe4_u8</span>, <span class='number'>0x1c_u8</span>, <span class='number'>0x84_u8</span>, + <span class='number'>0x9b_u8</span>, <span class='number'>0x80_u8</span>, <span class='number'>0xc8_u8</span>, <span class='number'>0xd8_u8</span>, <span class='number'>0x36_u8</span>, <span class='number'>0x62_u8</span>, <span class='number'>0xc0_u8</span>, + <span class='number'>0xe4_u8</span>, <span class='number'>0x4a_u8</span>, <span class='number'>0x8b_u8</span>, <span class='number'>0x29_u8</span>, <span class='number'>0x1a_u8</span>, <span class='number'>0x96_u8</span>, <span class='number'>0x4c_u8</span>, + <span class='number'>0xf2_u8</span>, <span class='number'>0xf0_u8</span>, <span class='number'>0x70_u8</span>, <span class='number'>0x38_u8</span> + ) + ); + + <span class='macro'>assert_eq</span><span class='macro'>!</span>( + <span class='ident'>super</span>::<span class='ident'>pbkdf2_hmac_sha1</span>( + <span class='string'>"pass\x00word"</span>, + <span class='string'>"sa\x00lt"</span>.<span class='ident'>as_bytes</span>(), + <span class='number'>4096</span>, + <span class='number'>16</span> + ), + <span class='macro'>vec</span><span class='macro'>!</span>( + <span class='number'>0x56_u8</span>, <span class='number'>0xfa_u8</span>, <span class='number'>0x6a_u8</span>, <span class='number'>0xa7_u8</span>, <span class='number'>0x55_u8</span>, <span class='number'>0x48_u8</span>, <span class='number'>0x09_u8</span>, + <span class='number'>0x9d_u8</span>, <span class='number'>0xcc_u8</span>, <span class='number'>0x37_u8</span>, <span class='number'>0xd7_u8</span>, <span class='number'>0xf0_u8</span>, <span class='number'>0x34_u8</span>, <span class='number'>0x25_u8</span>, + <span class='number'>0xe0_u8</span>, <span class='number'>0xc3_u8</span> + ) + ); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl"; + window.playgroundUrl = ""; + </script> + <script src="../../../jquery.js"></script> + <script src="../../../main.js"></script> + + <script async src="../../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl/crypto/pkey.rs.html b/src/openssl/crypto/pkey.rs.html new file mode 100644 index 0000000..4b93f74 --- /dev/null +++ b/src/openssl/crypto/pkey.rs.html @@ -0,0 +1,1103 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-0.6.3/src/crypto/pkey.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>pkey.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +<span id="313">313</span> +<span id="314">314</span> +<span id="315">315</span> +<span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +<span id="326">326</span> +<span id="327">327</span> +<span id="328">328</span> +<span id="329">329</span> +<span id="330">330</span> +<span id="331">331</span> +<span id="332">332</span> +<span id="333">333</span> +<span id="334">334</span> +<span id="335">335</span> +<span id="336">336</span> +<span id="337">337</span> +<span id="338">338</span> +<span id="339">339</span> +<span id="340">340</span> +<span id="341">341</span> +<span id="342">342</span> +<span id="343">343</span> +<span id="344">344</span> +<span id="345">345</span> +<span id="346">346</span> +<span id="347">347</span> +<span id="348">348</span> +<span id="349">349</span> +<span id="350">350</span> +<span id="351">351</span> +<span id="352">352</span> +<span id="353">353</span> +<span id="354">354</span> +<span id="355">355</span> +<span id="356">356</span> +<span id="357">357</span> +<span id="358">358</span> +<span id="359">359</span> +<span id="360">360</span> +<span id="361">361</span> +<span id="362">362</span> +<span id="363">363</span> +<span id="364">364</span> +<span id="365">365</span> +<span id="366">366</span> +<span id="367">367</span> +<span id="368">368</span> +<span id="369">369</span> +<span id="370">370</span> +<span id="371">371</span> +<span id="372">372</span> +<span id="373">373</span> +<span id="374">374</span> +<span id="375">375</span> +<span id="376">376</span> +<span id="377">377</span> +<span id="378">378</span> +<span id="379">379</span> +<span id="380">380</span> +<span id="381">381</span> +<span id="382">382</span> +<span id="383">383</span> +<span id="384">384</span> +<span id="385">385</span> +<span id="386">386</span> +<span id="387">387</span> +<span id="388">388</span> +<span id="389">389</span> +<span id="390">390</span> +<span id="391">391</span> +<span id="392">392</span> +<span id="393">393</span> +<span id="394">394</span> +<span id="395">395</span> +<span id="396">396</span> +<span id="397">397</span> +<span id="398">398</span> +<span id="399">399</span> +<span id="400">400</span> +<span id="401">401</span> +<span id="402">402</span> +<span id="403">403</span> +<span id="404">404</span> +<span id="405">405</span> +<span id="406">406</span> +<span id="407">407</span> +<span id="408">408</span> +<span id="409">409</span> +<span id="410">410</span> +<span id="411">411</span> +<span id="412">412</span> +<span id="413">413</span> +<span id="414">414</span> +<span id="415">415</span> +<span id="416">416</span> +<span id="417">417</span> +<span id="418">418</span> +<span id="419">419</span> +<span id="420">420</span> +<span id="421">421</span> +<span id="422">422</span> +<span id="423">423</span> +<span id="424">424</span> +<span id="425">425</span> +<span id="426">426</span> +<span id="427">427</span> +<span id="428">428</span> +<span id="429">429</span> +<span id="430">430</span> +<span id="431">431</span> +<span id="432">432</span> +<span id="433">433</span> +<span id="434">434</span> +<span id="435">435</span> +<span id="436">436</span> +<span id="437">437</span> +<span id="438">438</span> +<span id="439">439</span> +<span id="440">440</span> +<span id="441">441</span> +<span id="442">442</span> +<span id="443">443</span> +<span id="444">444</span> +<span id="445">445</span> +<span id="446">446</span> +<span id="447">447</span> +<span id="448">448</span> +<span id="449">449</span> +<span id="450">450</span> +<span id="451">451</span> +<span id="452">452</span> +<span id="453">453</span> +<span id="454">454</span> +<span id="455">455</span> +<span id="456">456</span> +<span id="457">457</span> +<span id="458">458</span> +<span id="459">459</span> +<span id="460">460</span> +<span id="461">461</span> +<span id="462">462</span> +<span id="463">463</span> +<span id="464">464</span> +<span id="465">465</span> +<span id="466">466</span> +<span id="467">467</span> +<span id="468">468</span> +<span id="469">469</span> +<span id="470">470</span> +<span id="471">471</span> +<span id="472">472</span> +<span id="473">473</span> +<span id="474">474</span> +<span id="475">475</span> +<span id="476">476</span> +<span id="477">477</span> +<span id="478">478</span> +<span id="479">479</span> +<span id="480">480</span> +<span id="481">481</span> +<span id="482">482</span> +<span id="483">483</span> +<span id="484">484</span> +<span id="485">485</span> +<span id="486">486</span> +<span id="487">487</span> +<span id="488">488</span> +<span id="489">489</span> +<span id="490">490</span> +<span id="491">491</span> +<span id="492">492</span> +<span id="493">493</span> +<span id="494">494</span> +<span id="495">495</span> +<span id="496">496</span> +<span id="497">497</span> +<span id="498">498</span> +<span id="499">499</span> +<span id="500">500</span> +<span id="501">501</span> +<span id="502">502</span> +<span id="503">503</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>libc</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_uint</span>, <span class='ident'>c_ulong</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>::<span class='ident'>prelude</span>::<span class='op'>*</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>iter</span>::<span class='ident'>repeat</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>mem</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ptr</span>; +<span class='kw'>use</span> <span class='ident'>bio</span>::{<span class='ident'>MemBio</span>}; +<span class='kw'>use</span> <span class='ident'>crypto</span>::<span class='ident'>hash</span>; +<span class='kw'>use</span> <span class='ident'>crypto</span>::<span class='ident'>hash</span>::<span class='ident'>Type</span> <span class='kw'>as</span> <span class='ident'>HashType</span>; +<span class='kw'>use</span> <span class='ident'>ffi</span>; +<span class='kw'>use</span> <span class='ident'>ssl</span>::<span class='ident'>error</span>::{<span class='ident'>SslError</span>, <span class='ident'>StreamError</span>}; + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Parts</span> { + <span class='ident'>Neither</span>, + <span class='ident'>Public</span>, + <span class='ident'>Both</span> +} + +<span class='doccomment'>/// Represents a role an asymmetric key might be appropriate for.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Role</span> { + <span class='ident'>Encrypt</span>, + <span class='ident'>Decrypt</span>, + <span class='ident'>Sign</span>, + <span class='ident'>Verify</span> +} + +<span class='doccomment'>/// Type of encryption padding to use.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>EncryptionPadding</span> { + <span class='ident'>OAEP</span>, + <span class='ident'>PKCS1v15</span> +} + +<span class='kw'>fn</span> <span class='ident'>openssl_padding_code</span>(<span class='ident'>padding</span>: <span class='ident'>EncryptionPadding</span>) <span class='op'>-></span> <span class='ident'>c_int</span> { + <span class='kw'>match</span> <span class='ident'>padding</span> { + <span class='ident'>EncryptionPadding</span>::<span class='ident'>OAEP</span> <span class='op'>=></span> <span class='number'>4</span>, + <span class='ident'>EncryptionPadding</span>::<span class='ident'>PKCS1v15</span> <span class='op'>=></span> <span class='number'>1</span> + } +} + +<span class='kw'>fn</span> <span class='ident'>openssl_hash_nid</span>(<span class='ident'>hash</span>: <span class='ident'>HashType</span>) <span class='op'>-></span> <span class='ident'>c_int</span> { + <span class='kw'>match</span> <span class='ident'>hash</span> { + <span class='ident'>HashType</span>::<span class='ident'>MD5</span> <span class='op'>=></span> <span class='number'>4</span>, <span class='comment'>// NID_md5,</span> + <span class='ident'>HashType</span>::<span class='ident'>SHA1</span> <span class='op'>=></span> <span class='number'>64</span>, <span class='comment'>// NID_sha1</span> + <span class='ident'>HashType</span>::<span class='ident'>SHA224</span> <span class='op'>=></span> <span class='number'>675</span>, <span class='comment'>// NID_sha224</span> + <span class='ident'>HashType</span>::<span class='ident'>SHA256</span> <span class='op'>=></span> <span class='number'>672</span>, <span class='comment'>// NID_sha256</span> + <span class='ident'>HashType</span>::<span class='ident'>SHA384</span> <span class='op'>=></span> <span class='number'>673</span>, <span class='comment'>// NID_sha384</span> + <span class='ident'>HashType</span>::<span class='ident'>SHA512</span> <span class='op'>=></span> <span class='number'>674</span>, <span class='comment'>// NID_sha512</span> + <span class='ident'>HashType</span>::<span class='ident'>RIPEMD160</span> <span class='op'>=></span> <span class='number'>117</span>, <span class='comment'>// NID_ripemd160</span> + } +} + +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>PKey</span> { + <span class='ident'>evp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_PKEY</span>, + <span class='ident'>parts</span>: <span class='ident'>Parts</span>, +} + +<span class='doccomment'>/// Represents a public key, optionally with a private key attached.</span> +<span class='kw'>impl</span> <span class='ident'>PKey</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>() <span class='op'>-></span> <span class='ident'>PKey</span> { + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>init</span>(); + + <span class='ident'>PKey</span> { + <span class='ident'>evp</span>: <span class='ident'>ffi</span>::<span class='ident'>EVP_PKEY_new</span>(), + <span class='ident'>parts</span>: <span class='ident'>Parts</span>::<span class='ident'>Neither</span>, + } + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>from_handle</span>(<span class='ident'>handle</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_PKEY</span>, <span class='ident'>parts</span>: <span class='ident'>Parts</span>) <span class='op'>-></span> <span class='ident'>PKey</span> { + <span class='ident'>ffi</span>::<span class='ident'>init</span>(); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>handle</span>.<span class='ident'>is_null</span>()); + + <span class='ident'>PKey</span> { + <span class='ident'>evp</span>: <span class='ident'>handle</span>, + <span class='ident'>parts</span>: <span class='ident'>parts</span>, + } + } + + <span class='doccomment'>/// Reads private key from PEM, takes ownership of handle</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>private_key_from_pem</span><span class='op'><</span><span class='ident'>R</span><span class='op'>></span>(<span class='ident'>reader</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>R</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>PKey</span>, <span class='ident'>SslError</span><span class='op'>></span> <span class='kw'>where</span> <span class='ident'>R</span>: <span class='ident'>Read</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>mem_bio</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>MemBio</span>::<span class='ident'>new</span>()); + <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>io</span>::<span class='ident'>copy</span>(<span class='ident'>reader</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>mem_bio</span>).<span class='ident'>map_err</span>(<span class='ident'>StreamError</span>)); + + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>evp</span> <span class='op'>=</span> <span class='macro'>try_ssl_null</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>PEM_read_bio_PrivateKey</span>(<span class='ident'>mem_bio</span>.<span class='ident'>get_handle</span>(), + <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>(), + <span class='prelude-val'>None</span>, <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>())); + <span class='prelude-val'>Ok</span>(<span class='ident'>PKey</span> { + <span class='ident'>evp</span>: <span class='ident'>evp</span>, + <span class='ident'>parts</span>: <span class='ident'>Parts</span>::<span class='ident'>Both</span>, + }) + } + } + + <span class='kw'>fn</span> <span class='ident'>_tostr</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw'>unsafe</span> <span class='kw'>extern</span> <span class='string'>"C"</span> <span class='kw'>fn</span>(<span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>RSA</span>, <span class='op'>*</span><span class='kw'>const</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>u8</span>) <span class='op'>-></span> <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>rsa</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_PKEY_get1_RSA</span>(<span class='self'>self</span>.<span class='ident'>evp</span>); + <span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='ident'>f</span>(<span class='ident'>rsa</span>, <span class='ident'>ptr</span>::<span class='ident'>null</span>()); + <span class='kw'>if</span> <span class='ident'>len</span> <span class='op'><</span> <span class='number'>0</span> <span class='kw'>as</span> <span class='ident'>c_int</span> { <span class='kw'>return</span> <span class='macro'>vec</span><span class='macro'>!</span>(); } + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>repeat</span>(<span class='number'>0u8</span>).<span class='ident'>take</span>(<span class='ident'>len</span> <span class='kw'>as</span> <span class='ident'>usize</span>).<span class='ident'>collect</span>::<span class='op'><</span><span class='ident'>Vec</span><span class='op'><</span>_<span class='op'>>></span>(); + + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>f</span>(<span class='ident'>rsa</span>, <span class='kw-2'>&</span><span class='ident'>s</span>.<span class='ident'>as_mut_ptr</span>()); + + <span class='ident'>s</span>.<span class='ident'>truncate</span>(<span class='ident'>r</span> <span class='kw'>as</span> <span class='ident'>usize</span>); + <span class='ident'>s</span> + } + } + + <span class='kw'>fn</span> <span class='ident'>_fromstr</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>], <span class='ident'>f</span>: <span class='kw'>unsafe</span> <span class='kw'>extern</span> <span class='string'>"C"</span> <span class='kw'>fn</span>(<span class='op'>*</span><span class='kw'>const</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>RSA</span>, <span class='op'>*</span><span class='kw'>const</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>u8</span>, <span class='ident'>c_uint</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>RSA</span>) { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>rsa</span> <span class='op'>=</span> <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>(); + <span class='ident'>f</span>(<span class='kw-2'>&</span><span class='ident'>rsa</span>, <span class='kw-2'>&</span><span class='ident'>s</span>.<span class='ident'>as_ptr</span>(), <span class='ident'>s</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>c_uint</span>); + <span class='ident'>ffi</span>::<span class='ident'>EVP_PKEY_set1_RSA</span>(<span class='self'>self</span>.<span class='ident'>evp</span>, <span class='ident'>rsa</span>); + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>gen</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>keysz</span>: <span class='ident'>usize</span>) { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>rsa</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>RSA_generate_key</span>( + <span class='ident'>keysz</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, + <span class='number'>65537</span> <span class='kw'>as</span> <span class='ident'>c_ulong</span>, + <span class='ident'>ptr</span>::<span class='ident'>null</span>(), + <span class='ident'>ptr</span>::<span class='ident'>null</span>() + ); + + <span class='comment'>// XXX: 6 == NID_rsaEncryption</span> + <span class='ident'>ffi</span>::<span class='ident'>EVP_PKEY_assign</span>( + <span class='self'>self</span>.<span class='ident'>evp</span>, + <span class='number'>6</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, + <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='ident'>rsa</span>)); + + <span class='self'>self</span>.<span class='ident'>parts</span> <span class='op'>=</span> <span class='ident'>Parts</span>::<span class='ident'>Both</span>; + } + } + + <span class='doccomment'>/** + * Returns a serialized form of the public key, suitable for load_pub(). + */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>save_pub</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>_tostr</span>(<span class='ident'>ffi</span>::<span class='ident'>i2d_RSA_PUBKEY</span>) + } + + <span class='doccomment'>/** + * Loads a serialized form of the public key, as produced by save_pub(). + */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>load_pub</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) { + <span class='self'>self</span>.<span class='ident'>_fromstr</span>(<span class='ident'>s</span>, <span class='ident'>ffi</span>::<span class='ident'>d2i_RSA_PUBKEY</span>); + <span class='self'>self</span>.<span class='ident'>parts</span> <span class='op'>=</span> <span class='ident'>Parts</span>::<span class='ident'>Public</span>; + } + + <span class='doccomment'>/** + * Returns a serialized form of the public and private keys, suitable for + * load_priv(). + */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>save_priv</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>_tostr</span>(<span class='ident'>ffi</span>::<span class='ident'>i2d_RSAPrivateKey</span>) + } + <span class='doccomment'>/** + * Loads a serialized form of the public and private keys, as produced by + * save_priv(). + */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>load_priv</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) { + <span class='self'>self</span>.<span class='ident'>_fromstr</span>(<span class='ident'>s</span>, <span class='ident'>ffi</span>::<span class='ident'>d2i_RSAPrivateKey</span>); + <span class='self'>self</span>.<span class='ident'>parts</span> <span class='op'>=</span> <span class='ident'>Parts</span>::<span class='ident'>Both</span>; + } + + <span class='doccomment'>/// Stores private key as a PEM</span> + <span class='comment'>// FIXME: also add password and encryption</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>write_pem</span><span class='op'><</span><span class='ident'>W</span>: <span class='ident'>Write</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>writer</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>W</span><span class='comment'>/*, password: Option<String>*/</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(), <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>mem_bio</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>MemBio</span>::<span class='ident'>new</span>()); + <span class='kw'>unsafe</span> { + <span class='macro'>try_ssl</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>PEM_write_bio_PrivateKey</span>(<span class='ident'>mem_bio</span>.<span class='ident'>get_handle</span>(), <span class='self'>self</span>.<span class='ident'>evp</span>, <span class='ident'>ptr</span>::<span class='ident'>null</span>(), + <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>(), <span class='op'>-</span><span class='number'>1</span>, <span class='prelude-val'>None</span>, <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>())); + + } + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>buf</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[]; + <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>mem_bio</span>.<span class='ident'>read_to_end</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>buf</span>).<span class='ident'>map_err</span>(<span class='ident'>StreamError</span>)); + <span class='ident'>writer</span>.<span class='ident'>write_all</span>(<span class='kw-2'>&</span><span class='ident'>buf</span>).<span class='ident'>map_err</span>(<span class='ident'>StreamError</span>) + } + + <span class='doccomment'>/** + * Returns the size of the public key modulus. + */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>size</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>RSA_size</span>(<span class='ident'>ffi</span>::<span class='ident'>EVP_PKEY_get1_RSA</span>(<span class='self'>self</span>.<span class='ident'>evp</span>)) <span class='kw'>as</span> <span class='ident'>usize</span> + } + } + + <span class='doccomment'>/** + * Returns whether this pkey object can perform the specified role. + */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>can</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>r</span>: <span class='ident'>Role</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>match</span> <span class='ident'>r</span> { + <span class='ident'>Role</span>::<span class='ident'>Encrypt</span> <span class='op'>=></span> + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>parts</span> { + <span class='ident'>Parts</span>::<span class='ident'>Neither</span> <span class='op'>=></span> <span class='boolval'>false</span>, + _ <span class='op'>=></span> <span class='boolval'>true</span>, + }, + <span class='ident'>Role</span>::<span class='ident'>Verify</span> <span class='op'>=></span> + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>parts</span> { + <span class='ident'>Parts</span>::<span class='ident'>Neither</span> <span class='op'>=></span> <span class='boolval'>false</span>, + _ <span class='op'>=></span> <span class='boolval'>true</span>, + }, + <span class='ident'>Role</span>::<span class='ident'>Decrypt</span> <span class='op'>=></span> + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>parts</span> { + <span class='ident'>Parts</span>::<span class='ident'>Both</span> <span class='op'>=></span> <span class='boolval'>true</span>, + _ <span class='op'>=></span> <span class='boolval'>false</span>, + }, + <span class='ident'>Role</span>::<span class='ident'>Sign</span> <span class='op'>=></span> + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>parts</span> { + <span class='ident'>Parts</span>::<span class='ident'>Both</span> <span class='op'>=></span> <span class='boolval'>true</span>, + _ <span class='op'>=></span> <span class='boolval'>false</span>, + }, + } + } + + <span class='doccomment'>/** + * Returns the maximum amount of data that can be encrypted by an encrypt() + * call. + */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>max_data</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>rsa</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_PKEY_get1_RSA</span>(<span class='self'>self</span>.<span class='ident'>evp</span>); + <span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>RSA_size</span>(<span class='ident'>rsa</span>); + + <span class='comment'>// 41 comes from RSA_public_encrypt(3) for OAEP</span> + <span class='ident'>len</span> <span class='kw'>as</span> <span class='ident'>usize</span> <span class='op'>-</span> <span class='number'>41</span> + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>encrypt_with_padding</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>], <span class='ident'>padding</span>: <span class='ident'>EncryptionPadding</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>rsa</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_PKEY_get1_RSA</span>(<span class='self'>self</span>.<span class='ident'>evp</span>); + <span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>RSA_size</span>(<span class='ident'>rsa</span>); + + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>len</span>() <span class='op'><</span> <span class='self'>self</span>.<span class='ident'>max_data</span>()); + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>repeat</span>(<span class='number'>0u8</span>).<span class='ident'>take</span>(<span class='ident'>len</span> <span class='kw'>as</span> <span class='ident'>usize</span> <span class='op'>+</span> <span class='number'>1</span>).<span class='ident'>collect</span>::<span class='op'><</span><span class='ident'>Vec</span><span class='op'><</span>_<span class='op'>>></span>(); + + <span class='kw'>let</span> <span class='ident'>rv</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>RSA_public_encrypt</span>( + <span class='ident'>s</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>c_int</span>, + <span class='ident'>s</span>.<span class='ident'>as_ptr</span>(), + <span class='ident'>r</span>.<span class='ident'>as_mut_ptr</span>(), + <span class='ident'>rsa</span>, + <span class='ident'>openssl_padding_code</span>(<span class='ident'>padding</span>)); + + <span class='kw'>if</span> <span class='ident'>rv</span> <span class='op'><</span> <span class='number'>0</span> <span class='kw'>as</span> <span class='ident'>c_int</span> { + <span class='macro'>vec</span><span class='macro'>!</span>() + } <span class='kw'>else</span> { + <span class='ident'>r</span>.<span class='ident'>truncate</span>(<span class='ident'>rv</span> <span class='kw'>as</span> <span class='ident'>usize</span>); + <span class='ident'>r</span> + } + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>decrypt_with_padding</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>], <span class='ident'>padding</span>: <span class='ident'>EncryptionPadding</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>rsa</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_PKEY_get1_RSA</span>(<span class='self'>self</span>.<span class='ident'>evp</span>); + <span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>RSA_size</span>(<span class='ident'>rsa</span>); + + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>c_int</span>, <span class='ident'>ffi</span>::<span class='ident'>RSA_size</span>(<span class='ident'>rsa</span>)); + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>repeat</span>(<span class='number'>0u8</span>).<span class='ident'>take</span>(<span class='ident'>len</span> <span class='kw'>as</span> <span class='ident'>usize</span> <span class='op'>+</span> <span class='number'>1</span>).<span class='ident'>collect</span>::<span class='op'><</span><span class='ident'>Vec</span><span class='op'><</span>_<span class='op'>>></span>(); + + <span class='kw'>let</span> <span class='ident'>rv</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>RSA_private_decrypt</span>( + <span class='ident'>s</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>c_int</span>, + <span class='ident'>s</span>.<span class='ident'>as_ptr</span>(), + <span class='ident'>r</span>.<span class='ident'>as_mut_ptr</span>(), + <span class='ident'>rsa</span>, + <span class='ident'>openssl_padding_code</span>(<span class='ident'>padding</span>)); + + <span class='kw'>if</span> <span class='ident'>rv</span> <span class='op'><</span> <span class='number'>0</span> <span class='kw'>as</span> <span class='ident'>c_int</span> { + <span class='macro'>vec</span><span class='macro'>!</span>() + } <span class='kw'>else</span> { + <span class='ident'>r</span>.<span class='ident'>truncate</span>(<span class='ident'>rv</span> <span class='kw'>as</span> <span class='ident'>usize</span>); + <span class='ident'>r</span> + } + } + } + + <span class='doccomment'>/** + * Encrypts data using OAEP padding, returning the encrypted data. The + * supplied data must not be larger than max_data(). + */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>encrypt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { <span class='self'>self</span>.<span class='ident'>encrypt_with_padding</span>(<span class='ident'>s</span>, <span class='ident'>EncryptionPadding</span>::<span class='ident'>OAEP</span>) } + + <span class='doccomment'>/** + * Decrypts data, expecting OAEP padding, returning the decrypted data. + */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>decrypt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { <span class='self'>self</span>.<span class='ident'>decrypt_with_padding</span>(<span class='ident'>s</span>, <span class='ident'>EncryptionPadding</span>::<span class='ident'>OAEP</span>) } + + <span class='doccomment'>/** + * Signs data, using OpenSSL's default scheme and adding sha256 ASN.1 information to the + * signature. + * The bytes to sign must be the result of a sha256 hashing; + * returns the signature. + */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>sign</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { <span class='self'>self</span>.<span class='ident'>sign_with_hash</span>(<span class='ident'>s</span>, <span class='ident'>HashType</span>::<span class='ident'>SHA256</span>) } + + <span class='doccomment'>/** + * Verifies a signature s (using OpenSSL's default scheme and sha256) on the SHA256 hash of a + * message. + * Returns true if the signature is valid, and false otherwise. + */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>verify</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>h</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>], <span class='ident'>s</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>bool</span> { <span class='self'>self</span>.<span class='ident'>verify_with_hash</span>(<span class='ident'>h</span>, <span class='ident'>s</span>, <span class='ident'>HashType</span>::<span class='ident'>SHA256</span>) } + + <span class='doccomment'>/** + * Signs data, using OpenSSL's default scheme and add ASN.1 information for the given hash type to the + * signature. + * The bytes to sign must be the result of this type of hashing; + * returns the signature. + */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>sign_with_hash</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>s</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>], <span class='ident'>hash</span>: <span class='ident'>hash</span>::<span class='ident'>Type</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>rsa</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_PKEY_get1_RSA</span>(<span class='self'>self</span>.<span class='ident'>evp</span>); + <span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>RSA_size</span>(<span class='ident'>rsa</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>repeat</span>(<span class='number'>0u8</span>).<span class='ident'>take</span>(<span class='ident'>len</span> <span class='kw'>as</span> <span class='ident'>usize</span> <span class='op'>+</span> <span class='number'>1</span>).<span class='ident'>collect</span>::<span class='op'><</span><span class='ident'>Vec</span><span class='op'><</span>_<span class='op'>>></span>(); + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>let</span> <span class='ident'>rv</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>RSA_sign</span>( + <span class='ident'>openssl_hash_nid</span>(<span class='ident'>hash</span>), + <span class='ident'>s</span>.<span class='ident'>as_ptr</span>(), + <span class='ident'>s</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>c_uint</span>, + <span class='ident'>r</span>.<span class='ident'>as_mut_ptr</span>(), + <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>len</span>, + <span class='ident'>rsa</span>); + + <span class='kw'>if</span> <span class='ident'>rv</span> <span class='op'><</span> <span class='number'>0</span> <span class='kw'>as</span> <span class='ident'>c_int</span> { + <span class='macro'>vec</span><span class='macro'>!</span>() + } <span class='kw'>else</span> { + <span class='ident'>r</span>.<span class='ident'>truncate</span>(<span class='ident'>len</span> <span class='kw'>as</span> <span class='ident'>usize</span>); + <span class='ident'>r</span> + } + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>verify_with_hash</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>h</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>], <span class='ident'>s</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>], <span class='ident'>hash</span>: <span class='ident'>hash</span>::<span class='ident'>Type</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>rsa</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_PKEY_get1_RSA</span>(<span class='self'>self</span>.<span class='ident'>evp</span>); + + <span class='kw'>let</span> <span class='ident'>rv</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>RSA_verify</span>( + <span class='ident'>openssl_hash_nid</span>(<span class='ident'>hash</span>), + <span class='ident'>h</span>.<span class='ident'>as_ptr</span>(), + <span class='ident'>h</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>c_uint</span>, + <span class='ident'>s</span>.<span class='ident'>as_ptr</span>(), + <span class='ident'>s</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>c_uint</span>, + <span class='ident'>rsa</span> + ); + + <span class='ident'>rv</span> <span class='op'>==</span> <span class='number'>1</span> <span class='kw'>as</span> <span class='ident'>c_int</span> + } + } + + <span class='kw'>pub</span> <span class='kw'>unsafe</span> <span class='kw'>fn</span> <span class='ident'>get_handle</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_PKEY</span> { + <span class='kw'>return</span> <span class='self'>self</span>.<span class='ident'>evp</span> + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>public_eq</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>PKey</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>EVP_PKEY_cmp</span>(<span class='self'>self</span>.<span class='ident'>evp</span>, <span class='ident'>other</span>.<span class='ident'>evp</span>) <span class='op'>==</span> <span class='number'>1</span> } + } +} + +<span class='kw'>impl</span> <span class='ident'>Drop</span> <span class='kw'>for</span> <span class='ident'>PKey</span> { + <span class='kw'>fn</span> <span class='ident'>drop</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>EVP_PKEY_free</span>(<span class='self'>self</span>.<span class='ident'>evp</span>); + } + } +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>tests</span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>path</span>::<span class='ident'>Path</span>; + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>fs</span>::<span class='ident'>File</span>; + <span class='kw'>use</span> <span class='ident'>crypto</span>::<span class='ident'>hash</span>::<span class='ident'>Type</span>::{<span class='ident'>MD5</span>, <span class='ident'>SHA1</span>}; + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_gen_pub</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>k0</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>PKey</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>k1</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>PKey</span>::<span class='ident'>new</span>(); + <span class='ident'>k0</span>.<span class='ident'>gen</span>(<span class='number'>512</span>); + <span class='ident'>k1</span>.<span class='ident'>load_pub</span>(<span class='kw-2'>&</span><span class='ident'>k0</span>.<span class='ident'>save_pub</span>()); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>k0</span>.<span class='ident'>save_pub</span>(), <span class='ident'>k1</span>.<span class='ident'>save_pub</span>()); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k0</span>.<span class='ident'>public_eq</span>(<span class='kw-2'>&</span><span class='ident'>k1</span>)); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>k0</span>.<span class='ident'>size</span>(), <span class='ident'>k1</span>.<span class='ident'>size</span>()); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k0</span>.<span class='ident'>can</span>(<span class='ident'>super</span>::<span class='ident'>Role</span>::<span class='ident'>Encrypt</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k0</span>.<span class='ident'>can</span>(<span class='ident'>super</span>::<span class='ident'>Role</span>::<span class='ident'>Decrypt</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k0</span>.<span class='ident'>can</span>(<span class='ident'>super</span>::<span class='ident'>Role</span>::<span class='ident'>Verify</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k0</span>.<span class='ident'>can</span>(<span class='ident'>super</span>::<span class='ident'>Role</span>::<span class='ident'>Sign</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k1</span>.<span class='ident'>can</span>(<span class='ident'>super</span>::<span class='ident'>Role</span>::<span class='ident'>Encrypt</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>k1</span>.<span class='ident'>can</span>(<span class='ident'>super</span>::<span class='ident'>Role</span>::<span class='ident'>Decrypt</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k1</span>.<span class='ident'>can</span>(<span class='ident'>super</span>::<span class='ident'>Role</span>::<span class='ident'>Verify</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>k1</span>.<span class='ident'>can</span>(<span class='ident'>super</span>::<span class='ident'>Role</span>::<span class='ident'>Sign</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_gen_priv</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>k0</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>PKey</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>k1</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>PKey</span>::<span class='ident'>new</span>(); + <span class='ident'>k0</span>.<span class='ident'>gen</span>(<span class='number'>512</span>); + <span class='ident'>k1</span>.<span class='ident'>load_priv</span>(<span class='kw-2'>&</span><span class='ident'>k0</span>.<span class='ident'>save_priv</span>()); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>k0</span>.<span class='ident'>save_priv</span>(), <span class='ident'>k1</span>.<span class='ident'>save_priv</span>()); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k0</span>.<span class='ident'>public_eq</span>(<span class='kw-2'>&</span><span class='ident'>k1</span>)); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>k0</span>.<span class='ident'>size</span>(), <span class='ident'>k1</span>.<span class='ident'>size</span>()); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k0</span>.<span class='ident'>can</span>(<span class='ident'>super</span>::<span class='ident'>Role</span>::<span class='ident'>Encrypt</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k0</span>.<span class='ident'>can</span>(<span class='ident'>super</span>::<span class='ident'>Role</span>::<span class='ident'>Decrypt</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k0</span>.<span class='ident'>can</span>(<span class='ident'>super</span>::<span class='ident'>Role</span>::<span class='ident'>Verify</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k0</span>.<span class='ident'>can</span>(<span class='ident'>super</span>::<span class='ident'>Role</span>::<span class='ident'>Sign</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k1</span>.<span class='ident'>can</span>(<span class='ident'>super</span>::<span class='ident'>Role</span>::<span class='ident'>Encrypt</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k1</span>.<span class='ident'>can</span>(<span class='ident'>super</span>::<span class='ident'>Role</span>::<span class='ident'>Decrypt</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k1</span>.<span class='ident'>can</span>(<span class='ident'>super</span>::<span class='ident'>Role</span>::<span class='ident'>Verify</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k1</span>.<span class='ident'>can</span>(<span class='ident'>super</span>::<span class='ident'>Role</span>::<span class='ident'>Sign</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_private_key_from_pem</span>() { + <span class='kw'>let</span> <span class='ident'>key_path</span> <span class='op'>=</span> <span class='ident'>Path</span>::<span class='ident'>new</span>(<span class='string'>"test/key.pem"</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>file</span> <span class='op'>=</span> <span class='ident'>File</span>::<span class='ident'>open</span>(<span class='kw-2'>&</span><span class='ident'>key_path</span>) + .<span class='ident'>ok</span>() + .<span class='ident'>expect</span>(<span class='string'>"Failed to open `test/key.pem`"</span>); + + <span class='ident'>super</span>::<span class='ident'>PKey</span>::<span class='ident'>private_key_from_pem</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>file</span>).<span class='ident'>unwrap</span>(); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_encrypt</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>k0</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>PKey</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>k1</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>PKey</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>msg</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>(<span class='number'>0xdeu8</span>, <span class='number'>0xadu8</span>, <span class='number'>0xd0u8</span>, <span class='number'>0x0du8</span>); + <span class='ident'>k0</span>.<span class='ident'>gen</span>(<span class='number'>512</span>); + <span class='ident'>k1</span>.<span class='ident'>load_pub</span>(<span class='kw-2'>&</span><span class='ident'>k0</span>.<span class='ident'>save_pub</span>()); + <span class='kw'>let</span> <span class='ident'>emsg</span> <span class='op'>=</span> <span class='ident'>k1</span>.<span class='ident'>encrypt</span>(<span class='kw-2'>&</span><span class='ident'>msg</span>); + <span class='kw'>let</span> <span class='ident'>dmsg</span> <span class='op'>=</span> <span class='ident'>k0</span>.<span class='ident'>decrypt</span>(<span class='kw-2'>&</span><span class='ident'>emsg</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>msg</span> <span class='op'>==</span> <span class='ident'>dmsg</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_encrypt_pkcs</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>k0</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>PKey</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>k1</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>PKey</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>msg</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>(<span class='number'>0xdeu8</span>, <span class='number'>0xadu8</span>, <span class='number'>0xd0u8</span>, <span class='number'>0x0du8</span>); + <span class='ident'>k0</span>.<span class='ident'>gen</span>(<span class='number'>512</span>); + <span class='ident'>k1</span>.<span class='ident'>load_pub</span>(<span class='kw-2'>&</span><span class='ident'>k0</span>.<span class='ident'>save_pub</span>()); + <span class='kw'>let</span> <span class='ident'>emsg</span> <span class='op'>=</span> <span class='ident'>k1</span>.<span class='ident'>encrypt_with_padding</span>(<span class='kw-2'>&</span><span class='ident'>msg</span>, <span class='ident'>super</span>::<span class='ident'>EncryptionPadding</span>::<span class='ident'>PKCS1v15</span>); + <span class='kw'>let</span> <span class='ident'>dmsg</span> <span class='op'>=</span> <span class='ident'>k0</span>.<span class='ident'>decrypt_with_padding</span>(<span class='kw-2'>&</span><span class='ident'>emsg</span>, <span class='ident'>super</span>::<span class='ident'>EncryptionPadding</span>::<span class='ident'>PKCS1v15</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>msg</span> <span class='op'>==</span> <span class='ident'>dmsg</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_sign</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>k0</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>PKey</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>k1</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>PKey</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>msg</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>(<span class='number'>0xdeu8</span>, <span class='number'>0xadu8</span>, <span class='number'>0xd0u8</span>, <span class='number'>0x0du8</span>); + <span class='ident'>k0</span>.<span class='ident'>gen</span>(<span class='number'>512</span>); + <span class='ident'>k1</span>.<span class='ident'>load_pub</span>(<span class='kw-2'>&</span><span class='ident'>k0</span>.<span class='ident'>save_pub</span>()); + <span class='kw'>let</span> <span class='ident'>sig</span> <span class='op'>=</span> <span class='ident'>k0</span>.<span class='ident'>sign</span>(<span class='kw-2'>&</span><span class='ident'>msg</span>); + <span class='kw'>let</span> <span class='ident'>rv</span> <span class='op'>=</span> <span class='ident'>k1</span>.<span class='ident'>verify</span>(<span class='kw-2'>&</span><span class='ident'>msg</span>, <span class='kw-2'>&</span><span class='ident'>sig</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>rv</span> <span class='op'>==</span> <span class='boolval'>true</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_sign_hashes</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>k0</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>PKey</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>k1</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>PKey</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>msg</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>(<span class='number'>0xdeu8</span>, <span class='number'>0xadu8</span>, <span class='number'>0xd0u8</span>, <span class='number'>0x0du8</span>); + <span class='ident'>k0</span>.<span class='ident'>gen</span>(<span class='number'>512</span>); + <span class='ident'>k1</span>.<span class='ident'>load_pub</span>(<span class='kw-2'>&</span><span class='ident'>k0</span>.<span class='ident'>save_pub</span>()); + + <span class='kw'>let</span> <span class='ident'>sig</span> <span class='op'>=</span> <span class='ident'>k0</span>.<span class='ident'>sign_with_hash</span>(<span class='kw-2'>&</span><span class='ident'>msg</span>, <span class='ident'>MD5</span>); + + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k1</span>.<span class='ident'>verify_with_hash</span>(<span class='kw-2'>&</span><span class='ident'>msg</span>, <span class='kw-2'>&</span><span class='ident'>sig</span>, <span class='ident'>MD5</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>k1</span>.<span class='ident'>verify_with_hash</span>(<span class='kw-2'>&</span><span class='ident'>msg</span>, <span class='kw-2'>&</span><span class='ident'>sig</span>, <span class='ident'>SHA1</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_eq</span>() { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>k0</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>PKey</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>p0</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>PKey</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>k1</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>PKey</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>p1</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>PKey</span>::<span class='ident'>new</span>(); + <span class='ident'>k0</span>.<span class='ident'>gen</span>(<span class='number'>512</span>); + <span class='ident'>k1</span>.<span class='ident'>gen</span>(<span class='number'>512</span>); + <span class='ident'>p0</span>.<span class='ident'>load_pub</span>(<span class='kw-2'>&</span><span class='ident'>k0</span>.<span class='ident'>save_pub</span>()); + <span class='ident'>p1</span>.<span class='ident'>load_pub</span>(<span class='kw-2'>&</span><span class='ident'>k1</span>.<span class='ident'>save_pub</span>()); + + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k0</span>.<span class='ident'>public_eq</span>(<span class='kw-2'>&</span><span class='ident'>k0</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k1</span>.<span class='ident'>public_eq</span>(<span class='kw-2'>&</span><span class='ident'>k1</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>p0</span>.<span class='ident'>public_eq</span>(<span class='kw-2'>&</span><span class='ident'>p0</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>p1</span>.<span class='ident'>public_eq</span>(<span class='kw-2'>&</span><span class='ident'>p1</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k0</span>.<span class='ident'>public_eq</span>(<span class='kw-2'>&</span><span class='ident'>p0</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k1</span>.<span class='ident'>public_eq</span>(<span class='kw-2'>&</span><span class='ident'>p1</span>)); + + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>k0</span>.<span class='ident'>public_eq</span>(<span class='kw-2'>&</span><span class='ident'>k1</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>p0</span>.<span class='ident'>public_eq</span>(<span class='kw-2'>&</span><span class='ident'>p1</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>k0</span>.<span class='ident'>public_eq</span>(<span class='kw-2'>&</span><span class='ident'>p1</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>p0</span>.<span class='ident'>public_eq</span>(<span class='kw-2'>&</span><span class='ident'>k1</span>)); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl"; + window.playgroundUrl = ""; + </script> + <script src="../../../jquery.js"></script> + <script src="../../../main.js"></script> + + <script async src="../../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl/crypto/rand.rs.html b/src/openssl/crypto/rand.rs.html new file mode 100644 index 0000000..fd6f00a --- /dev/null +++ b/src/openssl/crypto/rand.rs.html @@ -0,0 +1,151 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-0.6.3/src/crypto/rand.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>rand.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10">10</span> +<span id="11">11</span> +<span id="12">12</span> +<span id="13">13</span> +<span id="14">14</span> +<span id="15">15</span> +<span id="16">16</span> +<span id="17">17</span> +<span id="18">18</span> +<span id="19">19</span> +<span id="20">20</span> +<span id="21">21</span> +<span id="22">22</span> +<span id="23">23</span> +<span id="24">24</span> +<span id="25">25</span> +<span id="26">26</span> +<span id="27">27</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>libc</span>::<span class='ident'>c_int</span>; +<span class='kw'>use</span> <span class='ident'>ffi</span>; + +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>rand_bytes</span>(<span class='ident'>len</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>out</span> <span class='op'>=</span> <span class='ident'>Vec</span>::<span class='ident'>with_capacity</span>(<span class='ident'>len</span>); + + <span class='ident'>ffi</span>::<span class='ident'>init</span>(); + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>RAND_bytes</span>(<span class='ident'>out</span>.<span class='ident'>as_mut_ptr</span>(), <span class='ident'>len</span> <span class='kw'>as</span> <span class='ident'>c_int</span>); + <span class='kw'>if</span> <span class='ident'>r</span> <span class='op'>!=</span> <span class='number'>1</span> <span class='kw'>as</span> <span class='ident'>c_int</span> { <span class='macro'>panic</span><span class='macro'>!</span>() } + + <span class='ident'>out</span>.<span class='ident'>set_len</span>(<span class='ident'>len</span>); + + <span class='ident'>out</span> + } +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>tests</span> { + <span class='kw'>use</span> <span class='ident'>super</span>::<span class='ident'>rand_bytes</span>; + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_rand_bytes</span>() { + <span class='kw'>let</span> <span class='ident'>bytes</span> <span class='op'>=</span> <span class='ident'>rand_bytes</span>(<span class='number'>32</span>); + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"{:?}"</span>, <span class='ident'>bytes</span>); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl"; + window.playgroundUrl = ""; + </script> + <script src="../../../jquery.js"></script> + <script src="../../../main.js"></script> + + <script async src="../../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl/crypto/symm.rs.html b/src/openssl/crypto/symm.rs.html new file mode 100644 index 0000000..5cbd394 --- /dev/null +++ b/src/openssl/crypto/symm.rs.html @@ -0,0 +1,721 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-0.6.3/src/crypto/symm.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>symm.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>iter</span>::<span class='ident'>repeat</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>convert</span>::<span class='ident'>AsRef</span>; +<span class='kw'>use</span> <span class='ident'>libc</span>::{<span class='ident'>c_int</span>}; + +<span class='kw'>use</span> <span class='ident'>ffi</span>; + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Mode</span> { + <span class='ident'>Encrypt</span>, + <span class='ident'>Decrypt</span>, +} + +<span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>non_camel_case_types</span>)]</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Type</span> { + <span class='ident'>AES_128_ECB</span>, + <span class='ident'>AES_128_CBC</span>, + <span class='doccomment'>/// Requires the `aes_xts` feature</span> + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"aes_xts"</span>)]</span> + <span class='ident'>AES_128_XTS</span>, + <span class='comment'>// AES_128_CTR,</span> + <span class='comment'>//AES_128_GCM,</span> + + <span class='ident'>AES_256_ECB</span>, + <span class='ident'>AES_256_CBC</span>, + <span class='doccomment'>/// Requires the `aes_xts` feature</span> + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"aes_xts"</span>)]</span> + <span class='ident'>AES_256_XTS</span>, + <span class='comment'>// AES_256_CTR,</span> + <span class='comment'>//AES_256_GCM,</span> + + <span class='ident'>RC4_128</span>, +} + +<span class='kw'>fn</span> <span class='ident'>evpc</span>(<span class='ident'>t</span>: <span class='ident'>Type</span>) <span class='op'>-></span> (<span class='op'>*</span><span class='kw'>const</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_CIPHER</span>, <span class='ident'>u32</span>, <span class='ident'>u32</span>) { + <span class='kw'>unsafe</span> { + <span class='kw'>match</span> <span class='ident'>t</span> { + <span class='ident'>Type</span>::<span class='ident'>AES_128_ECB</span> <span class='op'>=></span> (<span class='ident'>ffi</span>::<span class='ident'>EVP_aes_128_ecb</span>(), <span class='number'>16</span>, <span class='number'>16</span>), + <span class='ident'>Type</span>::<span class='ident'>AES_128_CBC</span> <span class='op'>=></span> (<span class='ident'>ffi</span>::<span class='ident'>EVP_aes_128_cbc</span>(), <span class='number'>16</span>, <span class='number'>16</span>), + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"aes_xts"</span>)]</span> + <span class='ident'>Type</span>::<span class='ident'>AES_128_XTS</span> <span class='op'>=></span> (<span class='ident'>ffi</span>::<span class='ident'>EVP_aes_128_xts</span>(), <span class='number'>32</span>, <span class='number'>16</span>), + <span class='comment'>// AES_128_CTR => (EVP_aes_128_ctr(), 16, 0),</span> + <span class='comment'>//AES_128_GCM => (EVP_aes_128_gcm(), 16, 16),</span> + + <span class='ident'>Type</span>::<span class='ident'>AES_256_ECB</span> <span class='op'>=></span> (<span class='ident'>ffi</span>::<span class='ident'>EVP_aes_256_ecb</span>(), <span class='number'>32</span>, <span class='number'>16</span>), + <span class='ident'>Type</span>::<span class='ident'>AES_256_CBC</span> <span class='op'>=></span> (<span class='ident'>ffi</span>::<span class='ident'>EVP_aes_256_cbc</span>(), <span class='number'>32</span>, <span class='number'>16</span>), + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"aes_xts"</span>)]</span> + <span class='ident'>Type</span>::<span class='ident'>AES_256_XTS</span> <span class='op'>=></span> (<span class='ident'>ffi</span>::<span class='ident'>EVP_aes_256_xts</span>(), <span class='number'>64</span>, <span class='number'>16</span>), + <span class='comment'>// AES_256_CTR => (EVP_aes_256_ctr(), 32, 0),</span> + <span class='comment'>//AES_256_GCM => (EVP_aes_256_gcm(), 32, 16),</span> + + <span class='ident'>Type</span>::<span class='ident'>RC4_128</span> <span class='op'>=></span> (<span class='ident'>ffi</span>::<span class='ident'>EVP_rc4</span>(), <span class='number'>16</span>, <span class='number'>0</span>), + } + } +} + +<span class='doccomment'>/// Represents a symmetric cipher context.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Crypter</span> { + <span class='ident'>evp</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_CIPHER</span>, + <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>EVP_CIPHER_CTX</span>, + <span class='ident'>keylen</span>: <span class='ident'>u32</span>, + <span class='ident'>blocksize</span>: <span class='ident'>u32</span>, +} + +<span class='kw'>impl</span> <span class='ident'>Crypter</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>t</span>: <span class='ident'>Type</span>) <span class='op'>-></span> <span class='ident'>Crypter</span> { + <span class='ident'>ffi</span>::<span class='ident'>init</span>(); + + <span class='kw'>let</span> <span class='ident'>ctx</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>EVP_CIPHER_CTX_new</span>() }; + <span class='kw'>let</span> (<span class='ident'>evp</span>, <span class='ident'>keylen</span>, <span class='ident'>blocksz</span>) <span class='op'>=</span> <span class='ident'>evpc</span>(<span class='ident'>t</span>); + <span class='ident'>Crypter</span> { <span class='ident'>evp</span>: <span class='ident'>evp</span>, <span class='ident'>ctx</span>: <span class='ident'>ctx</span>, <span class='ident'>keylen</span>: <span class='ident'>keylen</span>, <span class='ident'>blocksize</span>: <span class='ident'>blocksz</span> } + } + + <span class='doccomment'>/** + * Enables or disables padding. If padding is disabled, total amount of + * data encrypted must be a multiple of block size. + */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>pad</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>padding</span>: <span class='ident'>bool</span>) { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>blocksize</span> <span class='op'>></span> <span class='number'>0</span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='ident'>padding</span> { <span class='number'>1</span> <span class='kw'>as</span> <span class='ident'>c_int</span> } <span class='kw'>else</span> { <span class='number'>0</span> }; + <span class='ident'>ffi</span>::<span class='ident'>EVP_CIPHER_CTX_set_padding</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>v</span>); + } + } + } + + <span class='doccomment'>/** + * Initializes this crypter. + */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>init</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>AsRef</span><span class='op'><</span>[<span class='ident'>u8</span>]<span class='op'>>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>mode</span>: <span class='ident'>Mode</span>, <span class='ident'>key</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>], <span class='ident'>iv</span>: <span class='ident'>T</span>) { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>mode</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>mode</span> { + <span class='ident'>Mode</span>::<span class='ident'>Encrypt</span> <span class='op'>=></span> <span class='number'>1</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, + <span class='ident'>Mode</span>::<span class='ident'>Decrypt</span> <span class='op'>=></span> <span class='number'>0</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, + }; + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>key</span>.<span class='ident'>len</span>(), <span class='self'>self</span>.<span class='ident'>keylen</span> <span class='kw'>as</span> <span class='ident'>usize</span>); + + <span class='ident'>ffi</span>::<span class='ident'>EVP_CipherInit</span>( + <span class='self'>self</span>.<span class='ident'>ctx</span>, + <span class='self'>self</span>.<span class='ident'>evp</span>, + <span class='ident'>key</span>.<span class='ident'>as_ptr</span>(), + <span class='ident'>iv</span>.<span class='ident'>as_ref</span>().<span class='ident'>as_ptr</span>(), + <span class='ident'>mode</span> + ); + } + } + + <span class='doccomment'>/** + * Update this crypter with more data to encrypt or decrypt. Returns + * encrypted or decrypted bytes. + */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>update</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>data</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>sum</span> <span class='op'>=</span> <span class='ident'>data</span>.<span class='ident'>len</span>() <span class='op'>+</span> (<span class='self'>self</span>.<span class='ident'>blocksize</span> <span class='kw'>as</span> <span class='ident'>usize</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='ident'>repeat</span>(<span class='number'>0u8</span>).<span class='ident'>take</span>(<span class='ident'>sum</span>).<span class='ident'>collect</span>::<span class='op'><</span><span class='ident'>Vec</span><span class='op'><</span>_<span class='op'>>></span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>reslen</span> <span class='op'>=</span> <span class='ident'>sum</span> <span class='kw'>as</span> <span class='ident'>c_int</span>; + + <span class='ident'>ffi</span>::<span class='ident'>EVP_CipherUpdate</span>( + <span class='self'>self</span>.<span class='ident'>ctx</span>, + <span class='ident'>res</span>.<span class='ident'>as_mut_ptr</span>(), + <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>reslen</span>, + <span class='ident'>data</span>.<span class='ident'>as_ptr</span>(), + <span class='ident'>data</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>c_int</span> + ); + + <span class='ident'>res</span>.<span class='ident'>truncate</span>(<span class='ident'>reslen</span> <span class='kw'>as</span> <span class='ident'>usize</span>); + <span class='ident'>res</span> + } + } + + <span class='doccomment'>/** + * Finish crypting. Returns the remaining partial block of output, if any. + */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>finalize</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='ident'>repeat</span>(<span class='number'>0u8</span>).<span class='ident'>take</span>(<span class='self'>self</span>.<span class='ident'>blocksize</span> <span class='kw'>as</span> <span class='ident'>usize</span>).<span class='ident'>collect</span>::<span class='op'><</span><span class='ident'>Vec</span><span class='op'><</span>_<span class='op'>>></span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>reslen</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>blocksize</span> <span class='kw'>as</span> <span class='ident'>c_int</span>; + + <span class='ident'>ffi</span>::<span class='ident'>EVP_CipherFinal</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, + <span class='ident'>res</span>.<span class='ident'>as_mut_ptr</span>(), + <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>reslen</span>); + + <span class='ident'>res</span>.<span class='ident'>truncate</span>(<span class='ident'>reslen</span> <span class='kw'>as</span> <span class='ident'>usize</span>); + <span class='ident'>res</span> + } + } +} + +<span class='kw'>impl</span> <span class='ident'>Drop</span> <span class='kw'>for</span> <span class='ident'>Crypter</span> { + <span class='kw'>fn</span> <span class='ident'>drop</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>EVP_CIPHER_CTX_free</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>); + } + } +} + +<span class='doccomment'>/** + * Encrypts data, using the specified crypter type in encrypt mode with the + * specified key and iv; returns the resulting (encrypted) data. + */</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>encrypt</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>AsRef</span><span class='op'><</span>[<span class='ident'>u8</span>]<span class='op'>>></span>(<span class='ident'>t</span>: <span class='ident'>Type</span>, <span class='ident'>key</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>], <span class='ident'>iv</span>: <span class='ident'>T</span>, <span class='ident'>data</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>c</span> <span class='op'>=</span> <span class='ident'>Crypter</span>::<span class='ident'>new</span>(<span class='ident'>t</span>); + <span class='ident'>c</span>.<span class='ident'>init</span>(<span class='ident'>Mode</span>::<span class='ident'>Encrypt</span>, <span class='ident'>key</span>, <span class='ident'>iv</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>c</span>.<span class='ident'>update</span>(<span class='ident'>data</span>); + <span class='kw'>let</span> <span class='ident'>rest</span> <span class='op'>=</span> <span class='ident'>c</span>.<span class='ident'>finalize</span>(); + <span class='ident'>r</span>.<span class='ident'>extend</span>(<span class='ident'>rest</span>.<span class='ident'>into_iter</span>()); + <span class='ident'>r</span> +} + +<span class='doccomment'>/** + * Decrypts data, using the specified crypter type in decrypt mode with the + * specified key and iv; returns the resulting (decrypted) data. + */</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>decrypt</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>AsRef</span><span class='op'><</span>[<span class='ident'>u8</span>]<span class='op'>>></span>(<span class='ident'>t</span>: <span class='ident'>Type</span>, <span class='ident'>key</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>], <span class='ident'>iv</span>: <span class='ident'>T</span>, <span class='ident'>data</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>c</span> <span class='op'>=</span> <span class='ident'>Crypter</span>::<span class='ident'>new</span>(<span class='ident'>t</span>); + <span class='ident'>c</span>.<span class='ident'>init</span>(<span class='ident'>Mode</span>::<span class='ident'>Decrypt</span>, <span class='ident'>key</span>, <span class='ident'>iv</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='ident'>c</span>.<span class='ident'>update</span>(<span class='ident'>data</span>); + <span class='kw'>let</span> <span class='ident'>rest</span> <span class='op'>=</span> <span class='ident'>c</span>.<span class='ident'>finalize</span>(); + <span class='ident'>r</span>.<span class='ident'>extend</span>(<span class='ident'>rest</span>.<span class='ident'>into_iter</span>()); + <span class='ident'>r</span> +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>tests</span> { + <span class='kw'>use</span> <span class='ident'>serialize</span>::<span class='ident'>hex</span>::<span class='ident'>FromHex</span>; + + <span class='comment'>// Test vectors from FIPS-197:</span> + <span class='comment'>// http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf</span> + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_aes_256_ecb</span>() { + <span class='kw'>let</span> <span class='ident'>k0</span> <span class='op'>=</span> + [<span class='number'>0x00u8</span>, <span class='number'>0x01u8</span>, <span class='number'>0x02u8</span>, <span class='number'>0x03u8</span>, <span class='number'>0x04u8</span>, <span class='number'>0x05u8</span>, <span class='number'>0x06u8</span>, <span class='number'>0x07u8</span>, + <span class='number'>0x08u8</span>, <span class='number'>0x09u8</span>, <span class='number'>0x0au8</span>, <span class='number'>0x0bu8</span>, <span class='number'>0x0cu8</span>, <span class='number'>0x0du8</span>, <span class='number'>0x0eu8</span>, <span class='number'>0x0fu8</span>, + <span class='number'>0x10u8</span>, <span class='number'>0x11u8</span>, <span class='number'>0x12u8</span>, <span class='number'>0x13u8</span>, <span class='number'>0x14u8</span>, <span class='number'>0x15u8</span>, <span class='number'>0x16u8</span>, <span class='number'>0x17u8</span>, + <span class='number'>0x18u8</span>, <span class='number'>0x19u8</span>, <span class='number'>0x1au8</span>, <span class='number'>0x1bu8</span>, <span class='number'>0x1cu8</span>, <span class='number'>0x1du8</span>, <span class='number'>0x1eu8</span>, <span class='number'>0x1fu8</span>]; + <span class='kw'>let</span> <span class='ident'>p0</span> <span class='op'>=</span> + [<span class='number'>0x00u8</span>, <span class='number'>0x11u8</span>, <span class='number'>0x22u8</span>, <span class='number'>0x33u8</span>, <span class='number'>0x44u8</span>, <span class='number'>0x55u8</span>, <span class='number'>0x66u8</span>, <span class='number'>0x77u8</span>, + <span class='number'>0x88u8</span>, <span class='number'>0x99u8</span>, <span class='number'>0xaau8</span>, <span class='number'>0xbbu8</span>, <span class='number'>0xccu8</span>, <span class='number'>0xddu8</span>, <span class='number'>0xeeu8</span>, <span class='number'>0xffu8</span>]; + <span class='kw'>let</span> <span class='ident'>c0</span> <span class='op'>=</span> + [<span class='number'>0x8eu8</span>, <span class='number'>0xa2u8</span>, <span class='number'>0xb7u8</span>, <span class='number'>0xcau8</span>, <span class='number'>0x51u8</span>, <span class='number'>0x67u8</span>, <span class='number'>0x45u8</span>, <span class='number'>0xbfu8</span>, + <span class='number'>0xeau8</span>, <span class='number'>0xfcu8</span>, <span class='number'>0x49u8</span>, <span class='number'>0x90u8</span>, <span class='number'>0x4bu8</span>, <span class='number'>0x49u8</span>, <span class='number'>0x60u8</span>, <span class='number'>0x89u8</span>]; + <span class='kw'>let</span> <span class='ident'>c</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>Crypter</span>::<span class='ident'>new</span>(<span class='ident'>super</span>::<span class='ident'>Type</span>::<span class='ident'>AES_256_ECB</span>); + <span class='ident'>c</span>.<span class='ident'>init</span>(<span class='ident'>super</span>::<span class='ident'>Mode</span>::<span class='ident'>Encrypt</span>, <span class='kw-2'>&</span><span class='ident'>k0</span>, <span class='kw-2'>&</span>[]); + <span class='ident'>c</span>.<span class='ident'>pad</span>(<span class='boolval'>false</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>r0</span> <span class='op'>=</span> <span class='ident'>c</span>.<span class='ident'>update</span>(<span class='kw-2'>&</span><span class='ident'>p0</span>); + <span class='ident'>r0</span>.<span class='ident'>extend</span>(<span class='ident'>c</span>.<span class='ident'>finalize</span>().<span class='ident'>into_iter</span>()); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>r0</span> <span class='op'>==</span> <span class='ident'>c0</span>); + <span class='ident'>c</span>.<span class='ident'>init</span>(<span class='ident'>super</span>::<span class='ident'>Mode</span>::<span class='ident'>Decrypt</span>, <span class='kw-2'>&</span><span class='ident'>k0</span>, <span class='kw-2'>&</span>[]); + <span class='ident'>c</span>.<span class='ident'>pad</span>(<span class='boolval'>false</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>p1</span> <span class='op'>=</span> <span class='ident'>c</span>.<span class='ident'>update</span>(<span class='kw-2'>&</span><span class='ident'>r0</span>); + <span class='ident'>p1</span>.<span class='ident'>extend</span>(<span class='ident'>c</span>.<span class='ident'>finalize</span>().<span class='ident'>into_iter</span>()); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>p1</span> <span class='op'>==</span> <span class='ident'>p0</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_aes_256_cbc_decrypt</span>() { + <span class='kw'>let</span> <span class='ident'>cr</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>Crypter</span>::<span class='ident'>new</span>(<span class='ident'>super</span>::<span class='ident'>Type</span>::<span class='ident'>AES_256_CBC</span>); + <span class='kw'>let</span> <span class='ident'>iv</span> <span class='op'>=</span> [ + <span class='number'>4_u8</span>, <span class='number'>223_u8</span>, <span class='number'>153_u8</span>, <span class='number'>219_u8</span>, <span class='number'>28_u8</span>, <span class='number'>142_u8</span>, <span class='number'>234_u8</span>, <span class='number'>68_u8</span>, <span class='number'>227_u8</span>, + <span class='number'>69_u8</span>, <span class='number'>98_u8</span>, <span class='number'>107_u8</span>, <span class='number'>208_u8</span>, <span class='number'>14_u8</span>, <span class='number'>236_u8</span>, <span class='number'>60_u8</span>, <span class='number'>0_u8</span>, <span class='number'>0_u8</span>, + <span class='number'>0_u8</span>, <span class='number'>0_u8</span>, <span class='number'>0_u8</span>, <span class='number'>0_u8</span>, <span class='number'>0_u8</span>, <span class='number'>0_u8</span>, <span class='number'>0_u8</span>, <span class='number'>0_u8</span>, <span class='number'>0_u8</span>, <span class='number'>0_u8</span>, <span class='number'>0_u8</span>, + <span class='number'>0_u8</span>, <span class='number'>0_u8</span>, <span class='number'>0_u8</span> + ]; + <span class='kw'>let</span> <span class='ident'>data</span> <span class='op'>=</span> [ + <span class='number'>143_u8</span>, <span class='number'>210_u8</span>, <span class='number'>75_u8</span>, <span class='number'>63_u8</span>, <span class='number'>214_u8</span>, <span class='number'>179_u8</span>, <span class='number'>155_u8</span>, + <span class='number'>241_u8</span>, <span class='number'>242_u8</span>, <span class='number'>31_u8</span>, <span class='number'>154_u8</span>, <span class='number'>56_u8</span>, <span class='number'>198_u8</span>, <span class='number'>145_u8</span>, <span class='number'>192_u8</span>, <span class='number'>64_u8</span>, + <span class='number'>2_u8</span>, <span class='number'>245_u8</span>, <span class='number'>167_u8</span>, <span class='number'>220_u8</span>, <span class='number'>55_u8</span>, <span class='number'>119_u8</span>, <span class='number'>233_u8</span>, <span class='number'>136_u8</span>, <span class='number'>139_u8</span>, + <span class='number'>27_u8</span>, <span class='number'>71_u8</span>, <span class='number'>242_u8</span>, <span class='number'>119_u8</span>, <span class='number'>175_u8</span>, <span class='number'>65_u8</span>, <span class='number'>207_u8</span> + ]; + <span class='kw'>let</span> <span class='ident'>ciphered_data</span> <span class='op'>=</span> [ + <span class='number'>0x4a_u8</span>, <span class='number'>0x2e_u8</span>, <span class='number'>0xe5_u8</span>, <span class='number'>0x6_u8</span>, <span class='number'>0xbf_u8</span>, <span class='number'>0xcf_u8</span>, <span class='number'>0xf2_u8</span>, <span class='number'>0xd7_u8</span>, + <span class='number'>0xea_u8</span>, <span class='number'>0x2d_u8</span>, <span class='number'>0xb1_u8</span>, <span class='number'>0x85_u8</span>, <span class='number'>0x6c_u8</span>, <span class='number'>0x93_u8</span>, <span class='number'>0x65_u8</span>, <span class='number'>0x6f_u8</span> + ]; + <span class='ident'>cr</span>.<span class='ident'>init</span>(<span class='ident'>super</span>::<span class='ident'>Mode</span>::<span class='ident'>Decrypt</span>, <span class='kw-2'>&</span><span class='ident'>data</span>, <span class='kw-2'>&</span><span class='ident'>iv</span>); + <span class='ident'>cr</span>.<span class='ident'>pad</span>(<span class='boolval'>false</span>); + <span class='kw'>let</span> <span class='ident'>unciphered_data_1</span> <span class='op'>=</span> <span class='ident'>cr</span>.<span class='ident'>update</span>(<span class='kw-2'>&</span><span class='ident'>ciphered_data</span>); + <span class='kw'>let</span> <span class='ident'>unciphered_data_2</span> <span class='op'>=</span> <span class='ident'>cr</span>.<span class='ident'>finalize</span>(); + + <span class='kw'>let</span> <span class='ident'>expected_unciphered_data</span> <span class='op'>=</span> <span class='string'>b"I love turtles.\x01"</span>; + + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>unciphered_data_2</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>0</span>); + + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>unciphered_data_1</span>, <span class='ident'>expected_unciphered_data</span>); + } + + <span class='kw'>fn</span> <span class='ident'>cipher_test</span>(<span class='ident'>ciphertype</span>: <span class='ident'>super</span>::<span class='ident'>Type</span>, <span class='ident'>pt</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>ct</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>key</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>iv</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) { + <span class='kw'>use</span> <span class='ident'>serialize</span>::<span class='ident'>hex</span>::<span class='ident'>ToHex</span>; + + <span class='kw'>let</span> <span class='ident'>cipher</span> <span class='op'>=</span> <span class='ident'>super</span>::<span class='ident'>Crypter</span>::<span class='ident'>new</span>(<span class='ident'>ciphertype</span>); + <span class='ident'>cipher</span>.<span class='ident'>init</span>(<span class='ident'>super</span>::<span class='ident'>Mode</span>::<span class='ident'>Encrypt</span>, <span class='kw-2'>&</span><span class='ident'>key</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(), <span class='kw-2'>&</span><span class='ident'>iv</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()); + + <span class='kw'>let</span> <span class='ident'>expected</span> <span class='op'>=</span> <span class='ident'>ct</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>computed</span> <span class='op'>=</span> <span class='ident'>cipher</span>.<span class='ident'>update</span>(<span class='kw-2'>&</span><span class='ident'>pt</span>.<span class='ident'>from_hex</span>().<span class='ident'>unwrap</span>()); + <span class='ident'>computed</span>.<span class='ident'>extend</span>(<span class='ident'>cipher</span>.<span class='ident'>finalize</span>().<span class='ident'>into_iter</span>()); + + <span class='kw'>if</span> <span class='ident'>computed</span> <span class='op'>!=</span> <span class='ident'>expected</span> { + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Computed: {}"</span>, <span class='ident'>computed</span>.<span class='ident'>to_hex</span>()); + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Expected: {}"</span>, <span class='ident'>expected</span>.<span class='ident'>to_hex</span>()); + <span class='kw'>if</span> <span class='ident'>computed</span>.<span class='ident'>len</span>() <span class='op'>!=</span> <span class='ident'>expected</span>.<span class='ident'>len</span>() { + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Lengths differ: {} in computed vs {} expected"</span>, + <span class='ident'>computed</span>.<span class='ident'>len</span>(), <span class='ident'>expected</span>.<span class='ident'>len</span>()); + } + <span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>"test failure"</span>); + } + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>test_rc4</span>() { + + <span class='kw'>let</span> <span class='ident'>pt</span> <span class='op'>=</span> <span class='string'>"0000000000000000000000000000000000000000000000000000000000000000000000000000"</span>; + <span class='kw'>let</span> <span class='ident'>ct</span> <span class='op'>=</span> <span class='string'>"A68686B04D686AA107BD8D4CAB191A3EEC0A6294BC78B60F65C25CB47BD7BB3A48EFC4D26BE4"</span>; + <span class='kw'>let</span> <span class='ident'>key</span> <span class='op'>=</span> <span class='string'>"97CD440324DA5FD1F7955C1C13B6B466"</span>; + <span class='kw'>let</span> <span class='ident'>iv</span> <span class='op'>=</span> <span class='string'>""</span>; + + <span class='ident'>cipher_test</span>(<span class='ident'>super</span>::<span class='ident'>Type</span>::<span class='ident'>RC4_128</span>, <span class='ident'>pt</span>, <span class='ident'>ct</span>, <span class='ident'>key</span>, <span class='ident'>iv</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"aes_xts"</span>)]</span> + <span class='kw'>fn</span> <span class='ident'>test_aes256_xts</span>() { + <span class='comment'>// Test case 174 from</span> + <span class='comment'>// http://csrc.nist.gov/groups/STM/cavp/documents/aes/XTSTestVectors.zip</span> + <span class='kw'>let</span> <span class='ident'>pt</span> <span class='op'>=</span> <span class='string'>"77f4ef63d734ebd028508da66c22cdebdd52ecd6ee2ab0a50bc8ad0cfd692ca5fcd4e6dedc45df7f6503f462611dc542"</span>; + <span class='kw'>let</span> <span class='ident'>ct</span> <span class='op'>=</span> <span class='string'>"ce7d905a7776ac72f240d22aafed5e4eb7566cdc7211220e970da634ce015f131a5ecb8d400bc9e84f0b81d8725dbbc7"</span>; + <span class='kw'>let</span> <span class='ident'>key</span> <span class='op'>=</span> <span class='string'>"b6bfef891f83b5ff073f2231267be51eb084b791fa19a154399c0684c8b2dfcb37de77d28bbda3b4180026ad640b74243b3133e7b9fae629403f6733423dae28"</span>; + <span class='kw'>let</span> <span class='ident'>iv</span> <span class='op'>=</span> <span class='string'>"db200efb7eaaa737dbdf40babb68953f"</span>; + + <span class='ident'>cipher_test</span>(<span class='ident'>super</span>::<span class='ident'>Type</span>::<span class='ident'>AES_256_XTS</span>, <span class='ident'>pt</span>, <span class='ident'>ct</span>, <span class='ident'>key</span>, <span class='ident'>iv</span>); + } + + <span class='comment'>/*#[test] + fn test_aes128_ctr() { + + let pt = ~"6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710"; + let ct = ~"874D6191B620E3261BEF6864990DB6CE9806F66B7970FDFF8617187BB9FFFDFF5AE4DF3EDBD5D35E5B4F09020DB03EAB1E031DDA2FBE03D1792170A0F3009CEE"; + let key = ~"2B7E151628AED2A6ABF7158809CF4F3C"; + let iv = ~"F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"; + + cipher_test(super::AES_128_CTR, pt, ct, key, iv); + }*/</span> + + <span class='comment'>/*#[test] + fn test_aes128_gcm() { + // Test case 3 in GCM spec + let pt = ~"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255"; + let ct = ~"42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091473f59854d5c2af327cd64a62cf35abd2ba6fab4"; + let key = ~"feffe9928665731c6d6a8f9467308308"; + let iv = ~"cafebabefacedbaddecaf888"; + + cipher_test(super::AES_128_GCM, pt, ct, key, iv); + }*/</span> +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl"; + window.playgroundUrl = ""; + </script> + <script src="../../../jquery.js"></script> + <script src="../../../main.js"></script> + + <script async src="../../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl/lib.rs.html b/src/openssl/lib.rs.html new file mode 100644 index 0000000..e8ad872 --- /dev/null +++ b/src/openssl/lib.rs.html @@ -0,0 +1,147 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-0.6.3/src/lib.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>lib.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10">10</span> +<span id="11">11</span> +<span id="12">12</span> +<span id="13">13</span> +<span id="14">14</span> +<span id="15">15</span> +<span id="16">16</span> +<span id="17">17</span> +<span id="18">18</span> +<span id="19">19</span> +<span id="20">20</span> +<span id="21">21</span> +<span id="22">22</span> +<span id="23">23</span> +<span id="24">24</span> +<span id="25">25</span> +</pre><pre class='rust '> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>doc</span>(<span class='ident'>html_root_url</span><span class='op'>=</span><span class='string'>"https://sfackler.github.io/rust-openssl/doc/v0.6.3"</span>)]</span> + +<span class='attribute'>#[<span class='ident'>macro_use</span>]</span> +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>bitflags</span>; +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>libc</span>; +<span class='attribute'>#[<span class='ident'>macro_use</span>]</span> +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>lazy_static</span>; +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>openssl_sys</span> <span class='kw'>as</span> <span class='ident'>ffi</span>; + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>rustc_serialize</span> <span class='kw'>as</span> <span class='ident'>serialize</span>; + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>any</span>(<span class='ident'>feature</span><span class='op'>=</span><span class='string'>"dtlsv1"</span>, <span class='ident'>feature</span><span class='op'>=</span><span class='string'>"dtlsv1_2"</span>))]</span> +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>connected_socket</span>; + +<span class='kw'>mod</span> <span class='ident'>macros</span>; + +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>asn1</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bn</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bio</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>crypto</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>ssl</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>x509</span>; +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>nid</span>; +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl/nid.rs.html b/src/openssl/nid.rs.html new file mode 100644 index 0000000..857ab9d --- /dev/null +++ b/src/openssl/nid.rs.html @@ -0,0 +1,437 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-0.6.3/src/nid.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>nid.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +</pre><pre class='rust '> +<span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>non_camel_case_types</span>)]</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> +<span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>usize</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Nid</span> { + <span class='ident'>Undefined</span>, + <span class='ident'>Rsadsi</span>, + <span class='ident'>Pkcs</span>, + <span class='ident'>MD2</span>, + <span class='ident'>MD4</span>, + <span class='ident'>MD5</span>, + <span class='ident'>RC4</span>, + <span class='ident'>RsaEncryption</span>, + <span class='ident'>RSA_MD2</span>, + <span class='ident'>RSA_MD5</span>, + <span class='ident'>PBE_MD2_DES</span>, + <span class='ident'>X500</span>, + <span class='ident'>x509</span>, + <span class='ident'>CN</span>, + <span class='ident'>C</span>, + <span class='ident'>L</span>, + <span class='ident'>ST</span>, + <span class='ident'>O</span>, + <span class='ident'>OU</span>, + <span class='ident'>RSA</span>, + <span class='ident'>Pkcs7</span>, + <span class='ident'>Pkcs7_data</span>, + <span class='ident'>Pkcs7_signedData</span>, + <span class='ident'>Pkcs7_envelopedData</span>, + <span class='ident'>Pkcs7_signedAndEnvelopedData</span>, + <span class='ident'>Pkcs7_digestData</span>, + <span class='ident'>Pkcs7_encryptedData</span>, + <span class='ident'>Pkcs3</span>, + <span class='ident'>DhKeyAgreement</span>, + <span class='ident'>DES_ECB</span>, + <span class='ident'>DES_CFB</span>, + <span class='ident'>DES_CBC</span>, + <span class='ident'>DES_EDE</span>, + <span class='ident'>DES_EDE3</span>, + <span class='ident'>IDEA_CBC</span>, + <span class='ident'>IDEA_ECB</span>, + <span class='ident'>RC2_CBC</span>, + <span class='ident'>RC2_ECB</span>, + <span class='ident'>RC2_CFB</span>, + <span class='ident'>RC2_OFB</span>, + <span class='ident'>SHA</span>, + <span class='ident'>RSA_SHA</span>, + <span class='ident'>DES_EDE_CBC</span>, + <span class='ident'>DES_EDE3_CBC</span>, + <span class='ident'>DES_OFB</span>, + <span class='ident'>IDEA_OFB</span>, + <span class='ident'>Pkcs9</span>, + <span class='ident'>Email</span>, + <span class='ident'>UnstructuredName</span>, + <span class='ident'>ContentType</span>, + <span class='ident'>MessageDigest</span>, + <span class='ident'>SigningTime</span>, + <span class='ident'>CounterSignature</span>, + <span class='ident'>UnstructuredAddress</span>, + <span class='ident'>ExtendedCertificateAttributes</span>, + <span class='ident'>Netscape</span>, + <span class='ident'>NetscapeCertExtention</span>, + <span class='ident'>NetscapeDatatype</span>, + <span class='ident'>DES_EDE_CFB64</span>, + <span class='ident'>DES_EDE3_CFB64</span>, + <span class='ident'>DES_EDE_OFB64</span>, + <span class='ident'>DES_EDE3_OFB64</span>, + <span class='ident'>SHA1</span>, + <span class='ident'>RSA_SHA1</span>, + <span class='ident'>DSA_SHA</span>, + <span class='ident'>DSA_OLD</span>, + <span class='ident'>PBE_SHA1_RC2_64</span>, + <span class='ident'>PBKDF2</span>, + <span class='ident'>DSA_SHA1_OLD</span>, + <span class='ident'>NetscapeCertType</span>, + <span class='ident'>NetscapeBaseUrl</span>, + <span class='ident'>NetscapeRevocationUrl</span>, + <span class='ident'>NetscapeCARevocationUrl</span>, + <span class='ident'>NetscapeRenewalUrl</span>, + <span class='ident'>NetscapeCAPolicyUrl</span>, + <span class='ident'>NetscapeSSLServerName</span>, + <span class='ident'>NetscapeComment</span>, + <span class='ident'>NetscapeCertSequence</span>, + <span class='ident'>DESX_CBC</span>, + <span class='ident'>ID_CE</span>, + <span class='ident'>SubjectKeyIdentifier</span>, + <span class='ident'>KeyUsage</span>, + <span class='ident'>PrivateKeyUsagePeriod</span>, + <span class='ident'>SubjectAltName</span>, + <span class='ident'>IssuerAltName</span>, + <span class='ident'>BasicConstraints</span>, + <span class='ident'>CrlNumber</span>, + <span class='ident'>CertificatePolicies</span>, + <span class='ident'>AuthorityKeyIdentifier</span>, + <span class='ident'>BF_CBC</span>, + <span class='ident'>BF_ECB</span>, + <span class='ident'>BF_OFB</span>, + <span class='ident'>MDC2</span>, + <span class='ident'>RSA_MDC2</span>, + <span class='ident'>RC4_40</span>, + <span class='ident'>RC2_40_CBC</span>, + <span class='ident'>G</span>, + <span class='ident'>S</span>, + <span class='ident'>I</span>, + <span class='ident'>UID</span>, + <span class='ident'>CrlDistributionPoints</span>, + <span class='ident'>RSA_NP_MD5</span>, + <span class='ident'>SN</span>, + <span class='ident'>T</span>, + <span class='ident'>D</span>, + <span class='ident'>CAST5_CBC</span>, + <span class='ident'>CAST5_ECB</span>, + <span class='ident'>CAST5_CFB</span>, + <span class='ident'>CAST5_OFB</span>, + <span class='ident'>PbeWithMD5AndCast5CBC</span>, + <span class='ident'>DSA_SHA1</span>, + <span class='ident'>MD5_SHA1</span>, + <span class='ident'>RSA_SHA1_2</span>, + <span class='ident'>DSA</span>, + <span class='ident'>RIPEMD160</span>, + <span class='ident'>RSA_RIPEMD160</span>, + <span class='ident'>RC5_CBC</span>, + <span class='ident'>RC5_ECB</span>, + <span class='ident'>RC5_CFB</span>, + <span class='ident'>RC5_OFB</span>, + <span class='ident'>RLE</span>, + <span class='ident'>ZLIB</span>, + <span class='ident'>ExtendedKeyUsage</span>, + <span class='ident'>PKIX</span>, + <span class='ident'>ID_KP</span>, + <span class='ident'>ServerAuth</span>, + <span class='ident'>ClientAuth</span>, + <span class='ident'>CodeSigning</span>, + <span class='ident'>EmailProtection</span>, + <span class='ident'>TimeStamping</span>, + <span class='ident'>MsCodeInd</span>, + <span class='ident'>MsCodeCom</span>, + <span class='ident'>MsCtlSigh</span>, + <span class='ident'>MsSGC</span>, + <span class='ident'>MsEFS</span>, + <span class='ident'>NsSGC</span>, + <span class='ident'>DeltaCRL</span>, + <span class='ident'>CRLReason</span>, + <span class='ident'>InvalidityDate</span>, + <span class='ident'>SXNetID</span>, + <span class='ident'>Pkcs12</span>, + <span class='ident'>PBE_SHA1_RC4_128</span>, + <span class='ident'>PBE_SHA1_RC4_40</span>, + <span class='ident'>PBE_SHA1_3DES</span>, + <span class='ident'>PBE_SHA1_2DES</span>, + <span class='ident'>PBE_SHA1_RC2_128</span>, + <span class='ident'>PBE_SHA1_RC2_40</span>, + <span class='ident'>KeyBag</span>, + <span class='ident'>Pkcs8ShroudedKeyBag</span>, + <span class='ident'>CertBag</span>, + <span class='ident'>CrlBag</span>, + <span class='ident'>SecretBag</span>, + <span class='ident'>SafeContentsBag</span>, + <span class='ident'>FriendlyName</span>, + <span class='ident'>LocalKeyID</span>, + <span class='ident'>X509Certificate</span>, + <span class='ident'>SdsiCertificate</span>, + <span class='ident'>X509Crl</span>, + <span class='ident'>PBES2</span>, + <span class='ident'>PBMAC1</span>, + <span class='ident'>HmacWithSha1</span>, + <span class='ident'>ID_QT_CPS</span>, + <span class='ident'>ID_QT_UNOTICE</span>, + <span class='ident'>RC2_64_CBC</span>, + <span class='ident'>SMIMECaps</span> +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl/ssl/error.rs.html b/src/openssl/ssl/error.rs.html new file mode 100644 index 0000000..683c375 --- /dev/null +++ b/src/openssl/ssl/error.rs.html @@ -0,0 +1,373 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-0.6.3/src/ssl/error.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>error.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +</pre><pre class='rust '> +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>SslError</span>::<span class='op'>*</span>; +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>OpensslError</span>::<span class='op'>*</span>; + +<span class='kw'>use</span> <span class='ident'>libc</span>::<span class='ident'>c_ulong</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>error</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>fmt</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ffi</span>::<span class='ident'>CStr</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>; + +<span class='kw'>use</span> <span class='ident'>ffi</span>; + +<span class='doccomment'>/// An SSL error</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>SslError</span> { + <span class='doccomment'>/// The underlying stream reported an error</span> + <span class='ident'>StreamError</span>(<span class='ident'>io</span>::<span class='ident'>Error</span>), + <span class='doccomment'>/// The SSL session has been closed by the other end</span> + <span class='ident'>SslSessionClosed</span>, + <span class='doccomment'>/// An error in the OpenSSL library</span> + <span class='ident'>OpenSslErrors</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>OpensslError</span><span class='op'>></span>) +} + +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Display</span> <span class='kw'>for</span> <span class='ident'>SslError</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>fmt</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>fmt</span>.<span class='ident'>write_str</span>(<span class='ident'>error</span>::<span class='ident'>Error</span>::<span class='ident'>description</span>(<span class='self'>self</span>))); + <span class='kw'>if</span> <span class='kw'>let</span> <span class='ident'>OpenSslErrors</span>(<span class='kw-2'>ref</span> <span class='ident'>errs</span>) <span class='op'>=</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>first</span> <span class='op'>=</span> <span class='boolval'>true</span>; + <span class='kw'>for</span> <span class='ident'>err</span> <span class='kw'>in</span> <span class='ident'>errs</span> { + <span class='kw'>if</span> <span class='ident'>first</span> { + <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>fmt</span>.<span class='ident'>write_str</span>(<span class='string'>": "</span>)); + <span class='ident'>first</span> <span class='op'>=</span> <span class='boolval'>false</span>; + } <span class='kw'>else</span> { + <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>fmt</span>.<span class='ident'>write_str</span>(<span class='string'>", "</span>)); + } + <span class='kw'>match</span> <span class='op'>*</span><span class='ident'>err</span> { + <span class='ident'>UnknownError</span> { <span class='kw-2'>ref</span> <span class='ident'>reason</span>, .. } <span class='op'>=></span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>fmt</span>.<span class='ident'>write_str</span>(<span class='ident'>reason</span>)), + } + } + } + + <span class='prelude-val'>Ok</span>(()) + } +} + +<span class='kw'>impl</span> <span class='ident'>error</span>::<span class='ident'>Error</span> <span class='kw'>for</span> <span class='ident'>SslError</span> { + <span class='kw'>fn</span> <span class='ident'>description</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>str</span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>StreamError</span>(_) <span class='op'>=></span> <span class='string'>"The underlying stream reported an error"</span>, + <span class='ident'>SslSessionClosed</span> <span class='op'>=></span> <span class='string'>"The SSL session has been closed by the other end"</span>, + <span class='ident'>OpenSslErrors</span>(_) <span class='op'>=></span> <span class='string'>"An error in the OpenSSL library"</span>, + } + } + + <span class='kw'>fn</span> <span class='ident'>cause</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='ident'>error</span>::<span class='ident'>Error</span><span class='op'>></span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>StreamError</span>(<span class='kw-2'>ref</span> <span class='ident'>err</span>) <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>err</span> <span class='kw'>as</span> <span class='kw-2'>&</span><span class='ident'>error</span>::<span class='ident'>Error</span>), + _ <span class='op'>=></span> <span class='prelude-val'>None</span> + } + } +} + +<span class='doccomment'>/// An error from the OpenSSL library</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>, <span class='ident'>Clone</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>OpensslError</span> { + <span class='doccomment'>/// An unknown error</span> + <span class='ident'>UnknownError</span> { + <span class='doccomment'>/// The library reporting the error</span> + <span class='ident'>library</span>: <span class='ident'>String</span>, + <span class='doccomment'>/// The function reporting the error</span> + <span class='ident'>function</span>: <span class='ident'>String</span>, + <span class='doccomment'>/// The reason for the error</span> + <span class='ident'>reason</span>: <span class='ident'>String</span> + } +} + +<span class='kw'>fn</span> <span class='ident'>get_lib</span>(<span class='ident'>err</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>bytes</span> <span class='op'>=</span> <span class='ident'>CStr</span>::<span class='ident'>from_ptr</span>(<span class='ident'>ffi</span>::<span class='ident'>ERR_lib_error_string</span>(<span class='ident'>err</span>)).<span class='ident'>to_bytes</span>().<span class='ident'>to_vec</span>(); + <span class='ident'>String</span>::<span class='ident'>from_utf8</span>(<span class='ident'>bytes</span>).<span class='ident'>unwrap</span>() + } +} + +<span class='kw'>fn</span> <span class='ident'>get_func</span>(<span class='ident'>err</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>bytes</span> <span class='op'>=</span> <span class='ident'>CStr</span>::<span class='ident'>from_ptr</span>(<span class='ident'>ffi</span>::<span class='ident'>ERR_func_error_string</span>(<span class='ident'>err</span>)).<span class='ident'>to_bytes</span>().<span class='ident'>to_vec</span>(); + <span class='ident'>String</span>::<span class='ident'>from_utf8</span>(<span class='ident'>bytes</span>).<span class='ident'>unwrap</span>() + } +} + +<span class='kw'>fn</span> <span class='ident'>get_reason</span>(<span class='ident'>err</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>bytes</span> <span class='op'>=</span> <span class='ident'>CStr</span>::<span class='ident'>from_ptr</span>(<span class='ident'>ffi</span>::<span class='ident'>ERR_reason_error_string</span>(<span class='ident'>err</span>)).<span class='ident'>to_bytes</span>().<span class='ident'>to_vec</span>(); + <span class='ident'>String</span>::<span class='ident'>from_utf8</span>(<span class='ident'>bytes</span>).<span class='ident'>unwrap</span>() + } +} + +<span class='kw'>impl</span> <span class='ident'>SslError</span> { + <span class='doccomment'>/// Creates a new `OpenSslErrors` with the current contents of the error</span> + <span class='doccomment'>/// stack.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get</span>() <span class='op'>-></span> <span class='ident'>SslError</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>errs</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>(); + <span class='kw'>loop</span> { + <span class='kw'>match</span> <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>ERR_get_error</span>() } { + <span class='number'>0</span> <span class='op'>=></span> <span class='kw'>break</span>, + <span class='ident'>err</span> <span class='op'>=></span> <span class='ident'>errs</span>.<span class='ident'>push</span>(<span class='ident'>SslError</span>::<span class='ident'>from_error_code</span>(<span class='ident'>err</span>)) + } + } + <span class='ident'>OpenSslErrors</span>(<span class='ident'>errs</span>) + } + + <span class='doccomment'>/// Creates an `SslError` from the raw numeric error code.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>from_error</span>(<span class='ident'>err</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='ident'>SslError</span> { + <span class='ident'>OpenSslErrors</span>(<span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>SslError</span>::<span class='ident'>from_error_code</span>(<span class='ident'>err</span>)]) + } + + <span class='kw'>fn</span> <span class='ident'>from_error_code</span>(<span class='ident'>err</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='ident'>OpensslError</span> { + <span class='ident'>ffi</span>::<span class='ident'>init</span>(); + <span class='ident'>UnknownError</span> { + <span class='ident'>library</span>: <span class='ident'>get_lib</span>(<span class='ident'>err</span>), + <span class='ident'>function</span>: <span class='ident'>get_func</span>(<span class='ident'>err</span>), + <span class='ident'>reason</span>: <span class='ident'>get_reason</span>(<span class='ident'>err</span>) + } + } +} + +<span class='attribute'>#[<span class='ident'>test</span>]</span> +<span class='kw'>fn</span> <span class='ident'>test_uknown_error_should_have_correct_messages</span>() { + <span class='kw'>let</span> <span class='ident'>errs</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>SslError</span>::<span class='ident'>from_error</span>(<span class='number'>336032784</span>) { + <span class='ident'>OpenSslErrors</span>(<span class='ident'>errs</span>) <span class='op'>=></span> <span class='ident'>errs</span>, + _ <span class='op'>=></span> <span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>"This should always be an `OpenSslErrors` variant."</span>) + }; + + <span class='kw'>let</span> <span class='ident'>UnknownError</span> { <span class='kw-2'>ref</span> <span class='ident'>library</span>, <span class='kw-2'>ref</span> <span class='ident'>function</span>, <span class='kw-2'>ref</span> <span class='ident'>reason</span> } <span class='op'>=</span> <span class='ident'>errs</span>[<span class='number'>0</span>]; + + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>library</span>[..], <span class='string'>"SSL routines"</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>function</span>[..], <span class='string'>"SSL23_GET_SERVER_HELLO"</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>reason</span>[..], <span class='string'>"sslv3 alert handshake failure"</span>); +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl"; + window.playgroundUrl = ""; + </script> + <script src="../../../jquery.js"></script> + <script src="../../../main.js"></script> + + <script async src="../../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl/ssl/mod.rs.html b/src/openssl/ssl/mod.rs.html new file mode 100644 index 0000000..40cd850 --- /dev/null +++ b/src/openssl/ssl/mod.rs.html @@ -0,0 +1,2079 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-0.6.3/src/ssl/mod.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>mod.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +<span id="313">313</span> +<span id="314">314</span> +<span id="315">315</span> +<span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +<span id="326">326</span> +<span id="327">327</span> +<span id="328">328</span> +<span id="329">329</span> +<span id="330">330</span> +<span id="331">331</span> +<span id="332">332</span> +<span id="333">333</span> +<span id="334">334</span> +<span id="335">335</span> +<span id="336">336</span> +<span id="337">337</span> +<span id="338">338</span> +<span id="339">339</span> +<span id="340">340</span> +<span id="341">341</span> +<span id="342">342</span> +<span id="343">343</span> +<span id="344">344</span> +<span id="345">345</span> +<span id="346">346</span> +<span id="347">347</span> +<span id="348">348</span> +<span id="349">349</span> +<span id="350">350</span> +<span id="351">351</span> +<span id="352">352</span> +<span id="353">353</span> +<span id="354">354</span> +<span id="355">355</span> +<span id="356">356</span> +<span id="357">357</span> +<span id="358">358</span> +<span id="359">359</span> +<span id="360">360</span> +<span id="361">361</span> +<span id="362">362</span> +<span id="363">363</span> +<span id="364">364</span> +<span id="365">365</span> +<span id="366">366</span> +<span id="367">367</span> +<span id="368">368</span> +<span id="369">369</span> +<span id="370">370</span> +<span id="371">371</span> +<span id="372">372</span> +<span id="373">373</span> +<span id="374">374</span> +<span id="375">375</span> +<span id="376">376</span> +<span id="377">377</span> +<span id="378">378</span> +<span id="379">379</span> +<span id="380">380</span> +<span id="381">381</span> +<span id="382">382</span> +<span id="383">383</span> +<span id="384">384</span> +<span id="385">385</span> +<span id="386">386</span> +<span id="387">387</span> +<span id="388">388</span> +<span id="389">389</span> +<span id="390">390</span> +<span id="391">391</span> +<span id="392">392</span> +<span id="393">393</span> +<span id="394">394</span> +<span id="395">395</span> +<span id="396">396</span> +<span id="397">397</span> +<span id="398">398</span> +<span id="399">399</span> +<span id="400">400</span> +<span id="401">401</span> +<span id="402">402</span> +<span id="403">403</span> +<span id="404">404</span> +<span id="405">405</span> +<span id="406">406</span> +<span id="407">407</span> +<span id="408">408</span> +<span id="409">409</span> +<span id="410">410</span> +<span id="411">411</span> +<span id="412">412</span> +<span id="413">413</span> +<span id="414">414</span> +<span id="415">415</span> +<span id="416">416</span> +<span id="417">417</span> +<span id="418">418</span> +<span id="419">419</span> +<span id="420">420</span> +<span id="421">421</span> +<span id="422">422</span> +<span id="423">423</span> +<span id="424">424</span> +<span id="425">425</span> +<span id="426">426</span> +<span id="427">427</span> +<span id="428">428</span> +<span id="429">429</span> +<span id="430">430</span> +<span id="431">431</span> +<span id="432">432</span> +<span id="433">433</span> +<span id="434">434</span> +<span id="435">435</span> +<span id="436">436</span> +<span id="437">437</span> +<span id="438">438</span> +<span id="439">439</span> +<span id="440">440</span> +<span id="441">441</span> +<span id="442">442</span> +<span id="443">443</span> +<span id="444">444</span> +<span id="445">445</span> +<span id="446">446</span> +<span id="447">447</span> +<span id="448">448</span> +<span id="449">449</span> +<span id="450">450</span> +<span id="451">451</span> +<span id="452">452</span> +<span id="453">453</span> +<span id="454">454</span> +<span id="455">455</span> +<span id="456">456</span> +<span id="457">457</span> +<span id="458">458</span> +<span id="459">459</span> +<span id="460">460</span> +<span id="461">461</span> +<span id="462">462</span> +<span id="463">463</span> +<span id="464">464</span> +<span id="465">465</span> +<span id="466">466</span> +<span id="467">467</span> +<span id="468">468</span> +<span id="469">469</span> +<span id="470">470</span> +<span id="471">471</span> +<span id="472">472</span> +<span id="473">473</span> +<span id="474">474</span> +<span id="475">475</span> +<span id="476">476</span> +<span id="477">477</span> +<span id="478">478</span> +<span id="479">479</span> +<span id="480">480</span> +<span id="481">481</span> +<span id="482">482</span> +<span id="483">483</span> +<span id="484">484</span> +<span id="485">485</span> +<span id="486">486</span> +<span id="487">487</span> +<span id="488">488</span> +<span id="489">489</span> +<span id="490">490</span> +<span id="491">491</span> +<span id="492">492</span> +<span id="493">493</span> +<span id="494">494</span> +<span id="495">495</span> +<span id="496">496</span> +<span id="497">497</span> +<span id="498">498</span> +<span id="499">499</span> +<span id="500">500</span> +<span id="501">501</span> +<span id="502">502</span> +<span id="503">503</span> +<span id="504">504</span> +<span id="505">505</span> +<span id="506">506</span> +<span id="507">507</span> +<span id="508">508</span> +<span id="509">509</span> +<span id="510">510</span> +<span id="511">511</span> +<span id="512">512</span> +<span id="513">513</span> +<span id="514">514</span> +<span id="515">515</span> +<span id="516">516</span> +<span id="517">517</span> +<span id="518">518</span> +<span id="519">519</span> +<span id="520">520</span> +<span id="521">521</span> +<span id="522">522</span> +<span id="523">523</span> +<span id="524">524</span> +<span id="525">525</span> +<span id="526">526</span> +<span id="527">527</span> +<span id="528">528</span> +<span id="529">529</span> +<span id="530">530</span> +<span id="531">531</span> +<span id="532">532</span> +<span id="533">533</span> +<span id="534">534</span> +<span id="535">535</span> +<span id="536">536</span> +<span id="537">537</span> +<span id="538">538</span> +<span id="539">539</span> +<span id="540">540</span> +<span id="541">541</span> +<span id="542">542</span> +<span id="543">543</span> +<span id="544">544</span> +<span id="545">545</span> +<span id="546">546</span> +<span id="547">547</span> +<span id="548">548</span> +<span id="549">549</span> +<span id="550">550</span> +<span id="551">551</span> +<span id="552">552</span> +<span id="553">553</span> +<span id="554">554</span> +<span id="555">555</span> +<span id="556">556</span> +<span id="557">557</span> +<span id="558">558</span> +<span id="559">559</span> +<span id="560">560</span> +<span id="561">561</span> +<span id="562">562</span> +<span id="563">563</span> +<span id="564">564</span> +<span id="565">565</span> +<span id="566">566</span> +<span id="567">567</span> +<span id="568">568</span> +<span id="569">569</span> +<span id="570">570</span> +<span id="571">571</span> +<span id="572">572</span> +<span id="573">573</span> +<span id="574">574</span> +<span id="575">575</span> +<span id="576">576</span> +<span id="577">577</span> +<span id="578">578</span> +<span id="579">579</span> +<span id="580">580</span> +<span id="581">581</span> +<span id="582">582</span> +<span id="583">583</span> +<span id="584">584</span> +<span id="585">585</span> +<span id="586">586</span> +<span id="587">587</span> +<span id="588">588</span> +<span id="589">589</span> +<span id="590">590</span> +<span id="591">591</span> +<span id="592">592</span> +<span id="593">593</span> +<span id="594">594</span> +<span id="595">595</span> +<span id="596">596</span> +<span id="597">597</span> +<span id="598">598</span> +<span id="599">599</span> +<span id="600">600</span> +<span id="601">601</span> +<span id="602">602</span> +<span id="603">603</span> +<span id="604">604</span> +<span id="605">605</span> +<span id="606">606</span> +<span id="607">607</span> +<span id="608">608</span> +<span id="609">609</span> +<span id="610">610</span> +<span id="611">611</span> +<span id="612">612</span> +<span id="613">613</span> +<span id="614">614</span> +<span id="615">615</span> +<span id="616">616</span> +<span id="617">617</span> +<span id="618">618</span> +<span id="619">619</span> +<span id="620">620</span> +<span id="621">621</span> +<span id="622">622</span> +<span id="623">623</span> +<span id="624">624</span> +<span id="625">625</span> +<span id="626">626</span> +<span id="627">627</span> +<span id="628">628</span> +<span id="629">629</span> +<span id="630">630</span> +<span id="631">631</span> +<span id="632">632</span> +<span id="633">633</span> +<span id="634">634</span> +<span id="635">635</span> +<span id="636">636</span> +<span id="637">637</span> +<span id="638">638</span> +<span id="639">639</span> +<span id="640">640</span> +<span id="641">641</span> +<span id="642">642</span> +<span id="643">643</span> +<span id="644">644</span> +<span id="645">645</span> +<span id="646">646</span> +<span id="647">647</span> +<span id="648">648</span> +<span id="649">649</span> +<span id="650">650</span> +<span id="651">651</span> +<span id="652">652</span> +<span id="653">653</span> +<span id="654">654</span> +<span id="655">655</span> +<span id="656">656</span> +<span id="657">657</span> +<span id="658">658</span> +<span id="659">659</span> +<span id="660">660</span> +<span id="661">661</span> +<span id="662">662</span> +<span id="663">663</span> +<span id="664">664</span> +<span id="665">665</span> +<span id="666">666</span> +<span id="667">667</span> +<span id="668">668</span> +<span id="669">669</span> +<span id="670">670</span> +<span id="671">671</span> +<span id="672">672</span> +<span id="673">673</span> +<span id="674">674</span> +<span id="675">675</span> +<span id="676">676</span> +<span id="677">677</span> +<span id="678">678</span> +<span id="679">679</span> +<span id="680">680</span> +<span id="681">681</span> +<span id="682">682</span> +<span id="683">683</span> +<span id="684">684</span> +<span id="685">685</span> +<span id="686">686</span> +<span id="687">687</span> +<span id="688">688</span> +<span id="689">689</span> +<span id="690">690</span> +<span id="691">691</span> +<span id="692">692</span> +<span id="693">693</span> +<span id="694">694</span> +<span id="695">695</span> +<span id="696">696</span> +<span id="697">697</span> +<span id="698">698</span> +<span id="699">699</span> +<span id="700">700</span> +<span id="701">701</span> +<span id="702">702</span> +<span id="703">703</span> +<span id="704">704</span> +<span id="705">705</span> +<span id="706">706</span> +<span id="707">707</span> +<span id="708">708</span> +<span id="709">709</span> +<span id="710">710</span> +<span id="711">711</span> +<span id="712">712</span> +<span id="713">713</span> +<span id="714">714</span> +<span id="715">715</span> +<span id="716">716</span> +<span id="717">717</span> +<span id="718">718</span> +<span id="719">719</span> +<span id="720">720</span> +<span id="721">721</span> +<span id="722">722</span> +<span id="723">723</span> +<span id="724">724</span> +<span id="725">725</span> +<span id="726">726</span> +<span id="727">727</span> +<span id="728">728</span> +<span id="729">729</span> +<span id="730">730</span> +<span id="731">731</span> +<span id="732">732</span> +<span id="733">733</span> +<span id="734">734</span> +<span id="735">735</span> +<span id="736">736</span> +<span id="737">737</span> +<span id="738">738</span> +<span id="739">739</span> +<span id="740">740</span> +<span id="741">741</span> +<span id="742">742</span> +<span id="743">743</span> +<span id="744">744</span> +<span id="745">745</span> +<span id="746">746</span> +<span id="747">747</span> +<span id="748">748</span> +<span id="749">749</span> +<span id="750">750</span> +<span id="751">751</span> +<span id="752">752</span> +<span id="753">753</span> +<span id="754">754</span> +<span id="755">755</span> +<span id="756">756</span> +<span id="757">757</span> +<span id="758">758</span> +<span id="759">759</span> +<span id="760">760</span> +<span id="761">761</span> +<span id="762">762</span> +<span id="763">763</span> +<span id="764">764</span> +<span id="765">765</span> +<span id="766">766</span> +<span id="767">767</span> +<span id="768">768</span> +<span id="769">769</span> +<span id="770">770</span> +<span id="771">771</span> +<span id="772">772</span> +<span id="773">773</span> +<span id="774">774</span> +<span id="775">775</span> +<span id="776">776</span> +<span id="777">777</span> +<span id="778">778</span> +<span id="779">779</span> +<span id="780">780</span> +<span id="781">781</span> +<span id="782">782</span> +<span id="783">783</span> +<span id="784">784</span> +<span id="785">785</span> +<span id="786">786</span> +<span id="787">787</span> +<span id="788">788</span> +<span id="789">789</span> +<span id="790">790</span> +<span id="791">791</span> +<span id="792">792</span> +<span id="793">793</span> +<span id="794">794</span> +<span id="795">795</span> +<span id="796">796</span> +<span id="797">797</span> +<span id="798">798</span> +<span id="799">799</span> +<span id="800">800</span> +<span id="801">801</span> +<span id="802">802</span> +<span id="803">803</span> +<span id="804">804</span> +<span id="805">805</span> +<span id="806">806</span> +<span id="807">807</span> +<span id="808">808</span> +<span id="809">809</span> +<span id="810">810</span> +<span id="811">811</span> +<span id="812">812</span> +<span id="813">813</span> +<span id="814">814</span> +<span id="815">815</span> +<span id="816">816</span> +<span id="817">817</span> +<span id="818">818</span> +<span id="819">819</span> +<span id="820">820</span> +<span id="821">821</span> +<span id="822">822</span> +<span id="823">823</span> +<span id="824">824</span> +<span id="825">825</span> +<span id="826">826</span> +<span id="827">827</span> +<span id="828">828</span> +<span id="829">829</span> +<span id="830">830</span> +<span id="831">831</span> +<span id="832">832</span> +<span id="833">833</span> +<span id="834">834</span> +<span id="835">835</span> +<span id="836">836</span> +<span id="837">837</span> +<span id="838">838</span> +<span id="839">839</span> +<span id="840">840</span> +<span id="841">841</span> +<span id="842">842</span> +<span id="843">843</span> +<span id="844">844</span> +<span id="845">845</span> +<span id="846">846</span> +<span id="847">847</span> +<span id="848">848</span> +<span id="849">849</span> +<span id="850">850</span> +<span id="851">851</span> +<span id="852">852</span> +<span id="853">853</span> +<span id="854">854</span> +<span id="855">855</span> +<span id="856">856</span> +<span id="857">857</span> +<span id="858">858</span> +<span id="859">859</span> +<span id="860">860</span> +<span id="861">861</span> +<span id="862">862</span> +<span id="863">863</span> +<span id="864">864</span> +<span id="865">865</span> +<span id="866">866</span> +<span id="867">867</span> +<span id="868">868</span> +<span id="869">869</span> +<span id="870">870</span> +<span id="871">871</span> +<span id="872">872</span> +<span id="873">873</span> +<span id="874">874</span> +<span id="875">875</span> +<span id="876">876</span> +<span id="877">877</span> +<span id="878">878</span> +<span id="879">879</span> +<span id="880">880</span> +<span id="881">881</span> +<span id="882">882</span> +<span id="883">883</span> +<span id="884">884</span> +<span id="885">885</span> +<span id="886">886</span> +<span id="887">887</span> +<span id="888">888</span> +<span id="889">889</span> +<span id="890">890</span> +<span id="891">891</span> +<span id="892">892</span> +<span id="893">893</span> +<span id="894">894</span> +<span id="895">895</span> +<span id="896">896</span> +<span id="897">897</span> +<span id="898">898</span> +<span id="899">899</span> +<span id="900">900</span> +<span id="901">901</span> +<span id="902">902</span> +<span id="903">903</span> +<span id="904">904</span> +<span id="905">905</span> +<span id="906">906</span> +<span id="907">907</span> +<span id="908">908</span> +<span id="909">909</span> +<span id="910">910</span> +<span id="911">911</span> +<span id="912">912</span> +<span id="913">913</span> +<span id="914">914</span> +<span id="915">915</span> +<span id="916">916</span> +<span id="917">917</span> +<span id="918">918</span> +<span id="919">919</span> +<span id="920">920</span> +<span id="921">921</span> +<span id="922">922</span> +<span id="923">923</span> +<span id="924">924</span> +<span id="925">925</span> +<span id="926">926</span> +<span id="927">927</span> +<span id="928">928</span> +<span id="929">929</span> +<span id="930">930</span> +<span id="931">931</span> +<span id="932">932</span> +<span id="933">933</span> +<span id="934">934</span> +<span id="935">935</span> +<span id="936">936</span> +<span id="937">937</span> +<span id="938">938</span> +<span id="939">939</span> +<span id="940">940</span> +<span id="941">941</span> +<span id="942">942</span> +<span id="943">943</span> +<span id="944">944</span> +<span id="945">945</span> +<span id="946">946</span> +<span id="947">947</span> +<span id="948">948</span> +<span id="949">949</span> +<span id="950">950</span> +<span id="951">951</span> +<span id="952">952</span> +<span id="953">953</span> +<span id="954">954</span> +<span id="955">955</span> +<span id="956">956</span> +<span id="957">957</span> +<span id="958">958</span> +<span id="959">959</span> +<span id="960">960</span> +<span id="961">961</span> +<span id="962">962</span> +<span id="963">963</span> +<span id="964">964</span> +<span id="965">965</span> +<span id="966">966</span> +<span id="967">967</span> +<span id="968">968</span> +<span id="969">969</span> +<span id="970">970</span> +<span id="971">971</span> +<span id="972">972</span> +<span id="973">973</span> +<span id="974">974</span> +<span id="975">975</span> +<span id="976">976</span> +<span id="977">977</span> +<span id="978">978</span> +<span id="979">979</span> +<span id="980">980</span> +<span id="981">981</span> +<span id="982">982</span> +<span id="983">983</span> +<span id="984">984</span> +<span id="985">985</span> +<span id="986">986</span> +<span id="987">987</span> +<span id="988">988</span> +<span id="989">989</span> +<span id="990">990</span> +<span id="991">991</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>libc</span>::{<span class='ident'>c_int</span>, <span class='ident'>c_void</span>, <span class='ident'>c_long</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>any</span>::<span class='ident'>TypeId</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ffi</span>::{<span class='ident'>CStr</span>, <span class='ident'>CString</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>fmt</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>::<span class='ident'>prelude</span>::<span class='op'>*</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>mem</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>net</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>path</span>::<span class='ident'>Path</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ptr</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>sync</span>::{<span class='ident'>Once</span>, <span class='ident'>ONCE_INIT</span>, <span class='ident'>Arc</span>, <span class='ident'>Mutex</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ops</span>::{<span class='ident'>Deref</span>, <span class='ident'>DerefMut</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>cmp</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>any</span>::<span class='ident'>Any</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"npn"</span>)]</span> +<span class='kw'>use</span> <span class='ident'>libc</span>::{<span class='ident'>c_uchar</span>, <span class='ident'>c_uint</span>}; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"npn"</span>)]</span> +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>slice</span>; + +<span class='kw'>use</span> <span class='ident'>bio</span>::{<span class='ident'>MemBio</span>}; +<span class='kw'>use</span> <span class='ident'>ffi</span>; +<span class='kw'>use</span> <span class='ident'>ssl</span>::<span class='ident'>error</span>::{<span class='ident'>SslError</span>, <span class='ident'>SslSessionClosed</span>, <span class='ident'>StreamError</span>, <span class='ident'>OpenSslErrors</span>}; +<span class='kw'>use</span> <span class='ident'>x509</span>::{<span class='ident'>X509StoreContext</span>, <span class='ident'>X509FileType</span>, <span class='ident'>X509</span>}; +<span class='kw'>use</span> <span class='ident'>crypto</span>::<span class='ident'>pkey</span>::<span class='ident'>PKey</span>; + +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>error</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>tests</span>; + +<span class='kw'>static</span> <span class='kw-2'>mut</span> <span class='ident'>VERIFY_IDX</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>1</span>; + +<span class='kw'>fn</span> <span class='ident'>init</span>() { + <span class='kw'>static</span> <span class='kw-2'>mut</span> <span class='ident'>INIT</span>: <span class='ident'>Once</span> <span class='op'>=</span> <span class='ident'>ONCE_INIT</span>; + + <span class='kw'>unsafe</span> { + <span class='ident'>INIT</span>.<span class='ident'>call_once</span>(<span class='op'>||</span> { + <span class='ident'>ffi</span>::<span class='ident'>init</span>(); + + <span class='kw'>let</span> <span class='ident'>verify_idx</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_get_ex_new_index</span>(<span class='number'>0</span>, <span class='ident'>ptr</span>::<span class='ident'>null</span>(), <span class='prelude-val'>None</span>, + <span class='prelude-val'>None</span>, <span class='prelude-val'>None</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>verify_idx</span> <span class='op'>>=</span> <span class='number'>0</span>); + <span class='ident'>VERIFY_IDX</span> <span class='op'>=</span> <span class='ident'>verify_idx</span>; + }); + } +} + +<span class='macro'>bitflags</span><span class='macro'>!</span> { + <span class='ident'>flags</span> <span class='ident'>SslContextOptions</span>: <span class='ident'>c_long</span> { + <span class='kw'>const</span> <span class='ident'>SSL_OP_LEGACY_SERVER_CONNECT</span> <span class='op'>=</span> <span class='number'>0x00000004</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG</span> <span class='op'>=</span> <span class='number'>0x00000008</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_TLSEXT_PADDING</span> <span class='op'>=</span> <span class='number'>0x00000010</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER</span> <span class='op'>=</span> <span class='number'>0x00000020</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_SAFARI_ECDHE_ECDSA_BUG</span> <span class='op'>=</span> <span class='number'>0x00000040</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_SSLEAY_080_CLIENT_DH_BUG</span> <span class='op'>=</span> <span class='number'>0x00000080</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_TLS_D5_BUG</span> <span class='op'>=</span> <span class='number'>0x00000100</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_TLS_BLOCK_PADDING_BUG</span> <span class='op'>=</span> <span class='number'>0x00000200</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS</span> <span class='op'>=</span> <span class='number'>0x00000800</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_ALL</span> <span class='op'>=</span> <span class='number'>0x80000BFF</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_NO_QUERY_MTU</span> <span class='op'>=</span> <span class='number'>0x00001000</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_COOKIE_EXCHANGE</span> <span class='op'>=</span> <span class='number'>0x00002000</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_NO_TICKET</span> <span class='op'>=</span> <span class='number'>0x00004000</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_CISCO_ANYCONNECT</span> <span class='op'>=</span> <span class='number'>0x00008000</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION</span> <span class='op'>=</span> <span class='number'>0x00010000</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_NO_COMPRESSION</span> <span class='op'>=</span> <span class='number'>0x00020000</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION</span> <span class='op'>=</span> <span class='number'>0x00040000</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_SINGLE_ECDH_USE</span> <span class='op'>=</span> <span class='number'>0x00080000</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_SINGLE_DH_USE</span> <span class='op'>=</span> <span class='number'>0x00100000</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_CIPHER_SERVER_PREFERENCE</span> <span class='op'>=</span> <span class='number'>0x00400000</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_TLS_ROLLBACK_BUG</span> <span class='op'>=</span> <span class='number'>0x00800000</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_NO_SSLV2</span> <span class='op'>=</span> <span class='number'>0x00000000</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_NO_SSLV3</span> <span class='op'>=</span> <span class='number'>0x02000000</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_NO_TLSV1</span> <span class='op'>=</span> <span class='number'>0x04000000</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_NO_TLSV1_2</span> <span class='op'>=</span> <span class='number'>0x08000000</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_NO_TLSV1_1</span> <span class='op'>=</span> <span class='number'>0x10000000</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_NO_DTLSV1</span> <span class='op'>=</span> <span class='number'>0x04000000</span>, + <span class='kw'>const</span> <span class='ident'>SSL_OP_NO_DTLSV1_2</span> <span class='op'>=</span> <span class='number'>0x08000000</span> + } +} + +<span class='doccomment'>/// Determines the SSL method supported</span> +<span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>non_camel_case_types</span>)]</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>, <span class='ident'>Debug</span>, <span class='ident'>Hash</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>SslMethod</span> { + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"sslv2"</span>)]</span> + <span class='doccomment'>/// Only support the SSLv2 protocol, requires the `sslv2` feature.</span> + <span class='ident'>Sslv2</span>, + <span class='doccomment'>/// Support the SSLv2, SSLv3 and TLSv1 protocols.</span> + <span class='ident'>Sslv23</span>, + <span class='doccomment'>/// Only support the SSLv3 protocol.</span> + <span class='ident'>Sslv3</span>, + <span class='doccomment'>/// Only support the TLSv1 protocol.</span> + <span class='ident'>Tlsv1</span>, + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"tlsv1_1"</span>)]</span> + <span class='doccomment'>/// Support TLSv1.1 protocol, requires the `tlsv1_1` feature.</span> + <span class='ident'>Tlsv1_1</span>, + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"tlsv1_2"</span>)]</span> + <span class='doccomment'>/// Support TLSv1.2 protocol, requires the `tlsv1_2` feature.</span> + <span class='ident'>Tlsv1_2</span>, + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"dtlsv1"</span>)]</span> + <span class='doccomment'>/// Support DTLSv1 protocol, requires the `dtlsv1` feature.</span> + <span class='ident'>Dtlsv1</span>, + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"dtlsv1_2"</span>)]</span> + <span class='doccomment'>/// Support DTLSv1.2 protocol, requires the `dtlsv1_2` feature.</span> + <span class='ident'>Dtlsv1_2</span>, +} + +<span class='kw'>impl</span> <span class='ident'>SslMethod</span> { + <span class='kw'>unsafe</span> <span class='kw'>fn</span> <span class='ident'>to_raw</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_METHOD</span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"sslv2"</span>)]</span> + <span class='ident'>SslMethod</span>::<span class='ident'>Sslv2</span> <span class='op'>=></span> <span class='ident'>ffi</span>::<span class='ident'>SSLv2_method</span>(), + <span class='ident'>SslMethod</span>::<span class='ident'>Sslv3</span> <span class='op'>=></span> <span class='ident'>ffi</span>::<span class='ident'>SSLv3_method</span>(), + <span class='ident'>SslMethod</span>::<span class='ident'>Tlsv1</span> <span class='op'>=></span> <span class='ident'>ffi</span>::<span class='ident'>TLSv1_method</span>(), + <span class='ident'>SslMethod</span>::<span class='ident'>Sslv23</span> <span class='op'>=></span> <span class='ident'>ffi</span>::<span class='ident'>SSLv23_method</span>(), + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"tlsv1_1"</span>)]</span> + <span class='ident'>SslMethod</span>::<span class='ident'>Tlsv1_1</span> <span class='op'>=></span> <span class='ident'>ffi</span>::<span class='ident'>TLSv1_1_method</span>(), + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"tlsv1_2"</span>)]</span> + <span class='ident'>SslMethod</span>::<span class='ident'>Tlsv1_2</span> <span class='op'>=></span> <span class='ident'>ffi</span>::<span class='ident'>TLSv1_2_method</span>(), + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"dtlsv1"</span>)]</span> + <span class='ident'>SslMethod</span>::<span class='ident'>Dtlsv1</span> <span class='op'>=></span> <span class='ident'>ffi</span>::<span class='ident'>DTLSv1_method</span>(), + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"dtlsv1_2"</span>)]</span> + <span class='ident'>SslMethod</span>::<span class='ident'>Dtlsv1_2</span> <span class='op'>=></span> <span class='ident'>ffi</span>::<span class='ident'>DTLSv1_2_method</span>(), + } + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"dtlsv1"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_dtlsv1</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='op'>*</span><span class='self'>self</span> <span class='op'>==</span> <span class='ident'>SslMethod</span>::<span class='ident'>Dtlsv1</span> + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"dtlsv1_2"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_dtlsv1_2</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='op'>*</span><span class='self'>self</span> <span class='op'>==</span> <span class='ident'>SslMethod</span>::<span class='ident'>Dtlsv1_2</span> + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_dtls</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='self'>self</span>.<span class='ident'>is_dtlsv1</span>() <span class='op'>||</span> <span class='self'>self</span>.<span class='ident'>is_dtlsv1_2</span>() + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"dtlsv1"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_dtlsv1</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='boolval'>false</span> + } + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>not</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"dtlsv1_2"</span>))]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_dtlsv1_2</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='boolval'>false</span> + } +} + +<span class='doccomment'>/// Determines the type of certificate verification used</span> +<span class='macro'>bitflags</span><span class='macro'>!</span> { + <span class='ident'>flags</span> <span class='ident'>SslVerifyMode</span>: <span class='ident'>i32</span> { + <span class='doccomment'>/// Verify that the server's certificate is trusted</span> + <span class='kw'>const</span> <span class='ident'>SSL_VERIFY_PEER</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_VERIFY_PEER</span>, + <span class='doccomment'>/// Do not verify the server's certificate</span> + <span class='kw'>const</span> <span class='ident'>SSL_VERIFY_NONE</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_VERIFY_NONE</span>, + <span class='doccomment'>/// Terminate handshake if client did not return a certificate.</span> + <span class='doccomment'>/// Use together with SSL_VERIFY_PEER.</span> + <span class='kw'>const</span> <span class='ident'>SSL_VERIFY_FAIL_IF_NO_PEER_CERT</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_VERIFY_FAIL_IF_NO_PEER_CERT</span>, + } +} + +<span class='macro'>lazy_static</span><span class='macro'>!</span> { + <span class='kw'>static</span> <span class='kw-2'>ref</span> <span class='ident'>INDEXES</span>: <span class='ident'>Mutex</span><span class='op'><</span><span class='ident'>HashMap</span><span class='op'><</span><span class='ident'>TypeId</span>, <span class='ident'>c_int</span><span class='op'>>></span> <span class='op'>=</span> <span class='ident'>Mutex</span>::<span class='ident'>new</span>(<span class='ident'>HashMap</span>::<span class='ident'>new</span>()); +} + +<span class='comment'>// Creates a static index for user data of type T</span> +<span class='comment'>// Registers a destructor for the data which will be called</span> +<span class='comment'>// when context is freed</span> +<span class='kw'>fn</span> <span class='ident'>get_verify_data_idx</span><span class='op'><</span><span class='ident'>T</span>: <span class='ident'>Any</span> <span class='op'>+</span> <span class='lifetime'>'static</span><span class='op'>></span>() <span class='op'>-></span> <span class='ident'>c_int</span> { + <span class='kw'>extern</span> <span class='kw'>fn</span> <span class='ident'>free_data_box</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span>(<span class='ident'>_parent</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>ptr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>_ad</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>CRYPTO_EX_DATA</span>, <span class='ident'>_idx</span>: <span class='ident'>c_int</span>, + <span class='ident'>_argl</span>: <span class='ident'>c_long</span>, <span class='ident'>_argp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>) { + <span class='kw'>if</span> <span class='ident'>ptr</span> <span class='op'>!=</span> <span class='number'>0</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw-2'>mut</span> _ { + <span class='kw'>let</span> _: <span class='ident'>Box</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='ident'>ptr</span>) }; + } + } + + <span class='op'>*</span><span class='ident'>INDEXES</span>.<span class='ident'>lock</span>().<span class='ident'>unwrap</span>().<span class='ident'>entry</span>(<span class='ident'>TypeId</span>::<span class='ident'>of</span>::<span class='op'><</span><span class='ident'>T</span><span class='op'>></span>()).<span class='ident'>or_insert_with</span>(<span class='op'>||</span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>f</span>: <span class='ident'>ffi</span>::<span class='ident'>CRYPTO_EX_free</span> <span class='op'>=</span> <span class='ident'>free_data_box</span>::<span class='op'><</span><span class='ident'>T</span><span class='op'>></span>; + <span class='kw'>let</span> <span class='ident'>idx</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_get_ex_new_index</span>(<span class='number'>0</span>, <span class='ident'>ptr</span>::<span class='ident'>null</span>(), <span class='prelude-val'>None</span>, <span class='prelude-val'>None</span>, <span class='prelude-val'>Some</span>(<span class='ident'>f</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>idx</span> <span class='op'>>=</span> <span class='number'>0</span>); + <span class='ident'>idx</span> + } + }) +} + +<span class='doccomment'>/// Creates a static index for the list of NPN protocols.</span> +<span class='doccomment'>/// Registers a destructor for the data which will be called</span> +<span class='doccomment'>/// when the context is freed.</span> +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"npn"</span>)]</span> +<span class='kw'>fn</span> <span class='ident'>get_npn_protos_idx</span>() <span class='op'>-></span> <span class='ident'>c_int</span> { + <span class='kw'>static</span> <span class='kw-2'>mut</span> <span class='ident'>NPN_PROTOS_IDX</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='op'>-</span><span class='number'>1</span>; + <span class='kw'>static</span> <span class='kw-2'>mut</span> <span class='ident'>INIT</span>: <span class='ident'>Once</span> <span class='op'>=</span> <span class='ident'>ONCE_INIT</span>; + + <span class='kw'>extern</span> <span class='kw'>fn</span> <span class='ident'>free_data_box</span>(<span class='ident'>_parent</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>ptr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>_ad</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>CRYPTO_EX_DATA</span>, <span class='ident'>_idx</span>: <span class='ident'>c_int</span>, + <span class='ident'>_argl</span>: <span class='ident'>c_long</span>, <span class='ident'>_argp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>) { + <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>ptr</span>.<span class='ident'>is_null</span>() { + <span class='kw'>let</span> _: <span class='ident'>Box</span><span class='op'><</span><span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>>></span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='ident'>ptr</span>) }; + } + } + + <span class='kw'>unsafe</span> { + <span class='ident'>INIT</span>.<span class='ident'>call_once</span>(<span class='op'>||</span> { + <span class='kw'>let</span> <span class='ident'>f</span>: <span class='ident'>ffi</span>::<span class='ident'>CRYPTO_EX_free</span> <span class='op'>=</span> <span class='ident'>free_data_box</span>; + <span class='kw'>let</span> <span class='ident'>idx</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_get_ex_new_index</span>(<span class='number'>0</span>, <span class='ident'>ptr</span>::<span class='ident'>null</span>(), <span class='prelude-val'>None</span>, + <span class='prelude-val'>None</span>, <span class='prelude-val'>Some</span>(<span class='ident'>f</span>)); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>idx</span> <span class='op'>>=</span> <span class='number'>0</span>); + <span class='ident'>NPN_PROTOS_IDX</span> <span class='op'>=</span> <span class='ident'>idx</span>; + }); + <span class='ident'>NPN_PROTOS_IDX</span> + } +} + +<span class='kw'>extern</span> <span class='kw'>fn</span> <span class='ident'>raw_verify</span>(<span class='ident'>preverify_ok</span>: <span class='ident'>c_int</span>, <span class='ident'>x509_ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>X509_STORE_CTX</span>) + <span class='op'>-></span> <span class='ident'>c_int</span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>idx</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_get_ex_data_X509_STORE_CTX_idx</span>(); + <span class='kw'>let</span> <span class='ident'>ssl</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>X509_STORE_CTX_get_ex_data</span>(<span class='ident'>x509_ctx</span>, <span class='ident'>idx</span>); + <span class='kw'>let</span> <span class='ident'>ssl_ctx</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_get_SSL_CTX</span>(<span class='ident'>ssl</span>); + <span class='kw'>let</span> <span class='ident'>verify</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_get_ex_data</span>(<span class='ident'>ssl_ctx</span>, <span class='ident'>VERIFY_IDX</span>); + <span class='kw'>let</span> <span class='ident'>verify</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>VerifyCallback</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='ident'>verify</span>); + + <span class='kw'>let</span> <span class='ident'>ctx</span> <span class='op'>=</span> <span class='ident'>X509StoreContext</span>::<span class='ident'>new</span>(<span class='ident'>x509_ctx</span>); + + <span class='kw'>match</span> <span class='ident'>verify</span> { + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='ident'>preverify_ok</span>, + <span class='prelude-val'>Some</span>(<span class='ident'>verify</span>) <span class='op'>=></span> <span class='ident'>verify</span>(<span class='ident'>preverify_ok</span> <span class='op'>!=</span> <span class='number'>0</span>, <span class='kw-2'>&</span><span class='ident'>ctx</span>) <span class='kw'>as</span> <span class='ident'>c_int</span> + } + } +} + +<span class='kw'>extern</span> <span class='kw'>fn</span> <span class='ident'>raw_verify_with_data</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span>(<span class='ident'>preverify_ok</span>: <span class='ident'>c_int</span>, + <span class='ident'>x509_ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>X509_STORE_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span> + <span class='kw'>where</span> <span class='ident'>T</span>: <span class='ident'>Any</span> <span class='op'>+</span> <span class='lifetime'>'static</span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>idx</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_get_ex_data_X509_STORE_CTX_idx</span>(); + <span class='kw'>let</span> <span class='ident'>ssl</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>X509_STORE_CTX_get_ex_data</span>(<span class='ident'>x509_ctx</span>, <span class='ident'>idx</span>); + <span class='kw'>let</span> <span class='ident'>ssl_ctx</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_get_SSL_CTX</span>(<span class='ident'>ssl</span>); + + <span class='kw'>let</span> <span class='ident'>verify</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_get_ex_data</span>(<span class='ident'>ssl_ctx</span>, <span class='ident'>VERIFY_IDX</span>); + <span class='kw'>let</span> <span class='ident'>verify</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>VerifyCallbackData</span><span class='op'><</span><span class='ident'>T</span><span class='op'>>></span> <span class='op'>=</span> <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='ident'>verify</span>); + + <span class='kw'>let</span> <span class='ident'>data</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_get_ex_data</span>(<span class='ident'>ssl_ctx</span>, <span class='ident'>get_verify_data_idx</span>::<span class='op'><</span><span class='ident'>T</span><span class='op'>></span>()); + <span class='kw'>let</span> <span class='ident'>data</span>: <span class='ident'>Box</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='ident'>data</span>); + + <span class='kw'>let</span> <span class='ident'>ctx</span> <span class='op'>=</span> <span class='ident'>X509StoreContext</span>::<span class='ident'>new</span>(<span class='ident'>x509_ctx</span>); + + <span class='kw'>let</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>verify</span> { + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='ident'>preverify_ok</span>, + <span class='prelude-val'>Some</span>(<span class='ident'>verify</span>) <span class='op'>=></span> <span class='ident'>verify</span>(<span class='ident'>preverify_ok</span> <span class='op'>!=</span> <span class='number'>0</span>, <span class='kw-2'>&</span><span class='ident'>ctx</span>, <span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>data</span>) <span class='kw'>as</span> <span class='ident'>c_int</span> + }; + + <span class='comment'>// Since data might be required on the next verification</span> + <span class='comment'>// it is time to forget about it and avoid dropping</span> + <span class='comment'>// data will be freed once OpenSSL considers it is time</span> + <span class='comment'>// to free all context data</span> + <span class='ident'>mem</span>::<span class='ident'>forget</span>(<span class='ident'>data</span>); + <span class='ident'>res</span> + } +} + +<span class='doccomment'>/// The function is given as the callback to `SSL_CTX_set_next_proto_select_cb`.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// It chooses the protocol that the client wishes to use, out of the given list of protocols</span> +<span class='doccomment'>/// supported by the server. It achieves this by delegating to the `SSL_select_next_proto`</span> +<span class='doccomment'>/// function. The list of protocols supported by the client is found in the extra data of the</span> +<span class='doccomment'>/// OpenSSL context.</span> +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"npn"</span>)]</span> +<span class='kw'>extern</span> <span class='kw'>fn</span> <span class='ident'>raw_next_proto_select_cb</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>SSL</span>, + <span class='ident'>out</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_uchar</span>, <span class='ident'>outlen</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_uchar</span>, + <span class='ident'>inbuf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_uchar</span>, <span class='ident'>inlen</span>: <span class='ident'>c_uint</span>, + <span class='ident'>_arg</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>) <span class='op'>-></span> <span class='ident'>c_int</span> { + <span class='kw'>unsafe</span> { + <span class='comment'>// First, get the list of protocols (that the client should support) saved in the context</span> + <span class='comment'>// extra data.</span> + <span class='kw'>let</span> <span class='ident'>ssl_ctx</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_get_SSL_CTX</span>(<span class='ident'>ssl</span>); + <span class='kw'>let</span> <span class='ident'>protocols</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_get_ex_data</span>(<span class='ident'>ssl_ctx</span>, <span class='ident'>get_npn_protos_idx</span>()); + <span class='kw'>let</span> <span class='ident'>protocols</span>: <span class='kw-2'>&</span><span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='ident'>protocols</span>); + <span class='comment'>// Prepare the client list parameters to be passed to the OpenSSL function...</span> + <span class='kw'>let</span> <span class='ident'>client</span> <span class='op'>=</span> <span class='ident'>protocols</span>.<span class='ident'>as_ptr</span>(); + <span class='kw'>let</span> <span class='ident'>client_len</span> <span class='op'>=</span> <span class='ident'>protocols</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>c_uint</span>; + <span class='comment'>// Finally, let OpenSSL find a protocol to be used, by matching the given server and</span> + <span class='comment'>// client lists.</span> + <span class='ident'>ffi</span>::<span class='ident'>SSL_select_next_proto</span>(<span class='ident'>out</span>, <span class='ident'>outlen</span>, <span class='ident'>inbuf</span>, <span class='ident'>inlen</span>, <span class='ident'>client</span>, <span class='ident'>client_len</span>); + } + + <span class='ident'>ffi</span>::<span class='ident'>SSL_TLSEXT_ERR_OK</span> +} + +<span class='doccomment'>/// The function is given as the callback to `SSL_CTX_set_next_protos_advertised_cb`.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// It causes the parameter `out` to point at a `*const c_uchar` instance that</span> +<span class='doccomment'>/// represents the list of protocols that the server should advertise as those</span> +<span class='doccomment'>/// that it supports.</span> +<span class='doccomment'>/// The list of supported protocols is found in the extra data of the OpenSSL</span> +<span class='doccomment'>/// context.</span> +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"npn"</span>)]</span> +<span class='kw'>extern</span> <span class='kw'>fn</span> <span class='ident'>raw_next_protos_advertise_cb</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>SSL</span>, + <span class='ident'>out</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_uchar</span>, <span class='ident'>outlen</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_uint</span>, + <span class='ident'>_arg</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>) <span class='op'>-></span> <span class='ident'>c_int</span> { + <span class='kw'>unsafe</span> { + <span class='comment'>// First, get the list of (supported) protocols saved in the context extra data.</span> + <span class='kw'>let</span> <span class='ident'>ssl_ctx</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_get_SSL_CTX</span>(<span class='ident'>ssl</span>); + <span class='kw'>let</span> <span class='ident'>protocols</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_get_ex_data</span>(<span class='ident'>ssl_ctx</span>, <span class='ident'>get_npn_protos_idx</span>()); + <span class='kw'>if</span> <span class='ident'>protocols</span>.<span class='ident'>is_null</span>() { + <span class='op'>*</span><span class='ident'>out</span> <span class='op'>=</span> <span class='string'>b""</span>.<span class='ident'>as_ptr</span>(); + <span class='op'>*</span><span class='ident'>outlen</span> <span class='op'>=</span> <span class='number'>0</span>; + } <span class='kw'>else</span> { + <span class='comment'>// If the pointer is valid, put the pointer to the actual byte array into the</span> + <span class='comment'>// output parameter `out`, as well as its length into `outlen`.</span> + <span class='kw'>let</span> <span class='ident'>protocols</span>: <span class='kw-2'>&</span><span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='ident'>protocols</span>); + <span class='op'>*</span><span class='ident'>out</span> <span class='op'>=</span> <span class='ident'>protocols</span>.<span class='ident'>as_ptr</span>(); + <span class='op'>*</span><span class='ident'>outlen</span> <span class='op'>=</span> <span class='ident'>protocols</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>c_uint</span>; + } + } + + <span class='ident'>ffi</span>::<span class='ident'>SSL_TLSEXT_ERR_OK</span> +} + +<span class='doccomment'>/// The signature of functions that can be used to manually verify certificates</span> +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>VerifyCallback</span> <span class='op'>=</span> <span class='kw'>fn</span>(<span class='ident'>preverify_ok</span>: <span class='ident'>bool</span>, + <span class='ident'>x509_ctx</span>: <span class='kw-2'>&</span><span class='ident'>X509StoreContext</span>) <span class='op'>-></span> <span class='ident'>bool</span>; + +<span class='doccomment'>/// The signature of functions that can be used to manually verify certificates</span> +<span class='doccomment'>/// when user-data should be carried for all verification process</span> +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>VerifyCallbackData</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> <span class='op'>=</span> <span class='kw'>fn</span>(<span class='ident'>preverify_ok</span>: <span class='ident'>bool</span>, + <span class='ident'>x509_ctx</span>: <span class='kw-2'>&</span><span class='ident'>X509StoreContext</span>, + <span class='ident'>data</span>: <span class='kw-2'>&</span><span class='ident'>T</span>) <span class='op'>-></span> <span class='ident'>bool</span>; + +<span class='comment'>// FIXME: macro may be instead of inlining?</span> +<span class='attribute'>#[<span class='ident'>inline</span>]</span> +<span class='kw'>fn</span> <span class='ident'>wrap_ssl_result</span>(<span class='ident'>res</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(),<span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>if</span> <span class='ident'>res</span> <span class='op'>==</span> <span class='number'>0</span> { + <span class='prelude-val'>Err</span>(<span class='ident'>SslError</span>::<span class='ident'>get</span>()) + } <span class='kw'>else</span> { + <span class='prelude-val'>Ok</span>(()) + } +} + +<span class='doccomment'>/// An SSL context object</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>SslContext</span> { + <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX</span> +} + +<span class='kw'>unsafe</span> <span class='kw'>impl</span> <span class='ident'>Send</span> <span class='kw'>for</span> <span class='ident'>SslContext</span> {} +<span class='kw'>unsafe</span> <span class='kw'>impl</span> <span class='ident'>Sync</span> <span class='kw'>for</span> <span class='ident'>SslContext</span> {} + +<span class='comment'>// TODO: add useful info here</span> +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Debug</span> <span class='kw'>for</span> <span class='ident'>SslContext</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>fmt</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>fmt</span>, <span class='string'>"SslContext"</span>) + } +} + +<span class='kw'>impl</span> <span class='ident'>Drop</span> <span class='kw'>for</span> <span class='ident'>SslContext</span> { + <span class='kw'>fn</span> <span class='ident'>drop</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_free</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>) } + } +} + +<span class='kw'>impl</span> <span class='ident'>SslContext</span> { + <span class='doccomment'>/// Creates a new SSL context.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>method</span>: <span class='ident'>SslMethod</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>SslContext</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='ident'>init</span>(); + + <span class='kw'>let</span> <span class='ident'>ctx</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_new</span>(<span class='ident'>method</span>.<span class='ident'>to_raw</span>()) }; + <span class='kw'>if</span> <span class='ident'>ctx</span> <span class='op'>==</span> <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>() { + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='ident'>SslError</span>::<span class='ident'>get</span>()); + } + + <span class='kw'>let</span> <span class='ident'>ctx</span> <span class='op'>=</span> <span class='ident'>SslContext</span> { <span class='ident'>ctx</span>: <span class='ident'>ctx</span> }; + + <span class='kw'>if</span> <span class='ident'>method</span>.<span class='ident'>is_dtls</span>() { + <span class='ident'>ctx</span>.<span class='ident'>set_read_ahead</span>(<span class='number'>1</span>); + } + + <span class='prelude-val'>Ok</span>(<span class='ident'>ctx</span>) + } + + <span class='doccomment'>/// Configures the certificate verification method for new connections.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_verify</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>mode</span>: <span class='ident'>SslVerifyMode</span>, + <span class='ident'>verify</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>VerifyCallback</span><span class='op'>></span>) { + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_set_ex_data</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>VERIFY_IDX</span>, + <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='ident'>verify</span>)); + <span class='kw'>let</span> <span class='ident'>f</span>: <span class='kw'>extern</span> <span class='kw'>fn</span>(<span class='ident'>c_int</span>, <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>X509_STORE_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span> <span class='op'>=</span> + <span class='ident'>raw_verify</span>; + + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_set_verify</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>mode</span>.<span class='ident'>bits</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, <span class='prelude-val'>Some</span>(<span class='ident'>f</span>)); + } + } + + <span class='doccomment'>/// Configures the certificate verification method for new connections also</span> + <span class='doccomment'>/// carrying supplied data.</span> + <span class='comment'>// Note: no option because there is no point to set data without providing</span> + <span class='comment'>// a function handling it</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_verify_with_data</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>mode</span>: <span class='ident'>SslVerifyMode</span>, + <span class='ident'>verify</span>: <span class='ident'>VerifyCallbackData</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span>, + <span class='ident'>data</span>: <span class='ident'>T</span>) + <span class='kw'>where</span> <span class='ident'>T</span>: <span class='ident'>Any</span> <span class='op'>+</span> <span class='lifetime'>'static</span> { + <span class='kw'>let</span> <span class='ident'>data</span> <span class='op'>=</span> <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>data</span>); + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_set_ex_data</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>VERIFY_IDX</span>, + <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='prelude-val'>Some</span>(<span class='ident'>verify</span>))); + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_set_ex_data</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>get_verify_data_idx</span>::<span class='op'><</span><span class='ident'>T</span><span class='op'>></span>(), + <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='ident'>data</span>)); + <span class='kw'>let</span> <span class='ident'>f</span>: <span class='kw'>extern</span> <span class='kw'>fn</span>(<span class='ident'>c_int</span>, <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>X509_STORE_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span> <span class='op'>=</span> + <span class='ident'>raw_verify_with_data</span>::<span class='op'><</span><span class='ident'>T</span><span class='op'>></span>; + + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_set_verify</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>mode</span>.<span class='ident'>bits</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, <span class='prelude-val'>Some</span>(<span class='ident'>f</span>)); + } + } + + <span class='doccomment'>/// Sets verification depth</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_verify_depth</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>depth</span>: <span class='ident'>u32</span>) { + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_set_verify_depth</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>depth</span> <span class='kw'>as</span> <span class='ident'>c_int</span>); + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_read_ahead</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>m</span>: <span class='ident'>u32</span>) { + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_set_read_ahead</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>m</span> <span class='kw'>as</span> <span class='ident'>c_long</span>); + } + } + + <span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>non_snake_case</span>)]</span> + <span class='doccomment'>/// Specifies the file that contains trusted CA certificates.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_CA_file</span><span class='op'><</span><span class='ident'>P</span>: <span class='ident'>AsRef</span><span class='op'><</span><span class='ident'>Path</span><span class='op'>>></span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>file</span>: <span class='ident'>P</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(),<span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>file</span> <span class='op'>=</span> <span class='ident'>CString</span>::<span class='ident'>new</span>(<span class='ident'>file</span>.<span class='ident'>as_ref</span>().<span class='ident'>as_os_str</span>().<span class='ident'>to_str</span>().<span class='ident'>expect</span>(<span class='string'>"invalid utf8"</span>)).<span class='ident'>unwrap</span>(); + <span class='ident'>wrap_ssl_result</span>( + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_load_verify_locations</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>file</span>.<span class='ident'>as_ptr</span>(), <span class='ident'>ptr</span>::<span class='ident'>null</span>()) + }) + } + + <span class='doccomment'>/// Specifies the file that contains certificate</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_certificate_file</span><span class='op'><</span><span class='ident'>P</span>: <span class='ident'>AsRef</span><span class='op'><</span><span class='ident'>Path</span><span class='op'>>></span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>file</span>: <span class='ident'>P</span>, <span class='ident'>file_type</span>: <span class='ident'>X509FileType</span>) + <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(),<span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>file</span> <span class='op'>=</span> <span class='ident'>CString</span>::<span class='ident'>new</span>(<span class='ident'>file</span>.<span class='ident'>as_ref</span>().<span class='ident'>as_os_str</span>().<span class='ident'>to_str</span>().<span class='ident'>expect</span>(<span class='string'>"invalid utf8"</span>)).<span class='ident'>unwrap</span>(); + <span class='ident'>wrap_ssl_result</span>( + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_use_certificate_file</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>file</span>.<span class='ident'>as_ptr</span>(), <span class='ident'>file_type</span> <span class='kw'>as</span> <span class='ident'>c_int</span>) + }) + } + + <span class='doccomment'>/// Specifies the certificate</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_certificate</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>cert</span>: <span class='kw-2'>&</span><span class='ident'>X509</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(),<span class='ident'>SslError</span><span class='op'>></span> { + <span class='ident'>wrap_ssl_result</span>( + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_use_certificate</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>cert</span>.<span class='ident'>get_handle</span>()) + }) + } + + <span class='doccomment'>/// Adds a certificate to the certificate chain presented together with the</span> + <span class='doccomment'>/// certificate specified using set_certificate()</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>add_extra_chain_cert</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>cert</span>: <span class='kw-2'>&</span><span class='ident'>X509</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(),<span class='ident'>SslError</span><span class='op'>></span> { + <span class='ident'>wrap_ssl_result</span>( + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_add_extra_chain_cert</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>cert</span>.<span class='ident'>get_handle</span>()) <span class='kw'>as</span> <span class='ident'>c_int</span> + }) + } + + <span class='doccomment'>/// Specifies the file that contains private key</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_private_key_file</span><span class='op'><</span><span class='ident'>P</span>: <span class='ident'>AsRef</span><span class='op'><</span><span class='ident'>Path</span><span class='op'>>></span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>file</span>: <span class='ident'>P</span>, + <span class='ident'>file_type</span>: <span class='ident'>X509FileType</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(),<span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>file</span> <span class='op'>=</span> <span class='ident'>CString</span>::<span class='ident'>new</span>(<span class='ident'>file</span>.<span class='ident'>as_ref</span>().<span class='ident'>as_os_str</span>().<span class='ident'>to_str</span>().<span class='ident'>expect</span>(<span class='string'>"invalid utf8"</span>)).<span class='ident'>unwrap</span>(); + <span class='ident'>wrap_ssl_result</span>( + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_use_PrivateKey_file</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>file</span>.<span class='ident'>as_ptr</span>(), <span class='ident'>file_type</span> <span class='kw'>as</span> <span class='ident'>c_int</span>) + }) + } + + <span class='doccomment'>/// Specifies the private key</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_private_key</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>key</span>: <span class='kw-2'>&</span><span class='ident'>PKey</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(),<span class='ident'>SslError</span><span class='op'>></span> { + <span class='ident'>wrap_ssl_result</span>( + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_use_PrivateKey</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>key</span>.<span class='ident'>get_handle</span>()) + }) + } + + <span class='doccomment'>/// Check consistency of private key and certificate</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>check_private_key</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(),<span class='ident'>SslError</span><span class='op'>></span> { + <span class='ident'>wrap_ssl_result</span>( + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_check_private_key</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>) + }) + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_cipher_list</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>cipher_list</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(),<span class='ident'>SslError</span><span class='op'>></span> { + <span class='ident'>wrap_ssl_result</span>( + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>cipher_list</span> <span class='op'>=</span> <span class='ident'>CString</span>::<span class='ident'>new</span>(<span class='ident'>cipher_list</span>.<span class='ident'>as_bytes</span>()).<span class='ident'>unwrap</span>(); + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_set_cipher_list</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>cipher_list</span>.<span class='ident'>as_ptr</span>()) + }) + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_options</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>option</span>: <span class='ident'>SslContextOptions</span>) <span class='op'>-></span> <span class='ident'>SslContextOptions</span> { + <span class='kw'>let</span> <span class='ident'>raw_bits</span> <span class='op'>=</span> <span class='ident'>option</span>.<span class='ident'>bits</span>(); + <span class='kw'>let</span> <span class='ident'>ret</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_set_options</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>raw_bits</span>) + }; + <span class='ident'>SslContextOptions</span>::<span class='ident'>from_bits</span>(<span class='ident'>ret</span>).<span class='ident'>unwrap</span>() + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_options</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>SslContextOptions</span> { + <span class='kw'>let</span> <span class='ident'>ret</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_get_options</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>) + }; + <span class='ident'>SslContextOptions</span>::<span class='ident'>from_bits</span>(<span class='ident'>ret</span>).<span class='ident'>unwrap</span>() + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>clear_options</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>option</span>: <span class='ident'>SslContextOptions</span>) <span class='op'>-></span> <span class='ident'>SslContextOptions</span> { + <span class='kw'>let</span> <span class='ident'>raw_bits</span> <span class='op'>=</span> <span class='ident'>option</span>.<span class='ident'>bits</span>(); + <span class='kw'>let</span> <span class='ident'>ret</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_clear_options</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>raw_bits</span>) + }; + <span class='ident'>SslContextOptions</span>::<span class='ident'>from_bits</span>(<span class='ident'>ret</span>).<span class='ident'>unwrap</span>() + } + + <span class='doccomment'>/// Set the protocols to be used during Next Protocol Negotiation (the protocols</span> + <span class='doccomment'>/// supported by the application).</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This method needs the `npn` feature.</span> + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"npn"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_npn_protocols</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>protocols</span>: <span class='kw-2'>&</span>[<span class='kw-2'>&</span>[<span class='ident'>u8</span>]]) { + <span class='comment'>// Firstly, convert the list of protocols to a byte-array that can be passed to OpenSSL</span> + <span class='comment'>// APIs -- a list of length-prefixed strings.</span> + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>npn_protocols</span> <span class='op'>=</span> <span class='ident'>Vec</span>::<span class='ident'>new</span>(); + <span class='kw'>for</span> <span class='ident'>protocol</span> <span class='kw'>in</span> <span class='ident'>protocols</span> { + <span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='ident'>protocol</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>u8</span>; + <span class='ident'>npn_protocols</span>.<span class='ident'>push</span>(<span class='ident'>len</span>); + <span class='comment'>// If the length is greater than the max `u8`, this truncates the protocol name.</span> + <span class='ident'>npn_protocols</span>.<span class='ident'>extend</span>(<span class='ident'>protocol</span>[..<span class='ident'>len</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>to_vec</span>()); + } + <span class='kw'>let</span> <span class='ident'>protocols</span>: <span class='ident'>Box</span><span class='op'><</span><span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>>></span> <span class='op'>=</span> <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>npn_protocols</span>); + + <span class='kw'>unsafe</span> { + <span class='comment'>// Attach the protocol list to the OpenSSL context structure,</span> + <span class='comment'>// so that we can refer to it within the callback.</span> + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_set_ex_data</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>get_npn_protos_idx</span>(), + <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='ident'>protocols</span>)); + <span class='comment'>// Now register the callback that performs the default protocol</span> + <span class='comment'>// matching based on the client-supported list of protocols that</span> + <span class='comment'>// has been saved.</span> + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_set_next_proto_select_cb</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>raw_next_proto_select_cb</span>, <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>()); + <span class='comment'>// Also register the callback to advertise these protocols, if a server socket is</span> + <span class='comment'>// created with the context.</span> + <span class='ident'>ffi</span>::<span class='ident'>SSL_CTX_set_next_protos_advertised_cb</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>, <span class='ident'>raw_next_protos_advertise_cb</span>, <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>()); + } + } +} + +<span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>dead_code</span>)]</span> +<span class='kw'>struct</span> <span class='ident'>MemBioRef</span><span class='op'><</span><span class='lifetime'>'ssl</span><span class='op'>></span> { + <span class='ident'>ssl</span>: <span class='kw-2'>&</span><span class='lifetime'>'ssl</span> <span class='ident'>Ssl</span>, + <span class='ident'>bio</span>: <span class='ident'>MemBio</span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'ssl</span><span class='op'>></span> <span class='ident'>Deref</span> <span class='kw'>for</span> <span class='ident'>MemBioRef</span><span class='op'><</span><span class='lifetime'>'ssl</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Target</span> <span class='op'>=</span> <span class='ident'>MemBio</span>; + + <span class='kw'>fn</span> <span class='ident'>deref</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>MemBio</span> { + <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>bio</span> + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'ssl</span><span class='op'>></span> <span class='ident'>DerefMut</span> <span class='kw'>for</span> <span class='ident'>MemBioRef</span><span class='op'><</span><span class='lifetime'>'ssl</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>deref_mut</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>MemBio</span> { + <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>bio</span> + } +} + +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Ssl</span> { + <span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>SSL</span> +} + +<span class='kw'>unsafe</span> <span class='kw'>impl</span> <span class='ident'>Send</span> <span class='kw'>for</span> <span class='ident'>Ssl</span> {} +<span class='kw'>unsafe</span> <span class='kw'>impl</span> <span class='ident'>Sync</span> <span class='kw'>for</span> <span class='ident'>Ssl</span> {} + +<span class='comment'>// TODO: put useful information here</span> +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Debug</span> <span class='kw'>for</span> <span class='ident'>Ssl</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>fmt</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>fmt</span>, <span class='string'>"Ssl"</span>) + } +} + +<span class='kw'>impl</span> <span class='ident'>Drop</span> <span class='kw'>for</span> <span class='ident'>Ssl</span> { + <span class='kw'>fn</span> <span class='ident'>drop</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>SSL_free</span>(<span class='self'>self</span>.<span class='ident'>ssl</span>) } + } +} + +<span class='kw'>impl</span> <span class='ident'>Ssl</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>ctx</span>: <span class='kw-2'>&</span><span class='ident'>SslContext</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Ssl</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>ssl</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>SSL_new</span>(<span class='ident'>ctx</span>.<span class='ident'>ctx</span>) }; + <span class='kw'>if</span> <span class='ident'>ssl</span> <span class='op'>==</span> <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>() { + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='ident'>SslError</span>::<span class='ident'>get</span>()); + } + <span class='kw'>let</span> <span class='ident'>ssl</span> <span class='op'>=</span> <span class='ident'>Ssl</span> { <span class='ident'>ssl</span>: <span class='ident'>ssl</span> }; + + <span class='kw'>let</span> <span class='ident'>rbio</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>MemBio</span>::<span class='ident'>new</span>()); + <span class='kw'>let</span> <span class='ident'>wbio</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>MemBio</span>::<span class='ident'>new</span>()); + + <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>SSL_set_bio</span>(<span class='ident'>ssl</span>.<span class='ident'>ssl</span>, <span class='ident'>rbio</span>.<span class='ident'>unwrap</span>(), <span class='ident'>wbio</span>.<span class='ident'>unwrap</span>()) } + <span class='prelude-val'>Ok</span>(<span class='ident'>ssl</span>) + } + + <span class='kw'>fn</span> <span class='ident'>get_rbio</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>MemBioRef</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { <span class='self'>self</span>.<span class='ident'>wrap_bio</span>(<span class='ident'>ffi</span>::<span class='ident'>SSL_get_rbio</span>(<span class='self'>self</span>.<span class='ident'>ssl</span>)) } + } + + <span class='kw'>fn</span> <span class='ident'>get_wbio</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>MemBioRef</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { <span class='self'>self</span>.<span class='ident'>wrap_bio</span>(<span class='ident'>ffi</span>::<span class='ident'>SSL_get_wbio</span>(<span class='self'>self</span>.<span class='ident'>ssl</span>)) } + } + + <span class='kw'>fn</span> <span class='ident'>wrap_bio</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='self'>self</span>, <span class='ident'>bio</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>BIO</span>) <span class='op'>-></span> <span class='ident'>MemBioRef</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>bio</span> <span class='op'>!=</span> <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>()); + <span class='ident'>MemBioRef</span> { + <span class='ident'>ssl</span>: <span class='self'>self</span>, + <span class='ident'>bio</span>: <span class='ident'>MemBio</span>::<span class='ident'>borrowed</span>(<span class='ident'>bio</span>) + } + } + + <span class='kw'>fn</span> <span class='ident'>connect</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>c_int</span> { + <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>SSL_connect</span>(<span class='self'>self</span>.<span class='ident'>ssl</span>) } + } + + <span class='kw'>fn</span> <span class='ident'>accept</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>c_int</span> { + <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>SSL_accept</span>(<span class='self'>self</span>.<span class='ident'>ssl</span>) } + } + + <span class='kw'>fn</span> <span class='ident'>read</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>buf</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> [<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>c_int</span> { + <span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='ident'>cmp</span>::<span class='ident'>min</span>(<span class='ident'>c_int</span>::<span class='ident'>max_value</span>() <span class='kw'>as</span> <span class='ident'>usize</span>, <span class='ident'>buf</span>.<span class='ident'>len</span>()) <span class='kw'>as</span> <span class='ident'>c_int</span>; + <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>SSL_read</span>(<span class='self'>self</span>.<span class='ident'>ssl</span>, <span class='ident'>buf</span>.<span class='ident'>as_ptr</span>() <span class='kw'>as</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>) } + } + + <span class='kw'>fn</span> <span class='ident'>write</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>buf</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>c_int</span> { + <span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='ident'>cmp</span>::<span class='ident'>min</span>(<span class='ident'>c_int</span>::<span class='ident'>max_value</span>() <span class='kw'>as</span> <span class='ident'>usize</span>, <span class='ident'>buf</span>.<span class='ident'>len</span>()) <span class='kw'>as</span> <span class='ident'>c_int</span>; + <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>SSL_write</span>(<span class='self'>self</span>.<span class='ident'>ssl</span>, <span class='ident'>buf</span>.<span class='ident'>as_ptr</span>() <span class='kw'>as</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>) } + } + + <span class='kw'>fn</span> <span class='ident'>get_error</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>ret</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>LibSslError</span> { + <span class='kw'>let</span> <span class='ident'>err</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>SSL_get_error</span>(<span class='self'>self</span>.<span class='ident'>ssl</span>, <span class='ident'>ret</span>) }; + <span class='kw'>match</span> <span class='ident'>LibSslError</span>::<span class='ident'>from_i32</span>(<span class='ident'>err</span> <span class='kw'>as</span> <span class='ident'>i32</span>) { + <span class='prelude-val'>Some</span>(<span class='ident'>err</span>) <span class='op'>=></span> <span class='ident'>err</span>, + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='macro'>unreachable</span><span class='macro'>!</span>() + } + } + + <span class='doccomment'>/// Set the host name to be used with SNI (Server Name Indication).</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_hostname</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>hostname</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(), <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>ret</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { + <span class='comment'>// This is defined as a macro:</span> + <span class='comment'>// #define SSL_set_tlsext_host_name(s,name) \</span> + <span class='comment'>// SSL_ctrl(s,SSL_CTRL_SET_TLSEXT_HOSTNAME,TLSEXT_NAMETYPE_host_name,(char *)name)</span> + + <span class='kw'>let</span> <span class='ident'>hostname</span> <span class='op'>=</span> <span class='ident'>CString</span>::<span class='ident'>new</span>(<span class='ident'>hostname</span>.<span class='ident'>as_bytes</span>()).<span class='ident'>unwrap</span>(); + <span class='ident'>ffi</span>::<span class='ident'>SSL_ctrl</span>(<span class='self'>self</span>.<span class='ident'>ssl</span>, <span class='ident'>ffi</span>::<span class='ident'>SSL_CTRL_SET_TLSEXT_HOSTNAME</span>, + <span class='ident'>ffi</span>::<span class='ident'>TLSEXT_NAMETYPE_host_name</span>, + <span class='ident'>hostname</span>.<span class='ident'>as_ptr</span>() <span class='kw'>as</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>) + }; + + <span class='comment'>// For this case, 0 indicates failure.</span> + <span class='kw'>if</span> <span class='ident'>ret</span> <span class='op'>==</span> <span class='number'>0</span> { + <span class='prelude-val'>Err</span>(<span class='ident'>SslError</span>::<span class='ident'>get</span>()) + } <span class='kw'>else</span> { + <span class='prelude-val'>Ok</span>(()) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_peer_certificate</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>X509</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>ptr</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>SSL_get_peer_certificate</span>(<span class='self'>self</span>.<span class='ident'>ssl</span>); + <span class='kw'>if</span> <span class='ident'>ptr</span>.<span class='ident'>is_null</span>() { + <span class='prelude-val'>None</span> + } <span class='kw'>else</span> { + <span class='prelude-val'>Some</span>(<span class='ident'>X509</span>::<span class='ident'>new</span>(<span class='ident'>ptr</span>, <span class='boolval'>true</span>)) + } + } + } + + <span class='doccomment'>/// Returns the protocol selected by performing Next Protocol Negotiation, if any.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The protocol's name is returned is an opaque sequence of bytes. It is up to the client</span> + <span class='doccomment'>/// to interpret it.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This method needs the `npn` feature.</span> + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"npn"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_selected_npn_protocol</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span>[<span class='ident'>u8</span>]<span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>data</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_uchar</span> <span class='op'>=</span> <span class='ident'>ptr</span>::<span class='ident'>null</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>len</span>: <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='comment'>// Get the negotiated protocol from the SSL instance.</span> + <span class='comment'>// `data` will point at a `c_uchar` array; `len` will contain the length of this array.</span> + <span class='ident'>ffi</span>::<span class='ident'>SSL_get0_next_proto_negotiated</span>(<span class='self'>self</span>.<span class='ident'>ssl</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>data</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>len</span>); + + <span class='kw'>if</span> <span class='ident'>data</span>.<span class='ident'>is_null</span>() { + <span class='prelude-val'>None</span> + } <span class='kw'>else</span> { + <span class='prelude-val'>Some</span>(<span class='ident'>slice</span>::<span class='ident'>from_raw_parts</span>(<span class='ident'>data</span>, <span class='ident'>len</span> <span class='kw'>as</span> <span class='ident'>usize</span>)) + } + } + } + + <span class='doccomment'>/// pending() takes into account only bytes from the TLS/SSL record that is currently being processed (if any).</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>pending</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>SSL_pending</span>(<span class='self'>self</span>.<span class='ident'>ssl</span>) <span class='kw'>as</span> <span class='ident'>usize</span> + } + } +} + +<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>make_LibSslError</span> { + ($(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>variant</span>:<span class='ident'>ident</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>value</span>:<span class='ident'>ident</span>),<span class='op'>+</span>) <span class='op'>=></span> { + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>)]</span> + <span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>i32</span>)]</span> + <span class='kw'>enum</span> <span class='ident'>LibSslError</span> { + $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>variant</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>value</span>),<span class='op'>+</span> + } + + <span class='kw'>impl</span> <span class='ident'>LibSslError</span> { + <span class='kw'>fn</span> <span class='ident'>from_i32</span>(<span class='ident'>val</span>: <span class='ident'>i32</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>LibSslError</span><span class='op'>></span> { + <span class='kw'>match</span> <span class='ident'>val</span> { + $(<span class='ident'>ffi</span>::<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>value</span> <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>LibSslError</span>::<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>variant</span>),)<span class='op'>+</span> + _ <span class='op'>=></span> <span class='prelude-val'>None</span> + } + } + } + } +} + +<span class='macro'>make_LibSslError</span><span class='macro'>!</span> { + <span class='ident'>ErrorNone</span> <span class='op'>=</span> <span class='ident'>SSL_ERROR_NONE</span>, + <span class='ident'>ErrorSsl</span> <span class='op'>=</span> <span class='ident'>SSL_ERROR_SSL</span>, + <span class='ident'>ErrorWantRead</span> <span class='op'>=</span> <span class='ident'>SSL_ERROR_WANT_READ</span>, + <span class='ident'>ErrorWantWrite</span> <span class='op'>=</span> <span class='ident'>SSL_ERROR_WANT_WRITE</span>, + <span class='ident'>ErrorWantX509Lookup</span> <span class='op'>=</span> <span class='ident'>SSL_ERROR_WANT_X509_LOOKUP</span>, + <span class='ident'>ErrorSyscall</span> <span class='op'>=</span> <span class='ident'>SSL_ERROR_SYSCALL</span>, + <span class='ident'>ErrorZeroReturn</span> <span class='op'>=</span> <span class='ident'>SSL_ERROR_ZERO_RETURN</span>, + <span class='ident'>ErrorWantConnect</span> <span class='op'>=</span> <span class='ident'>SSL_ERROR_WANT_CONNECT</span>, + <span class='ident'>ErrorWantAccept</span> <span class='op'>=</span> <span class='ident'>SSL_ERROR_WANT_ACCEPT</span> +} + +<span class='doccomment'>/// A stream wrapper which handles SSL encryption for an underlying stream.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>SslStream</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span> { + <span class='ident'>stream</span>: <span class='ident'>S</span>, + <span class='ident'>ssl</span>: <span class='ident'>Arc</span><span class='op'><</span><span class='ident'>Ssl</span><span class='op'>></span>, + <span class='ident'>buf</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> +} + +<span class='kw'>impl</span> <span class='ident'>SslStream</span><span class='op'><</span><span class='ident'>net</span>::<span class='ident'>TcpStream</span><span class='op'>></span> { + <span class='doccomment'>/// Create a new independently owned handle to the underlying socket.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>try_clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>SslStream</span><span class='op'><</span><span class='ident'>net</span>::<span class='ident'>TcpStream</span><span class='op'>>></span> { + <span class='prelude-val'>Ok</span>(<span class='ident'>SslStream</span> { + <span class='ident'>stream</span>: <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>stream</span>.<span class='ident'>try_clone</span>()), + <span class='ident'>ssl</span>: <span class='self'>self</span>.<span class='ident'>ssl</span>.<span class='ident'>clone</span>(), + <span class='ident'>buf</span>: <span class='self'>self</span>.<span class='ident'>buf</span>.<span class='ident'>clone</span>(), + }) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span> <span class='ident'>fmt</span>::<span class='ident'>Debug</span> <span class='kw'>for</span> <span class='ident'>SslStream</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span> <span class='kw'>where</span> <span class='ident'>S</span>: <span class='ident'>fmt</span>::<span class='ident'>Debug</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>fmt</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>fmt</span>, <span class='string'>"SslStream {{ stream: {:?}, ssl: {:?} }}"</span>, <span class='self'>self</span>.<span class='ident'>stream</span>, <span class='self'>self</span>.<span class='ident'>ssl</span>) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>S</span>: <span class='ident'>Read</span><span class='op'>+</span><span class='ident'>Write</span><span class='op'>></span> <span class='ident'>SslStream</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>new_base</span>(<span class='ident'>ssl</span>:<span class='ident'>Ssl</span>, <span class='ident'>stream</span>: <span class='ident'>S</span>) <span class='op'>-></span> <span class='ident'>SslStream</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span> { + <span class='ident'>SslStream</span> { + <span class='ident'>stream</span>: <span class='ident'>stream</span>, + <span class='ident'>ssl</span>: <span class='ident'>Arc</span>::<span class='ident'>new</span>(<span class='ident'>ssl</span>), + <span class='comment'>// Maximum TLS record size is 16k</span> + <span class='comment'>// We're just using this as a buffer, so there's no reason to pay</span> + <span class='comment'>// to memset it</span> + <span class='ident'>buf</span>: { + <span class='kw'>const</span> <span class='ident'>CAP</span>: <span class='ident'>usize</span> <span class='op'>=</span> <span class='number'>16</span> <span class='op'>*</span> <span class='number'>1024</span>; + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>v</span> <span class='op'>=</span> <span class='ident'>Vec</span>::<span class='ident'>with_capacity</span>(<span class='ident'>CAP</span>); + <span class='kw'>unsafe</span> { <span class='ident'>v</span>.<span class='ident'>set_len</span>(<span class='ident'>CAP</span>); } + <span class='ident'>v</span> + } + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new_server_from</span>(<span class='ident'>ssl</span>: <span class='ident'>Ssl</span>, <span class='ident'>stream</span>: <span class='ident'>S</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>SslStream</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>ssl</span> <span class='op'>=</span> <span class='ident'>SslStream</span>::<span class='ident'>new_base</span>(<span class='ident'>ssl</span>, <span class='ident'>stream</span>); + <span class='ident'>ssl</span>.<span class='ident'>in_retry_wrapper</span>(<span class='op'>|</span><span class='ident'>ssl</span><span class='op'>|</span> { <span class='ident'>ssl</span>.<span class='ident'>accept</span>() }).<span class='ident'>and</span>(<span class='prelude-val'>Ok</span>(<span class='ident'>ssl</span>)) + } + + <span class='doccomment'>/// Attempts to create a new SSL stream from a given `Ssl` instance.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new_from</span>(<span class='ident'>ssl</span>: <span class='ident'>Ssl</span>, <span class='ident'>stream</span>: <span class='ident'>S</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>SslStream</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>ssl</span> <span class='op'>=</span> <span class='ident'>SslStream</span>::<span class='ident'>new_base</span>(<span class='ident'>ssl</span>, <span class='ident'>stream</span>); + <span class='ident'>ssl</span>.<span class='ident'>in_retry_wrapper</span>(<span class='op'>|</span><span class='ident'>ssl</span><span class='op'>|</span> { <span class='ident'>ssl</span>.<span class='ident'>connect</span>() }).<span class='ident'>and</span>(<span class='prelude-val'>Ok</span>(<span class='ident'>ssl</span>)) + } + + <span class='doccomment'>/// Creates a new SSL stream</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>ctx</span>: <span class='kw-2'>&</span><span class='ident'>SslContext</span>, <span class='ident'>stream</span>: <span class='ident'>S</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>SslStream</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>ssl</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>Ssl</span>::<span class='ident'>new</span>(<span class='ident'>ctx</span>)); + <span class='ident'>SslStream</span>::<span class='ident'>new_from</span>(<span class='ident'>ssl</span>, <span class='ident'>stream</span>) + } + + <span class='doccomment'>/// Creates a new SSL server stream</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new_server</span>(<span class='ident'>ctx</span>: <span class='kw-2'>&</span><span class='ident'>SslContext</span>, <span class='ident'>stream</span>: <span class='ident'>S</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>SslStream</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>ssl</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>Ssl</span>::<span class='ident'>new</span>(<span class='ident'>ctx</span>)); + <span class='ident'>SslStream</span>::<span class='ident'>new_server_from</span>(<span class='ident'>ssl</span>, <span class='ident'>stream</span>) + } + + <span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_inner</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>S</span> { + <span class='self'>self</span>.<span class='ident'>get_mut</span>() + } + + <span class='doccomment'>/// Returns a reference to the underlying stream.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_ref</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>S</span> { + <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>stream</span> + } + + <span class='doccomment'>/// Return the certificate of the peer</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_peer_certificate</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>X509</span><span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>ssl</span>.<span class='ident'>get_peer_certificate</span>() + } + + <span class='doccomment'>/// Returns a mutable reference to the underlying stream.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ## Warning</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// It is inadvisable to read from or write to the underlying stream as it</span> + <span class='doccomment'>/// will most likely desynchronize the SSL session.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_mut</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>S</span> { + <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>stream</span> + } + + <span class='kw'>fn</span> <span class='ident'>in_retry_wrapper</span><span class='op'><</span><span class='ident'>F</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='kw-2'>mut</span> <span class='ident'>blk</span>: <span class='ident'>F</span>) + <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>c_int</span>, <span class='ident'>SslError</span><span class='op'>></span> <span class='kw'>where</span> <span class='ident'>F</span>: <span class='ident'>FnMut</span>(<span class='kw-2'>&</span><span class='ident'>Ssl</span>) <span class='op'>-></span> <span class='ident'>c_int</span> { + <span class='kw'>loop</span> { + <span class='kw'>let</span> <span class='ident'>ret</span> <span class='op'>=</span> <span class='ident'>blk</span>(<span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>ssl</span>); + <span class='kw'>if</span> <span class='ident'>ret</span> <span class='op'>></span> <span class='number'>0</span> { + <span class='kw'>return</span> <span class='prelude-val'>Ok</span>(<span class='ident'>ret</span>); + } + + <span class='kw'>let</span> <span class='ident'>e</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>ssl</span>.<span class='ident'>get_error</span>(<span class='ident'>ret</span>); + <span class='kw'>match</span> <span class='ident'>e</span> { + <span class='ident'>LibSslError</span>::<span class='ident'>ErrorWantRead</span> <span class='op'>=></span> { + <span class='macro'>try_ssl_stream</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>flush</span>()); + <span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='macro'>try_ssl_stream</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>stream</span>.<span class='ident'>read</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>buf</span>[..])); + <span class='kw'>if</span> <span class='ident'>len</span> <span class='op'>==</span> <span class='number'>0</span> { + <span class='self'>self</span>.<span class='ident'>ssl</span>.<span class='ident'>get_rbio</span>().<span class='ident'>set_eof</span>(<span class='boolval'>true</span>); + } <span class='kw'>else</span> { + <span class='macro'>try_ssl_stream</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>ssl</span>.<span class='ident'>get_rbio</span>().<span class='ident'>write_all</span>(<span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>buf</span>[..<span class='ident'>len</span>])); + } + } + <span class='ident'>LibSslError</span>::<span class='ident'>ErrorWantWrite</span> <span class='op'>=></span> { <span class='macro'>try_ssl_stream</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>flush</span>()) } + <span class='ident'>LibSslError</span>::<span class='ident'>ErrorZeroReturn</span> <span class='op'>=></span> <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='ident'>SslSessionClosed</span>), + <span class='ident'>LibSslError</span>::<span class='ident'>ErrorSsl</span> <span class='op'>=></span> <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='ident'>SslError</span>::<span class='ident'>get</span>()), + <span class='ident'>LibSslError</span>::<span class='ident'>ErrorSyscall</span> <span class='kw'>if</span> <span class='ident'>ret</span> <span class='op'>==</span> <span class='number'>0</span> <span class='op'>=></span> <span class='kw'>return</span> <span class='prelude-val'>Ok</span>(<span class='number'>0</span>), + <span class='ident'>err</span> <span class='op'>=></span> <span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>"unexpected error {:?} with ret {}"</span>, <span class='ident'>err</span>, <span class='ident'>ret</span>), + } + } + } + + <span class='kw'>fn</span> <span class='ident'>write_through</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='ident'>io</span>::<span class='ident'>copy</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='self'>self</span>.<span class='ident'>ssl</span>.<span class='ident'>get_wbio</span>(), <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>stream</span>).<span class='ident'>map</span>(<span class='op'>|</span>_<span class='op'>|</span> ()) + } + + <span class='doccomment'>/// Get the compression currently in use. The result will be</span> + <span class='doccomment'>/// either None, indicating no compression is in use, or a string</span> + <span class='doccomment'>/// with the compression name.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_compression</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>ptr</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>SSL_get_current_compression</span>(<span class='self'>self</span>.<span class='ident'>ssl</span>.<span class='ident'>ssl</span>) }; + <span class='kw'>if</span> <span class='ident'>ptr</span> <span class='op'>==</span> <span class='ident'>ptr</span>::<span class='ident'>null</span>() { + <span class='kw'>return</span> <span class='prelude-val'>None</span>; + } + + <span class='kw'>let</span> <span class='ident'>meth</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>SSL_COMP_get_name</span>(<span class='ident'>ptr</span>) }; + <span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { + <span class='ident'>String</span>::<span class='ident'>from_utf8</span>(<span class='ident'>CStr</span>::<span class='ident'>from_ptr</span>(<span class='ident'>meth</span>).<span class='ident'>to_bytes</span>().<span class='ident'>to_vec</span>()).<span class='ident'>unwrap</span>() + }; + + <span class='prelude-val'>Some</span>(<span class='ident'>s</span>) + } + + <span class='doccomment'>/// Returns the protocol selected by performing Next Protocol Negotiation, if any.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The protocol's name is returned is an opaque sequence of bytes. It is up to the client</span> + <span class='doccomment'>/// to interpret it.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This method needs the `npn` feature.</span> + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"npn"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_selected_npn_protocol</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span>[<span class='ident'>u8</span>]<span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>ssl</span>.<span class='ident'>get_selected_npn_protocol</span>() + } + + <span class='doccomment'>/// pending() takes into account only bytes from the TLS/SSL record that is currently being processed (if any).</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>pending</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='self'>self</span>.<span class='ident'>ssl</span>.<span class='ident'>pending</span>() + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>S</span>: <span class='ident'>Read</span><span class='op'>+</span><span class='ident'>Write</span><span class='op'>></span> <span class='ident'>Read</span> <span class='kw'>for</span> <span class='ident'>SslStream</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>read</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>buf</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> [<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span> { + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>in_retry_wrapper</span>(<span class='op'>|</span><span class='ident'>ssl</span><span class='op'>|</span> { <span class='ident'>ssl</span>.<span class='ident'>read</span>(<span class='ident'>buf</span>) }) { + <span class='prelude-val'>Ok</span>(<span class='ident'>len</span>) <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='ident'>len</span> <span class='kw'>as</span> <span class='ident'>usize</span>), + <span class='prelude-val'>Err</span>(<span class='ident'>SslSessionClosed</span>) <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='number'>0</span>), + <span class='prelude-val'>Err</span>(<span class='ident'>StreamError</span>(<span class='ident'>e</span>)) <span class='op'>=></span> <span class='prelude-val'>Err</span>(<span class='ident'>e</span>), + <span class='prelude-val'>Err</span>(<span class='ident'>e</span> <span class='kw-2'>@</span> <span class='ident'>OpenSslErrors</span>(_)) <span class='op'>=></span> { + <span class='prelude-val'>Err</span>(<span class='ident'>io</span>::<span class='ident'>Error</span>::<span class='ident'>new</span>(<span class='ident'>io</span>::<span class='ident'>ErrorKind</span>::<span class='ident'>Other</span>, <span class='ident'>e</span>)) + } + } + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>S</span>: <span class='ident'>Read</span><span class='op'>+</span><span class='ident'>Write</span><span class='op'>></span> <span class='ident'>Write</span> <span class='kw'>for</span> <span class='ident'>SslStream</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>write</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>buf</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>count</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>in_retry_wrapper</span>(<span class='op'>|</span><span class='ident'>ssl</span><span class='op'>|</span> <span class='ident'>ssl</span>.<span class='ident'>write</span>(<span class='ident'>buf</span>)) { + <span class='prelude-val'>Ok</span>(<span class='ident'>len</span>) <span class='op'>=></span> <span class='ident'>len</span> <span class='kw'>as</span> <span class='ident'>usize</span>, + <span class='prelude-val'>Err</span>(<span class='ident'>SslSessionClosed</span>) <span class='op'>=></span> <span class='number'>0</span>, + <span class='prelude-val'>Err</span>(<span class='ident'>StreamError</span>(<span class='ident'>e</span>)) <span class='op'>=></span> <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='ident'>e</span>), + <span class='prelude-val'>Err</span>(<span class='ident'>e</span> <span class='kw-2'>@</span> <span class='ident'>OpenSslErrors</span>(_)) <span class='op'>=></span> <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='ident'>io</span>::<span class='ident'>Error</span>::<span class='ident'>new</span>(<span class='ident'>io</span>::<span class='ident'>ErrorKind</span>::<span class='ident'>Other</span>, <span class='ident'>e</span>)), + }; + <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>write_through</span>()); + <span class='prelude-val'>Ok</span>(<span class='ident'>count</span>) + } + + <span class='kw'>fn</span> <span class='ident'>flush</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>write_through</span>()); + <span class='self'>self</span>.<span class='ident'>stream</span>.<span class='ident'>flush</span>() + } +} + +<span class='doccomment'>/// A utility type to help in cases where the use of SSL is decided at runtime.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>MaybeSslStream</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span> <span class='kw'>where</span> <span class='ident'>S</span>: <span class='ident'>Read</span><span class='op'>+</span><span class='ident'>Write</span> { + <span class='doccomment'>/// A connection using SSL</span> + <span class='ident'>Ssl</span>(<span class='ident'>SslStream</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span>), + <span class='doccomment'>/// A connection not using SSL</span> + <span class='ident'>Normal</span>(<span class='ident'>S</span>), +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span> <span class='ident'>Read</span> <span class='kw'>for</span> <span class='ident'>MaybeSslStream</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span> <span class='kw'>where</span> <span class='ident'>S</span>: <span class='ident'>Read</span><span class='op'>+</span><span class='ident'>Write</span> { + <span class='kw'>fn</span> <span class='ident'>read</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>buf</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> [<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>MaybeSslStream</span>::<span class='ident'>Ssl</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>s</span>.<span class='ident'>read</span>(<span class='ident'>buf</span>), + <span class='ident'>MaybeSslStream</span>::<span class='ident'>Normal</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>s</span>.<span class='ident'>read</span>(<span class='ident'>buf</span>), + } + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span> <span class='ident'>Write</span> <span class='kw'>for</span> <span class='ident'>MaybeSslStream</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span> <span class='kw'>where</span> <span class='ident'>S</span>: <span class='ident'>Read</span><span class='op'>+</span><span class='ident'>Write</span> { + <span class='kw'>fn</span> <span class='ident'>write</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>buf</span>: <span class='kw-2'>&</span>[<span class='ident'>u8</span>]) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>MaybeSslStream</span>::<span class='ident'>Ssl</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>s</span>.<span class='ident'>write</span>(<span class='ident'>buf</span>), + <span class='ident'>MaybeSslStream</span>::<span class='ident'>Normal</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>s</span>.<span class='ident'>write</span>(<span class='ident'>buf</span>), + } + } + + <span class='kw'>fn</span> <span class='ident'>flush</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>MaybeSslStream</span>::<span class='ident'>Ssl</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>s</span>.<span class='ident'>flush</span>(), + <span class='ident'>MaybeSslStream</span>::<span class='ident'>Normal</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>s</span>.<span class='ident'>flush</span>(), + } + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span> <span class='ident'>MaybeSslStream</span><span class='op'><</span><span class='ident'>S</span><span class='op'>></span> <span class='kw'>where</span> <span class='ident'>S</span>: <span class='ident'>Read</span><span class='op'>+</span><span class='ident'>Write</span> { + <span class='doccomment'>/// Returns a reference to the underlying stream.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_ref</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>S</span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>MaybeSslStream</span>::<span class='ident'>Ssl</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>s</span>.<span class='ident'>get_ref</span>(), + <span class='ident'>MaybeSslStream</span>::<span class='ident'>Normal</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>s</span>, + } + } + + <span class='doccomment'>/// Returns a mutable reference to the underlying stream.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ## Warning</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// It is inadvisable to read from or write to the underlying stream.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_mut</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>S</span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>MaybeSslStream</span>::<span class='ident'>Ssl</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>s</span>.<span class='ident'>get_mut</span>(), + <span class='ident'>MaybeSslStream</span>::<span class='ident'>Normal</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>s</span>) <span class='op'>=></span> <span class='ident'>s</span>, + } + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl"; + window.playgroundUrl = ""; + </script> + <script src="../../../jquery.js"></script> + <script src="../../../main.js"></script> + + <script async src="../../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl/x509/mod.rs.html b/src/openssl/x509/mod.rs.html new file mode 100644 index 0000000..ea45241 --- /dev/null +++ b/src/openssl/x509/mod.rs.html @@ -0,0 +1,1461 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-0.6.3/src/x509/mod.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>mod.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +<span id="313">313</span> +<span id="314">314</span> +<span id="315">315</span> +<span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +<span id="326">326</span> +<span id="327">327</span> +<span id="328">328</span> +<span id="329">329</span> +<span id="330">330</span> +<span id="331">331</span> +<span id="332">332</span> +<span id="333">333</span> +<span id="334">334</span> +<span id="335">335</span> +<span id="336">336</span> +<span id="337">337</span> +<span id="338">338</span> +<span id="339">339</span> +<span id="340">340</span> +<span id="341">341</span> +<span id="342">342</span> +<span id="343">343</span> +<span id="344">344</span> +<span id="345">345</span> +<span id="346">346</span> +<span id="347">347</span> +<span id="348">348</span> +<span id="349">349</span> +<span id="350">350</span> +<span id="351">351</span> +<span id="352">352</span> +<span id="353">353</span> +<span id="354">354</span> +<span id="355">355</span> +<span id="356">356</span> +<span id="357">357</span> +<span id="358">358</span> +<span id="359">359</span> +<span id="360">360</span> +<span id="361">361</span> +<span id="362">362</span> +<span id="363">363</span> +<span id="364">364</span> +<span id="365">365</span> +<span id="366">366</span> +<span id="367">367</span> +<span id="368">368</span> +<span id="369">369</span> +<span id="370">370</span> +<span id="371">371</span> +<span id="372">372</span> +<span id="373">373</span> +<span id="374">374</span> +<span id="375">375</span> +<span id="376">376</span> +<span id="377">377</span> +<span id="378">378</span> +<span id="379">379</span> +<span id="380">380</span> +<span id="381">381</span> +<span id="382">382</span> +<span id="383">383</span> +<span id="384">384</span> +<span id="385">385</span> +<span id="386">386</span> +<span id="387">387</span> +<span id="388">388</span> +<span id="389">389</span> +<span id="390">390</span> +<span id="391">391</span> +<span id="392">392</span> +<span id="393">393</span> +<span id="394">394</span> +<span id="395">395</span> +<span id="396">396</span> +<span id="397">397</span> +<span id="398">398</span> +<span id="399">399</span> +<span id="400">400</span> +<span id="401">401</span> +<span id="402">402</span> +<span id="403">403</span> +<span id="404">404</span> +<span id="405">405</span> +<span id="406">406</span> +<span id="407">407</span> +<span id="408">408</span> +<span id="409">409</span> +<span id="410">410</span> +<span id="411">411</span> +<span id="412">412</span> +<span id="413">413</span> +<span id="414">414</span> +<span id="415">415</span> +<span id="416">416</span> +<span id="417">417</span> +<span id="418">418</span> +<span id="419">419</span> +<span id="420">420</span> +<span id="421">421</span> +<span id="422">422</span> +<span id="423">423</span> +<span id="424">424</span> +<span id="425">425</span> +<span id="426">426</span> +<span id="427">427</span> +<span id="428">428</span> +<span id="429">429</span> +<span id="430">430</span> +<span id="431">431</span> +<span id="432">432</span> +<span id="433">433</span> +<span id="434">434</span> +<span id="435">435</span> +<span id="436">436</span> +<span id="437">437</span> +<span id="438">438</span> +<span id="439">439</span> +<span id="440">440</span> +<span id="441">441</span> +<span id="442">442</span> +<span id="443">443</span> +<span id="444">444</span> +<span id="445">445</span> +<span id="446">446</span> +<span id="447">447</span> +<span id="448">448</span> +<span id="449">449</span> +<span id="450">450</span> +<span id="451">451</span> +<span id="452">452</span> +<span id="453">453</span> +<span id="454">454</span> +<span id="455">455</span> +<span id="456">456</span> +<span id="457">457</span> +<span id="458">458</span> +<span id="459">459</span> +<span id="460">460</span> +<span id="461">461</span> +<span id="462">462</span> +<span id="463">463</span> +<span id="464">464</span> +<span id="465">465</span> +<span id="466">466</span> +<span id="467">467</span> +<span id="468">468</span> +<span id="469">469</span> +<span id="470">470</span> +<span id="471">471</span> +<span id="472">472</span> +<span id="473">473</span> +<span id="474">474</span> +<span id="475">475</span> +<span id="476">476</span> +<span id="477">477</span> +<span id="478">478</span> +<span id="479">479</span> +<span id="480">480</span> +<span id="481">481</span> +<span id="482">482</span> +<span id="483">483</span> +<span id="484">484</span> +<span id="485">485</span> +<span id="486">486</span> +<span id="487">487</span> +<span id="488">488</span> +<span id="489">489</span> +<span id="490">490</span> +<span id="491">491</span> +<span id="492">492</span> +<span id="493">493</span> +<span id="494">494</span> +<span id="495">495</span> +<span id="496">496</span> +<span id="497">497</span> +<span id="498">498</span> +<span id="499">499</span> +<span id="500">500</span> +<span id="501">501</span> +<span id="502">502</span> +<span id="503">503</span> +<span id="504">504</span> +<span id="505">505</span> +<span id="506">506</span> +<span id="507">507</span> +<span id="508">508</span> +<span id="509">509</span> +<span id="510">510</span> +<span id="511">511</span> +<span id="512">512</span> +<span id="513">513</span> +<span id="514">514</span> +<span id="515">515</span> +<span id="516">516</span> +<span id="517">517</span> +<span id="518">518</span> +<span id="519">519</span> +<span id="520">520</span> +<span id="521">521</span> +<span id="522">522</span> +<span id="523">523</span> +<span id="524">524</span> +<span id="525">525</span> +<span id="526">526</span> +<span id="527">527</span> +<span id="528">528</span> +<span id="529">529</span> +<span id="530">530</span> +<span id="531">531</span> +<span id="532">532</span> +<span id="533">533</span> +<span id="534">534</span> +<span id="535">535</span> +<span id="536">536</span> +<span id="537">537</span> +<span id="538">538</span> +<span id="539">539</span> +<span id="540">540</span> +<span id="541">541</span> +<span id="542">542</span> +<span id="543">543</span> +<span id="544">544</span> +<span id="545">545</span> +<span id="546">546</span> +<span id="547">547</span> +<span id="548">548</span> +<span id="549">549</span> +<span id="550">550</span> +<span id="551">551</span> +<span id="552">552</span> +<span id="553">553</span> +<span id="554">554</span> +<span id="555">555</span> +<span id="556">556</span> +<span id="557">557</span> +<span id="558">558</span> +<span id="559">559</span> +<span id="560">560</span> +<span id="561">561</span> +<span id="562">562</span> +<span id="563">563</span> +<span id="564">564</span> +<span id="565">565</span> +<span id="566">566</span> +<span id="567">567</span> +<span id="568">568</span> +<span id="569">569</span> +<span id="570">570</span> +<span id="571">571</span> +<span id="572">572</span> +<span id="573">573</span> +<span id="574">574</span> +<span id="575">575</span> +<span id="576">576</span> +<span id="577">577</span> +<span id="578">578</span> +<span id="579">579</span> +<span id="580">580</span> +<span id="581">581</span> +<span id="582">582</span> +<span id="583">583</span> +<span id="584">584</span> +<span id="585">585</span> +<span id="586">586</span> +<span id="587">587</span> +<span id="588">588</span> +<span id="589">589</span> +<span id="590">590</span> +<span id="591">591</span> +<span id="592">592</span> +<span id="593">593</span> +<span id="594">594</span> +<span id="595">595</span> +<span id="596">596</span> +<span id="597">597</span> +<span id="598">598</span> +<span id="599">599</span> +<span id="600">600</span> +<span id="601">601</span> +<span id="602">602</span> +<span id="603">603</span> +<span id="604">604</span> +<span id="605">605</span> +<span id="606">606</span> +<span id="607">607</span> +<span id="608">608</span> +<span id="609">609</span> +<span id="610">610</span> +<span id="611">611</span> +<span id="612">612</span> +<span id="613">613</span> +<span id="614">614</span> +<span id="615">615</span> +<span id="616">616</span> +<span id="617">617</span> +<span id="618">618</span> +<span id="619">619</span> +<span id="620">620</span> +<span id="621">621</span> +<span id="622">622</span> +<span id="623">623</span> +<span id="624">624</span> +<span id="625">625</span> +<span id="626">626</span> +<span id="627">627</span> +<span id="628">628</span> +<span id="629">629</span> +<span id="630">630</span> +<span id="631">631</span> +<span id="632">632</span> +<span id="633">633</span> +<span id="634">634</span> +<span id="635">635</span> +<span id="636">636</span> +<span id="637">637</span> +<span id="638">638</span> +<span id="639">639</span> +<span id="640">640</span> +<span id="641">641</span> +<span id="642">642</span> +<span id="643">643</span> +<span id="644">644</span> +<span id="645">645</span> +<span id="646">646</span> +<span id="647">647</span> +<span id="648">648</span> +<span id="649">649</span> +<span id="650">650</span> +<span id="651">651</span> +<span id="652">652</span> +<span id="653">653</span> +<span id="654">654</span> +<span id="655">655</span> +<span id="656">656</span> +<span id="657">657</span> +<span id="658">658</span> +<span id="659">659</span> +<span id="660">660</span> +<span id="661">661</span> +<span id="662">662</span> +<span id="663">663</span> +<span id="664">664</span> +<span id="665">665</span> +<span id="666">666</span> +<span id="667">667</span> +<span id="668">668</span> +<span id="669">669</span> +<span id="670">670</span> +<span id="671">671</span> +<span id="672">672</span> +<span id="673">673</span> +<span id="674">674</span> +<span id="675">675</span> +<span id="676">676</span> +<span id="677">677</span> +<span id="678">678</span> +<span id="679">679</span> +<span id="680">680</span> +<span id="681">681</span> +<span id="682">682</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>libc</span>::{<span class='ident'>c_char</span>, <span class='ident'>c_int</span>, <span class='ident'>c_long</span>, <span class='ident'>c_ulong</span>, <span class='ident'>c_uint</span>, <span class='ident'>c_void</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>::<span class='ident'>prelude</span>::<span class='op'>*</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>cmp</span>::<span class='ident'>Ordering</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ffi</span>::{<span class='ident'>CString</span>, <span class='ident'>CStr</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>iter</span>::<span class='ident'>repeat</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>mem</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ptr</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ops</span>::<span class='ident'>Deref</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>fmt</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>str</span>; + +<span class='kw'>use</span> <span class='ident'>asn1</span>::{<span class='ident'>Asn1Time</span>}; +<span class='kw'>use</span> <span class='ident'>bio</span>::{<span class='ident'>MemBio</span>}; +<span class='kw'>use</span> <span class='ident'>crypto</span>::<span class='ident'>hash</span>; +<span class='kw'>use</span> <span class='ident'>crypto</span>::<span class='ident'>hash</span>::<span class='ident'>Type</span> <span class='kw'>as</span> <span class='ident'>HashType</span>; +<span class='kw'>use</span> <span class='ident'>crypto</span>::<span class='ident'>pkey</span>::{<span class='ident'>PKey</span>,<span class='ident'>Parts</span>}; +<span class='kw'>use</span> <span class='ident'>crypto</span>::<span class='ident'>rand</span>::<span class='ident'>rand_bytes</span>; +<span class='kw'>use</span> <span class='ident'>ffi</span>; +<span class='kw'>use</span> <span class='ident'>ssl</span>::<span class='ident'>error</span>::{<span class='ident'>SslError</span>, <span class='ident'>StreamError</span>}; +<span class='kw'>use</span> <span class='ident'>nid</span>; + + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>tests</span>; + +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>SslString</span> { + <span class='ident'>s</span> : <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'s</span><span class='op'>></span> <span class='ident'>Drop</span> <span class='kw'>for</span> <span class='ident'>SslString</span> { + <span class='kw'>fn</span> <span class='ident'>drop</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>CRYPTO_free</span>(<span class='self'>self</span>.<span class='ident'>s</span>.<span class='ident'>as_ptr</span>() <span class='kw'>as</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>); } + } +} + +<span class='kw'>impl</span> <span class='ident'>Deref</span> <span class='kw'>for</span> <span class='ident'>SslString</span> { + <span class='kw'>type</span> <span class='ident'>Target</span> <span class='op'>=</span> <span class='ident'>str</span>; + + <span class='kw'>fn</span> <span class='ident'>deref</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>str</span> { + <span class='self'>self</span>.<span class='ident'>s</span> + } +} + +<span class='kw'>impl</span> <span class='ident'>SslString</span> { + <span class='kw'>unsafe</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>SslString</span> { + <span class='ident'>SslString</span> { + <span class='ident'>s</span>: <span class='ident'>str</span>::<span class='ident'>from_utf8</span>(<span class='ident'>CStr</span>::<span class='ident'>from_ptr</span>(<span class='ident'>buf</span>).<span class='ident'>to_bytes</span>()).<span class='ident'>unwrap</span>() + } + } +} + +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Display</span> <span class='kw'>for</span> <span class='ident'>SslString</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='ident'>fmt</span>::<span class='ident'>Display</span>::<span class='ident'>fmt</span>(<span class='self'>self</span>.<span class='ident'>s</span>, <span class='ident'>f</span>) + } +} + +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Debug</span> <span class='kw'>for</span> <span class='ident'>SslString</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='ident'>fmt</span>::<span class='ident'>Debug</span>::<span class='ident'>fmt</span>(<span class='self'>self</span>.<span class='ident'>s</span>, <span class='ident'>f</span>) + } +} + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> +<span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>i32</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>X509FileType</span> { + <span class='ident'>PEM</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>X509_FILETYPE_PEM</span>, + <span class='ident'>ASN1</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>X509_FILETYPE_ASN1</span>, + <span class='ident'>Default</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>X509_FILETYPE_DEFAULT</span> +} + +<span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>missing_copy_implementations</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>X509StoreContext</span> { + <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>X509_STORE_CTX</span> +} + +<span class='kw'>impl</span> <span class='ident'>X509StoreContext</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>X509_STORE_CTX</span>) <span class='op'>-></span> <span class='ident'>X509StoreContext</span> { + <span class='ident'>X509StoreContext</span> { + <span class='ident'>ctx</span>: <span class='ident'>ctx</span> + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_error</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>X509ValidationError</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>err</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>X509_STORE_CTX_get_error</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>) }; + <span class='ident'>X509ValidationError</span>::<span class='ident'>from_raw</span>(<span class='ident'>err</span>) + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_current_cert</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>X509</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span> { + <span class='kw'>let</span> <span class='ident'>ptr</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>X509_STORE_CTX_get_current_cert</span>(<span class='self'>self</span>.<span class='ident'>ctx</span>) }; + + <span class='kw'>if</span> <span class='ident'>ptr</span>.<span class='ident'>is_null</span>() { + <span class='prelude-val'>None</span> + } <span class='kw'>else</span> { + <span class='prelude-val'>Some</span>(<span class='ident'>X509</span> { <span class='ident'>ctx</span>: <span class='prelude-val'>Some</span>(<span class='self'>self</span>), <span class='ident'>handle</span>: <span class='ident'>ptr</span>, <span class='ident'>owned</span>: <span class='boolval'>false</span> }) + } + } +} + +<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> +<span class='kw'>trait</span> <span class='ident'>AsStr</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>as_str</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>str</span>; +} + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Copy</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>KeyUsage</span> { + <span class='ident'>DigitalSignature</span>, + <span class='ident'>NonRepudiation</span>, + <span class='ident'>KeyEncipherment</span>, + <span class='ident'>DataEncipherment</span>, + <span class='ident'>KeyAgreement</span>, + <span class='ident'>KeyCertSign</span>, + <span class='ident'>CRLSign</span>, + <span class='ident'>EncipherOnly</span>, + <span class='ident'>DecipherOnly</span> +} + +<span class='kw'>impl</span> <span class='ident'>AsStr</span><span class='op'><</span><span class='lifetime'>'static</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>KeyUsage</span> { + <span class='kw'>fn</span> <span class='ident'>as_str</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> { + <span class='kw'>match</span> <span class='self'>self</span> { + <span class='kw-2'>&</span><span class='ident'>KeyUsage</span>::<span class='ident'>DigitalSignature</span> <span class='op'>=></span> <span class='string'>"digitalSignature"</span>, + <span class='kw-2'>&</span><span class='ident'>KeyUsage</span>::<span class='ident'>NonRepudiation</span> <span class='op'>=></span> <span class='string'>"nonRepudiation"</span>, + <span class='kw-2'>&</span><span class='ident'>KeyUsage</span>::<span class='ident'>KeyEncipherment</span> <span class='op'>=></span> <span class='string'>"keyEncipherment"</span>, + <span class='kw-2'>&</span><span class='ident'>KeyUsage</span>::<span class='ident'>DataEncipherment</span> <span class='op'>=></span> <span class='string'>"dataEncipherment"</span>, + <span class='kw-2'>&</span><span class='ident'>KeyUsage</span>::<span class='ident'>KeyAgreement</span> <span class='op'>=></span> <span class='string'>"keyAgreement"</span>, + <span class='kw-2'>&</span><span class='ident'>KeyUsage</span>::<span class='ident'>KeyCertSign</span> <span class='op'>=></span> <span class='string'>"keyCertSign"</span>, + <span class='kw-2'>&</span><span class='ident'>KeyUsage</span>::<span class='ident'>CRLSign</span> <span class='op'>=></span> <span class='string'>"cRLSign"</span>, + <span class='kw-2'>&</span><span class='ident'>KeyUsage</span>::<span class='ident'>EncipherOnly</span> <span class='op'>=></span> <span class='string'>"encipherOnly"</span>, + <span class='kw-2'>&</span><span class='ident'>KeyUsage</span>::<span class='ident'>DecipherOnly</span> <span class='op'>=></span> <span class='string'>"decipherOnly"</span> + } + } +} + + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Copy</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>ExtKeyUsage</span> { + <span class='ident'>ServerAuth</span>, + <span class='ident'>ClientAuth</span>, + <span class='ident'>CodeSigning</span>, + <span class='ident'>EmailProtection</span>, + <span class='ident'>TimeStamping</span>, + <span class='ident'>MsCodeInd</span>, + <span class='ident'>MsCodeCom</span>, + <span class='ident'>MsCtlSign</span>, + <span class='ident'>MsSgc</span>, + <span class='ident'>MsEfs</span>, + <span class='ident'>NsSgc</span> +} + +<span class='kw'>impl</span> <span class='ident'>AsStr</span><span class='op'><</span><span class='lifetime'>'static</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>ExtKeyUsage</span> { + <span class='kw'>fn</span> <span class='ident'>as_str</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> { + <span class='kw'>match</span> <span class='self'>self</span> { + <span class='kw-2'>&</span><span class='ident'>ExtKeyUsage</span>::<span class='ident'>ServerAuth</span> <span class='op'>=></span> <span class='string'>"serverAuth"</span>, + <span class='kw-2'>&</span><span class='ident'>ExtKeyUsage</span>::<span class='ident'>ClientAuth</span> <span class='op'>=></span> <span class='string'>"clientAuth"</span>, + <span class='kw-2'>&</span><span class='ident'>ExtKeyUsage</span>::<span class='ident'>CodeSigning</span> <span class='op'>=></span> <span class='string'>"codeSigning"</span>, + <span class='kw-2'>&</span><span class='ident'>ExtKeyUsage</span>::<span class='ident'>EmailProtection</span> <span class='op'>=></span> <span class='string'>"emailProtection"</span>, + <span class='kw-2'>&</span><span class='ident'>ExtKeyUsage</span>::<span class='ident'>TimeStamping</span> <span class='op'>=></span> <span class='string'>"timeStamping"</span>, + <span class='kw-2'>&</span><span class='ident'>ExtKeyUsage</span>::<span class='ident'>MsCodeInd</span> <span class='op'>=></span> <span class='string'>"msCodeInd"</span>, + <span class='kw-2'>&</span><span class='ident'>ExtKeyUsage</span>::<span class='ident'>MsCodeCom</span> <span class='op'>=></span> <span class='string'>"msCodeCom"</span>, + <span class='kw-2'>&</span><span class='ident'>ExtKeyUsage</span>::<span class='ident'>MsCtlSign</span> <span class='op'>=></span> <span class='string'>"msCTLSign"</span>, + <span class='kw-2'>&</span><span class='ident'>ExtKeyUsage</span>::<span class='ident'>MsSgc</span> <span class='op'>=></span> <span class='string'>"msSGC"</span>, + <span class='kw-2'>&</span><span class='ident'>ExtKeyUsage</span>::<span class='ident'>MsEfs</span> <span class='op'>=></span> <span class='string'>"msEFS"</span>, + <span class='kw-2'>&</span><span class='ident'>ExtKeyUsage</span>::<span class='ident'>NsSgc</span> <span class='op'>=></span><span class='string'>"nsSGC"</span> + } + } +} + + +<span class='comment'>// FIXME: a dirty hack as there is no way to</span> +<span class='comment'>// implement ToString for Vec as both are defined</span> +<span class='comment'>// in another crate</span> +<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> +<span class='kw'>trait</span> <span class='ident'>ToStr</span> { + <span class='kw'>fn</span> <span class='ident'>to_str</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>String</span>; +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>T</span>: <span class='ident'>AsStr</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>>></span> <span class='ident'>ToStr</span> <span class='kw'>for</span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>to_str</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='self'>self</span>.<span class='ident'>iter</span>().<span class='ident'>enumerate</span>().<span class='ident'>fold</span>(<span class='ident'>String</span>::<span class='ident'>new</span>(), <span class='op'>|</span><span class='kw-2'>mut</span> <span class='ident'>acc</span>, (<span class='ident'>idx</span>, <span class='ident'>v</span>)<span class='op'>|</span> { + <span class='kw'>if</span> <span class='ident'>idx</span> <span class='op'>></span> <span class='number'>0</span> { <span class='ident'>acc</span>.<span class='ident'>push</span>(<span class='string'>','</span>) }; + <span class='ident'>acc</span>.<span class='ident'>push_str</span>(<span class='ident'>v</span>.<span class='ident'>as_str</span>()); + <span class='ident'>acc</span> + }) + } +} + +<span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>non_snake_case</span>)]</span> +<span class='doccomment'>/// Generator of private key/certificate pairs</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Example</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ```</span> +<span class='doccomment'>/// # #[allow(unstable)]</span> +<span class='doccomment'>/// # fn main() {</span> +<span class='doccomment'>/// use std::fs;</span> +<span class='doccomment'>/// use std::fs::File;</span> +<span class='doccomment'>/// use std::io::prelude::*;</span> +<span class='doccomment'>/// use std::path::Path;</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// use openssl::crypto::hash::Type;</span> +<span class='doccomment'>/// use openssl::x509::{KeyUsage, X509Generator};</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// let gen = X509Generator::new()</span> +<span class='doccomment'>/// .set_bitlength(2048)</span> +<span class='doccomment'>/// .set_valid_period(365*2)</span> +<span class='doccomment'>/// .set_CN("SuperMegaCorp Inc.")</span> +<span class='doccomment'>/// .set_sign_hash(Type::SHA256)</span> +<span class='doccomment'>/// .set_usage(&[KeyUsage::DigitalSignature]);</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// let (cert, pkey) = gen.generate().unwrap();</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// let cert_path = "doc_cert.pem";</span> +<span class='doccomment'>/// let mut file = File::create(cert_path).unwrap();</span> +<span class='doccomment'>/// assert!(cert.write_pem(&mut file).is_ok());</span> +<span class='doccomment'>/// # let _ = fs::remove_file(cert_path);</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// let pkey_path = "doc_key.pem";</span> +<span class='doccomment'>/// let mut file = File::create(pkey_path).unwrap();</span> +<span class='doccomment'>/// assert!(pkey.write_pem(&mut file).is_ok());</span> +<span class='doccomment'>/// # let _ = fs::remove_file(pkey_path);</span> +<span class='doccomment'>/// # }</span> +<span class='doccomment'>/// ```</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>X509Generator</span> { + <span class='ident'>bits</span>: <span class='ident'>u32</span>, + <span class='ident'>days</span>: <span class='ident'>u32</span>, + <span class='ident'>CN</span>: <span class='ident'>String</span>, + <span class='ident'>key_usage</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>KeyUsage</span><span class='op'>></span>, + <span class='ident'>ext_key_usage</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>ExtKeyUsage</span><span class='op'>></span>, + <span class='ident'>hash_type</span>: <span class='ident'>HashType</span>, +} + +<span class='kw'>impl</span> <span class='ident'>X509Generator</span> { + <span class='doccomment'>/// Creates a new generator with the following defaults:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// bit length: 1024</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// validity period: 365 days</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// CN: "rust-openssl"</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// hash: SHA1</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>() <span class='op'>-></span> <span class='ident'>X509Generator</span> { + <span class='ident'>X509Generator</span> { + <span class='ident'>bits</span>: <span class='number'>1024</span>, + <span class='ident'>days</span>: <span class='number'>365</span>, + <span class='ident'>CN</span>: <span class='string'>"rust-openssl"</span>.<span class='ident'>to_string</span>(), + <span class='ident'>key_usage</span>: <span class='ident'>Vec</span>::<span class='ident'>new</span>(), + <span class='ident'>ext_key_usage</span>: <span class='ident'>Vec</span>::<span class='ident'>new</span>(), + <span class='ident'>hash_type</span>: <span class='ident'>HashType</span>::<span class='ident'>SHA1</span> + } + } + + <span class='doccomment'>/// Sets desired bit length</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_bitlength</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>bits</span>: <span class='ident'>u32</span>) <span class='op'>-></span> <span class='ident'>X509Generator</span> { + <span class='self'>self</span>.<span class='ident'>bits</span> <span class='op'>=</span> <span class='ident'>bits</span>; + <span class='self'>self</span> + } + + <span class='doccomment'>/// Sets certificate validity period in days since today</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_valid_period</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>days</span>: <span class='ident'>u32</span>) <span class='op'>-></span> <span class='ident'>X509Generator</span> { + <span class='self'>self</span>.<span class='ident'>days</span> <span class='op'>=</span> <span class='ident'>days</span>; + <span class='self'>self</span> + } + + <span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>non_snake_case</span>)]</span> + <span class='doccomment'>/// Sets Common Name of certificate</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_CN</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>CN</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>X509Generator</span> { + <span class='self'>self</span>.<span class='ident'>CN</span> <span class='op'>=</span> <span class='ident'>CN</span>.<span class='ident'>to_string</span>(); + <span class='self'>self</span> + } + + <span class='doccomment'>/// Sets what for certificate could be used</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_usage</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>purposes</span>: <span class='kw-2'>&</span>[<span class='ident'>KeyUsage</span>]) <span class='op'>-></span> <span class='ident'>X509Generator</span> { + <span class='self'>self</span>.<span class='ident'>key_usage</span> <span class='op'>=</span> <span class='ident'>purposes</span>.<span class='ident'>to_vec</span>(); + <span class='self'>self</span> + } + + <span class='doccomment'>/// Sets allowed extended usage of certificate</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_ext_usage</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>purposes</span>: <span class='kw-2'>&</span>[<span class='ident'>ExtKeyUsage</span>]) <span class='op'>-></span> <span class='ident'>X509Generator</span> { + <span class='self'>self</span>.<span class='ident'>ext_key_usage</span> <span class='op'>=</span> <span class='ident'>purposes</span>.<span class='ident'>to_vec</span>(); + <span class='self'>self</span> + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>set_sign_hash</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>hash_type</span>: <span class='ident'>hash</span>::<span class='ident'>Type</span>) <span class='op'>-></span> <span class='ident'>X509Generator</span> { + <span class='self'>self</span>.<span class='ident'>hash_type</span> <span class='op'>=</span> <span class='ident'>hash_type</span>; + <span class='self'>self</span> + } + + <span class='kw'>fn</span> <span class='ident'>add_extension</span>(<span class='ident'>x509</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>X509</span>, <span class='ident'>extension</span>: <span class='ident'>c_int</span>, <span class='ident'>value</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(), <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>ctx</span>: <span class='ident'>ffi</span>::<span class='ident'>X509V3_CTX</span> <span class='op'>=</span> <span class='ident'>mem</span>::<span class='ident'>zeroed</span>(); + <span class='ident'>ffi</span>::<span class='ident'>X509V3_set_ctx</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>ctx</span>, <span class='ident'>x509</span>, <span class='ident'>x509</span>, + <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>(), <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>(), <span class='number'>0</span>); + <span class='kw'>let</span> <span class='ident'>value</span> <span class='op'>=</span> <span class='ident'>CString</span>::<span class='ident'>new</span>(<span class='ident'>value</span>.<span class='ident'>as_bytes</span>()).<span class='ident'>unwrap</span>(); + <span class='kw'>let</span> <span class='ident'>ext</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>X509V3_EXT_conf_nid</span>(<span class='ident'>ptr</span>::<span class='ident'>null_mut</span>(), + <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='kw-2'>&</span><span class='ident'>ctx</span>), + <span class='ident'>extension</span>, + <span class='ident'>value</span>.<span class='ident'>as_ptr</span>() <span class='kw'>as</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>); + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>success</span> <span class='op'>=</span> <span class='boolval'>false</span>; + <span class='kw'>if</span> <span class='ident'>ext</span> <span class='op'>!=</span> <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>() { + <span class='ident'>success</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>X509_add_ext</span>(<span class='ident'>x509</span>, <span class='ident'>ext</span>, <span class='op'>-</span><span class='number'>1</span>) <span class='op'>!=</span> <span class='number'>0</span>; + <span class='ident'>ffi</span>::<span class='ident'>X509_EXTENSION_free</span>(<span class='ident'>ext</span>); + } + <span class='macro'>lift_ssl_if</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>success</span>) + } + } + + <span class='kw'>fn</span> <span class='ident'>add_name</span>(<span class='ident'>name</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>X509_NAME</span>, <span class='ident'>key</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>value</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(), <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>value_len</span> <span class='op'>=</span> <span class='ident'>value</span>.<span class='ident'>len</span>() <span class='kw'>as</span> <span class='ident'>c_int</span>; + <span class='macro'>lift_ssl</span><span class='macro'>!</span>(<span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>key</span> <span class='op'>=</span> <span class='ident'>CString</span>::<span class='ident'>new</span>(<span class='ident'>key</span>.<span class='ident'>as_bytes</span>()).<span class='ident'>unwrap</span>(); + <span class='kw'>let</span> <span class='ident'>value</span> <span class='op'>=</span> <span class='ident'>CString</span>::<span class='ident'>new</span>(<span class='ident'>value</span>.<span class='ident'>as_bytes</span>()).<span class='ident'>unwrap</span>(); + <span class='ident'>ffi</span>::<span class='ident'>X509_NAME_add_entry_by_txt</span>(<span class='ident'>name</span>, <span class='ident'>key</span>.<span class='ident'>as_ptr</span>(), <span class='ident'>ffi</span>::<span class='ident'>MBSTRING_UTF8</span>, + <span class='ident'>value</span>.<span class='ident'>as_ptr</span>(), <span class='ident'>value_len</span>, <span class='op'>-</span><span class='number'>1</span>, <span class='number'>0</span>) + }) + } + + <span class='kw'>fn</span> <span class='ident'>random_serial</span>() <span class='op'>-></span> <span class='ident'>c_long</span> { + <span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='ident'>mem</span>::<span class='ident'>size_of</span>::<span class='op'><</span><span class='ident'>c_long</span><span class='op'>></span>(); + <span class='kw'>let</span> <span class='ident'>bytes</span> <span class='op'>=</span> <span class='ident'>rand_bytes</span>(<span class='ident'>len</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>for</span> <span class='ident'>b</span> <span class='kw'>in</span> <span class='ident'>bytes</span>.<span class='ident'>iter</span>() { + <span class='ident'>res</span> <span class='op'>=</span> <span class='ident'>res</span> <span class='op'><<</span> <span class='number'>8</span>; + <span class='ident'>res</span> <span class='op'>|=</span> (<span class='op'>*</span><span class='ident'>b</span> <span class='kw'>as</span> <span class='ident'>c_long</span>) <span class='kw-2'>&</span> <span class='number'>0xff</span>; + } + + <span class='comment'>// While OpenSSL is actually OK to have negative serials</span> + <span class='comment'>// other libraries (for example, Go crypto) can drop</span> + <span class='comment'>// such certificates as invalid, so we clear the high bit</span> + ((<span class='ident'>res</span> <span class='kw'>as</span> <span class='ident'>c_ulong</span>) <span class='op'>>></span> <span class='number'>1</span>) <span class='kw'>as</span> <span class='ident'>c_long</span> + } + + <span class='doccomment'>/// Generates a private key and a self-signed certificate and returns them</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>generate</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(<span class='ident'>X509</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>PKey</span>), <span class='ident'>SslError</span><span class='op'>></span> { + <span class='ident'>ffi</span>::<span class='ident'>init</span>(); + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>p_key</span> <span class='op'>=</span> <span class='ident'>PKey</span>::<span class='ident'>new</span>(); + <span class='ident'>p_key</span>.<span class='ident'>gen</span>(<span class='self'>self</span>.<span class='ident'>bits</span> <span class='kw'>as</span> <span class='ident'>usize</span>); + + <span class='kw'>let</span> <span class='ident'>x509</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>sign</span>(<span class='kw-2'>&</span><span class='ident'>p_key</span>)); + <span class='prelude-val'>Ok</span>((<span class='ident'>x509</span>, <span class='ident'>p_key</span>)) + } + + <span class='doccomment'>/// Sets the certificate public-key, then self-sign and return it</span> + <span class='doccomment'>/// Note: That the bit-length of the private key is used (set_bitlength is ignored)</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>sign</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>p_key</span>: <span class='kw-2'>&</span><span class='ident'>PKey</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>X509</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='ident'>ffi</span>::<span class='ident'>init</span>(); + + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>x509</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>X509_new</span>(); + <span class='macro'>try_ssl_null</span><span class='macro'>!</span>(<span class='ident'>x509</span>); + + <span class='kw'>let</span> <span class='ident'>x509</span> <span class='op'>=</span> <span class='ident'>X509</span> { <span class='ident'>handle</span>: <span class='ident'>x509</span>, <span class='ident'>ctx</span>: <span class='prelude-val'>None</span>, <span class='ident'>owned</span>: <span class='boolval'>true</span>}; + + <span class='macro'>try_ssl</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>X509_set_version</span>(<span class='ident'>x509</span>.<span class='ident'>handle</span>, <span class='number'>2</span>)); + <span class='macro'>try_ssl</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>ASN1_INTEGER_set</span>(<span class='ident'>ffi</span>::<span class='ident'>X509_get_serialNumber</span>(<span class='ident'>x509</span>.<span class='ident'>handle</span>), <span class='ident'>X509Generator</span>::<span class='ident'>random_serial</span>())); + + <span class='kw'>let</span> <span class='ident'>not_before</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>Asn1Time</span>::<span class='ident'>days_from_now</span>(<span class='number'>0</span>)); + <span class='kw'>let</span> <span class='ident'>not_after</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>Asn1Time</span>::<span class='ident'>days_from_now</span>(<span class='self'>self</span>.<span class='ident'>days</span>)); + + <span class='macro'>try_ssl</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>X509_set_notBefore</span>(<span class='ident'>x509</span>.<span class='ident'>handle</span>, <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='ident'>not_before</span>.<span class='ident'>get_handle</span>()))); + <span class='comment'>// If prev line succeded - ownership should go to cert</span> + <span class='ident'>mem</span>::<span class='ident'>forget</span>(<span class='ident'>not_before</span>); + + <span class='macro'>try_ssl</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>X509_set_notAfter</span>(<span class='ident'>x509</span>.<span class='ident'>handle</span>, <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='ident'>not_after</span>.<span class='ident'>get_handle</span>()))); + <span class='comment'>// If prev line succeded - ownership should go to cert</span> + <span class='ident'>mem</span>::<span class='ident'>forget</span>(<span class='ident'>not_after</span>); + + <span class='macro'>try_ssl</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>X509_set_pubkey</span>(<span class='ident'>x509</span>.<span class='ident'>handle</span>, <span class='ident'>p_key</span>.<span class='ident'>get_handle</span>())); + + <span class='kw'>let</span> <span class='ident'>name</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>X509_get_subject_name</span>(<span class='ident'>x509</span>.<span class='ident'>handle</span>); + <span class='macro'>try_ssl_null</span><span class='macro'>!</span>(<span class='ident'>name</span>); + + <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>X509Generator</span>::<span class='ident'>add_name</span>(<span class='ident'>name</span>, <span class='string'>"CN"</span>, <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>CN</span>)); + <span class='ident'>ffi</span>::<span class='ident'>X509_set_issuer_name</span>(<span class='ident'>x509</span>.<span class='ident'>handle</span>, <span class='ident'>name</span>); + + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>key_usage</span>.<span class='ident'>len</span>() <span class='op'>></span> <span class='number'>0</span> { + <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>X509Generator</span>::<span class='ident'>add_extension</span>(<span class='ident'>x509</span>.<span class='ident'>handle</span>, <span class='ident'>ffi</span>::<span class='ident'>NID_key_usage</span>, + <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>key_usage</span>.<span class='ident'>to_str</span>())); + } + + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>ext_key_usage</span>.<span class='ident'>len</span>() <span class='op'>></span> <span class='number'>0</span> { + <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>X509Generator</span>::<span class='ident'>add_extension</span>(<span class='ident'>x509</span>.<span class='ident'>handle</span>, <span class='ident'>ffi</span>::<span class='ident'>NID_ext_key_usage</span>, + <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>ext_key_usage</span>.<span class='ident'>to_str</span>())); + } + + <span class='kw'>let</span> <span class='ident'>hash_fn</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>hash_type</span>.<span class='ident'>evp_md</span>(); + <span class='macro'>try_ssl</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>X509_sign</span>(<span class='ident'>x509</span>.<span class='ident'>handle</span>, <span class='ident'>p_key</span>.<span class='ident'>get_handle</span>(), <span class='ident'>hash_fn</span>)); + <span class='prelude-val'>Ok</span>(<span class='ident'>x509</span>) + } + } + + <span class='doccomment'>/// Obtain a certificate signing request (CSR)</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>request</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>p_key</span>: <span class='kw-2'>&</span><span class='ident'>PKey</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>X509Req</span>, <span class='ident'>SslError</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>cert</span><span class='op'>=</span><span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>sign</span>(<span class='ident'>p_key</span>) { + <span class='prelude-val'>Ok</span>(<span class='ident'>c</span>) <span class='op'>=></span> <span class='ident'>c</span>, + <span class='prelude-val'>Err</span>(<span class='ident'>x</span>) <span class='op'>=></span> <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='ident'>x</span>) + }; + + <span class='kw'>let</span> <span class='ident'>hash_fn</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>hash_type</span>.<span class='ident'>evp_md</span>(); + <span class='kw'>let</span> <span class='ident'>req</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>X509_to_X509_REQ</span>(<span class='ident'>cert</span>.<span class='ident'>handle</span>, <span class='ident'>p_key</span>.<span class='ident'>get_handle</span>(), <span class='ident'>hash_fn</span>) }; + <span class='macro'>try_ssl_null</span><span class='macro'>!</span>(<span class='ident'>req</span>); + + <span class='prelude-val'>Ok</span>(<span class='ident'>X509Req</span>::<span class='ident'>new</span>(<span class='ident'>req</span>)) + } +} + + +<span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>dead_code</span>)]</span> +<span class='doccomment'>/// A public key certificate</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>X509</span><span class='op'><</span><span class='lifetime'>'ctx</span><span class='op'>></span> { + <span class='ident'>ctx</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'ctx</span> <span class='ident'>X509StoreContext</span><span class='op'>></span>, + <span class='ident'>handle</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>X509</span>, + <span class='ident'>owned</span>: <span class='ident'>bool</span> +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'ctx</span><span class='op'>></span> <span class='ident'>X509</span><span class='op'><</span><span class='lifetime'>'ctx</span><span class='op'>></span> { + <span class='doccomment'>/// Creates new from handle with desired ownership.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>handle</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>X509</span>, <span class='ident'>owned</span>: <span class='ident'>bool</span>) <span class='op'>-></span> <span class='ident'>X509</span><span class='op'><</span><span class='lifetime'>'ctx</span><span class='op'>></span> { + <span class='ident'>X509</span> { + <span class='ident'>ctx</span>: <span class='prelude-val'>None</span>, + <span class='ident'>handle</span>: <span class='ident'>handle</span>, + <span class='ident'>owned</span>: <span class='ident'>owned</span>, + } + } + + <span class='doccomment'>/// Creates a new certificate from context. Doesn't take ownership</span> + <span class='doccomment'>/// of handle.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new_in_ctx</span>(<span class='ident'>handle</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>X509</span>, <span class='ident'>ctx</span>: <span class='kw-2'>&</span><span class='lifetime'>'ctx</span> <span class='ident'>X509StoreContext</span>) <span class='op'>-></span> <span class='ident'>X509</span><span class='op'><</span><span class='lifetime'>'ctx</span><span class='op'>></span> { + <span class='ident'>X509</span> { + <span class='ident'>ctx</span>: <span class='prelude-val'>Some</span>(<span class='ident'>ctx</span>), + <span class='ident'>handle</span>: <span class='ident'>handle</span>, + <span class='ident'>owned</span>: <span class='boolval'>false</span> + } + } + + <span class='doccomment'>/// Reads certificate from PEM, takes ownership of handle</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>from_pem</span><span class='op'><</span><span class='ident'>R</span><span class='op'>></span>(<span class='ident'>reader</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>R</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>X509</span><span class='op'><</span><span class='lifetime'>'ctx</span><span class='op'>></span>, <span class='ident'>SslError</span><span class='op'>></span> <span class='kw'>where</span> <span class='ident'>R</span>: <span class='ident'>Read</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>mem_bio</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>MemBio</span>::<span class='ident'>new</span>()); + <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>io</span>::<span class='ident'>copy</span>(<span class='ident'>reader</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>mem_bio</span>).<span class='ident'>map_err</span>(<span class='ident'>StreamError</span>)); + + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>handle</span> <span class='op'>=</span> <span class='macro'>try_ssl_null</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>PEM_read_bio_X509</span>(<span class='ident'>mem_bio</span>.<span class='ident'>get_handle</span>(), + <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>(), + <span class='prelude-val'>None</span>, <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>())); + <span class='prelude-val'>Ok</span>(<span class='ident'>X509</span>::<span class='ident'>new</span>(<span class='ident'>handle</span>, <span class='boolval'>true</span>)) + } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_handle</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>X509</span> { + <span class='self'>self</span>.<span class='ident'>handle</span> + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>subject_name</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>X509Name</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>name</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>X509_get_subject_name</span>(<span class='self'>self</span>.<span class='ident'>handle</span>) }; + <span class='ident'>X509Name</span> { <span class='ident'>x509</span>: <span class='self'>self</span>, <span class='ident'>name</span>: <span class='ident'>name</span> } + } + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>public_key</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>PKey</span> { + <span class='kw'>let</span> <span class='ident'>pkey</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>X509_get_pubkey</span>(<span class='self'>self</span>.<span class='ident'>handle</span>) }; + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>pkey</span>.<span class='ident'>is_null</span>()); + + <span class='ident'>PKey</span>::<span class='ident'>from_handle</span>(<span class='ident'>pkey</span>, <span class='ident'>Parts</span>::<span class='ident'>Public</span>) + } + + <span class='doccomment'>/// Returns certificate fingerprint calculated using provided hash</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fingerprint</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>hash_type</span>: <span class='ident'>hash</span>::<span class='ident'>Type</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>>></span> { + <span class='kw'>let</span> <span class='ident'>evp</span> <span class='op'>=</span> <span class='ident'>hash_type</span>.<span class='ident'>evp_md</span>(); + <span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='ident'>hash_type</span>.<span class='ident'>md_len</span>(); + <span class='kw'>let</span> <span class='ident'>v</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>u8</span><span class='op'>></span> <span class='op'>=</span> <span class='ident'>repeat</span>(<span class='number'>0</span>).<span class='ident'>take</span>(<span class='ident'>len</span> <span class='kw'>as</span> <span class='ident'>usize</span>).<span class='ident'>collect</span>(); + <span class='kw'>let</span> <span class='ident'>act_len</span>: <span class='ident'>c_uint</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>let</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='kw'>unsafe</span> { + <span class='ident'>ffi</span>::<span class='ident'>X509_digest</span>(<span class='self'>self</span>.<span class='ident'>handle</span>, <span class='ident'>evp</span>, <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='ident'>v</span>.<span class='ident'>as_ptr</span>()), + <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='kw-2'>&</span><span class='ident'>act_len</span>)) + }; + + <span class='kw'>match</span> <span class='ident'>res</span> { + <span class='number'>0</span> <span class='op'>=></span> <span class='prelude-val'>None</span>, + _ <span class='op'>=></span> { + <span class='kw'>let</span> <span class='ident'>act_len</span> <span class='op'>=</span> <span class='ident'>act_len</span> <span class='kw'>as</span> <span class='ident'>usize</span>; + <span class='kw'>match</span> <span class='ident'>len</span>.<span class='ident'>cmp</span>(<span class='kw-2'>&</span><span class='ident'>act_len</span>) { + <span class='ident'>Ordering</span>::<span class='ident'>Greater</span> <span class='op'>=></span> <span class='prelude-val'>None</span>, + <span class='ident'>Ordering</span>::<span class='ident'>Equal</span> <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>v</span>), + <span class='ident'>Ordering</span>::<span class='ident'>Less</span> <span class='op'>=></span> <span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>"Fingerprint buffer was corrupted!"</span>) + } + } + } + } + + <span class='doccomment'>/// Writes certificate as PEM</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>write_pem</span><span class='op'><</span><span class='ident'>W</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>writer</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>W</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(), <span class='ident'>SslError</span><span class='op'>></span> <span class='kw'>where</span> <span class='ident'>W</span>: <span class='ident'>Write</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>mem_bio</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>MemBio</span>::<span class='ident'>new</span>()); + <span class='kw'>unsafe</span> { + <span class='macro'>try_ssl</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>PEM_write_bio_X509</span>(<span class='ident'>mem_bio</span>.<span class='ident'>get_handle</span>(), + <span class='self'>self</span>.<span class='ident'>handle</span>)); + } + <span class='ident'>io</span>::<span class='ident'>copy</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>mem_bio</span>, <span class='ident'>writer</span>).<span class='ident'>map_err</span>(<span class='ident'>StreamError</span>).<span class='ident'>map</span>(<span class='op'>|</span>_<span class='op'>|</span> ()) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'ctx</span><span class='op'>></span> <span class='ident'>Drop</span> <span class='kw'>for</span> <span class='ident'>X509</span><span class='op'><</span><span class='lifetime'>'ctx</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>drop</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>owned</span> { + <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>X509_free</span>(<span class='self'>self</span>.<span class='ident'>handle</span>) }; + } + } +} + +<span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>dead_code</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>X509Name</span><span class='op'><</span><span class='lifetime'>'x</span><span class='op'>></span> { + <span class='ident'>x509</span>: <span class='kw-2'>&</span><span class='lifetime'>'x</span> <span class='ident'>X509</span><span class='op'><</span><span class='lifetime'>'x</span><span class='op'>></span>, + <span class='ident'>name</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>X509_NAME</span> +} + +<span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>dead_code</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>X509NameEntry</span><span class='op'><</span><span class='lifetime'>'x</span><span class='op'>></span> { + <span class='ident'>x509_name</span>: <span class='kw-2'>&</span><span class='lifetime'>'x</span> <span class='ident'>X509Name</span><span class='op'><</span><span class='lifetime'>'x</span><span class='op'>></span>, + <span class='ident'>ne</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>X509_NAME_ENTRY</span> +} + +<span class='kw'>impl</span> <span class='op'><</span><span class='lifetime'>'x</span><span class='op'>></span> <span class='ident'>X509Name</span><span class='op'><</span><span class='lifetime'>'x</span><span class='op'>></span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>text_by_nid</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>nid</span>: <span class='ident'>nid</span>::<span class='ident'>Nid</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>SslString</span><span class='op'>></span> { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>loc</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>X509_NAME_get_index_by_NID</span>(<span class='self'>self</span>.<span class='ident'>name</span>, <span class='ident'>nid</span> <span class='kw'>as</span> <span class='ident'>c_int</span>, <span class='op'>-</span><span class='number'>1</span>); + <span class='kw'>if</span> <span class='ident'>loc</span> <span class='op'>==</span> <span class='op'>-</span><span class='number'>1</span> { + <span class='kw'>return</span> <span class='prelude-val'>None</span>; + } + + <span class='kw'>let</span> <span class='ident'>ne</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>X509_NAME_get_entry</span>(<span class='self'>self</span>.<span class='ident'>name</span>, <span class='ident'>loc</span>); + <span class='kw'>if</span> <span class='ident'>ne</span>.<span class='ident'>is_null</span>() { + <span class='kw'>return</span> <span class='prelude-val'>None</span>; + } + + <span class='kw'>let</span> <span class='ident'>asn1_str</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>X509_NAME_ENTRY_get_data</span>(<span class='ident'>ne</span>); + <span class='kw'>if</span> <span class='ident'>asn1_str</span>.<span class='ident'>is_null</span>() { + <span class='kw'>return</span> <span class='prelude-val'>None</span>; + } + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>str_from_asn1</span> : <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span> <span class='op'>=</span> <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>(); + <span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='ident'>ffi</span>::<span class='ident'>ASN1_STRING_to_UTF8</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>str_from_asn1</span>, <span class='ident'>asn1_str</span>); + + <span class='kw'>if</span> <span class='ident'>len</span> <span class='op'><</span> <span class='number'>0</span> { + <span class='kw'>return</span> <span class='prelude-val'>None</span> + } + + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>str_from_asn1</span>.<span class='ident'>is_null</span>()); + + <span class='prelude-val'>Some</span>(<span class='ident'>SslString</span>::<span class='ident'>new</span>(<span class='ident'>str_from_asn1</span>)) + } + } +} + +<span class='doccomment'>/// A certificate signing request</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>X509Req</span> { + <span class='ident'>handle</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>X509_REQ</span>, +} + +<span class='kw'>impl</span> <span class='ident'>X509Req</span> { + <span class='doccomment'>/// Creates new from handle</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>handle</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ffi</span>::<span class='ident'>X509_REQ</span>) <span class='op'>-></span> <span class='ident'>X509Req</span> { + <span class='ident'>X509Req</span> { + <span class='ident'>handle</span>: <span class='ident'>handle</span>, + } + } + + <span class='doccomment'>/// Reads CSR from PEM</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>from_pem</span><span class='op'><</span><span class='ident'>R</span><span class='op'>></span>(<span class='ident'>reader</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>R</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>X509Req</span>, <span class='ident'>SslError</span><span class='op'>></span> <span class='kw'>where</span> <span class='ident'>R</span>: <span class='ident'>Read</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>mem_bio</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>MemBio</span>::<span class='ident'>new</span>()); + <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>io</span>::<span class='ident'>copy</span>(<span class='ident'>reader</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>mem_bio</span>).<span class='ident'>map_err</span>(<span class='ident'>StreamError</span>)); + + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>handle</span> <span class='op'>=</span> <span class='macro'>try_ssl_null</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>PEM_read_bio_X509_REQ</span>(<span class='ident'>mem_bio</span>.<span class='ident'>get_handle</span>(), + <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>(), + <span class='prelude-val'>None</span>, <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>())); + <span class='prelude-val'>Ok</span>(<span class='ident'>X509Req</span>::<span class='ident'>new</span>(<span class='ident'>handle</span>)) + } + } + + <span class='doccomment'>/// Writes CSR as PEM</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>write_pem</span><span class='op'><</span><span class='ident'>W</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>writer</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>W</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(), <span class='ident'>SslError</span><span class='op'>></span> <span class='kw'>where</span> <span class='ident'>W</span>: <span class='ident'>Write</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>mem_bio</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>MemBio</span>::<span class='ident'>new</span>()); + <span class='kw'>unsafe</span> { + <span class='macro'>try_ssl</span><span class='macro'>!</span>(<span class='ident'>ffi</span>::<span class='ident'>PEM_write_bio_X509_REQ</span>(<span class='ident'>mem_bio</span>.<span class='ident'>get_handle</span>(), + <span class='self'>self</span>.<span class='ident'>handle</span>)); + } + <span class='ident'>io</span>::<span class='ident'>copy</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>mem_bio</span>, <span class='ident'>writer</span>).<span class='ident'>map_err</span>(<span class='ident'>StreamError</span>).<span class='ident'>map</span>(<span class='op'>|</span>_<span class='op'>|</span> ()) + } +} + +<span class='kw'>impl</span> <span class='ident'>Drop</span> <span class='kw'>for</span> <span class='ident'>X509Req</span> { + <span class='kw'>fn</span> <span class='ident'>drop</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>unsafe</span> { <span class='ident'>ffi</span>::<span class='ident'>X509_REQ_free</span>(<span class='self'>self</span>.<span class='ident'>handle</span>) }; + } +} + +<span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>make_validation_error</span>( + (<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>ok_val</span>:<span class='ident'>ident</span>, $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>name</span>:<span class='ident'>ident</span> <span class='op'>=</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>val</span>:<span class='ident'>ident</span>,)<span class='op'>+</span>) <span class='op'>=></span> ( + <span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>X509ValidationError</span> { + $(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>name</span>,)<span class='op'>+</span> + <span class='ident'>X509UnknownError</span>(<span class='ident'>c_int</span>) + } + + <span class='kw'>impl</span> <span class='ident'>X509ValidationError</span> { + <span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>from_raw</span>(<span class='ident'>err</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>X509ValidationError</span><span class='op'>></span> { + <span class='kw'>match</span> <span class='ident'>err</span> { + <span class='ident'>ffi</span>::<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>ok_val</span> <span class='op'>=></span> <span class='prelude-val'>None</span>, + $(<span class='ident'>ffi</span>::<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>val</span> <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>X509ValidationError</span>::<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>name</span>),)<span class='op'>+</span> + <span class='ident'>err</span> <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>X509ValidationError</span>::<span class='ident'>X509UnknownError</span>(<span class='ident'>err</span>)) + } + } + } + ) +); + +<span class='macro'>make_validation_error</span><span class='macro'>!</span>(<span class='ident'>X509_V_OK</span>, + <span class='ident'>X509UnableToGetIssuerCert</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT</span>, + <span class='ident'>X509UnableToGetCrl</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_UNABLE_TO_GET_CRL</span>, + <span class='ident'>X509UnableToDecryptCertSignature</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE</span>, + <span class='ident'>X509UnableToDecryptCrlSignature</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE</span>, + <span class='ident'>X509UnableToDecodeIssuerPublicKey</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY</span>, + <span class='ident'>X509CertSignatureFailure</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_CERT_SIGNATURE_FAILURE</span>, + <span class='ident'>X509CrlSignatureFailure</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_CRL_SIGNATURE_FAILURE</span>, + <span class='ident'>X509CertNotYetValid</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_CERT_NOT_YET_VALID</span>, + <span class='ident'>X509CertHasExpired</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_CERT_HAS_EXPIRED</span>, + <span class='ident'>X509CrlNotYetValid</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_CRL_NOT_YET_VALID</span>, + <span class='ident'>X509CrlHasExpired</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_CRL_HAS_EXPIRED</span>, + <span class='ident'>X509ErrorInCertNotBeforeField</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD</span>, + <span class='ident'>X509ErrorInCertNotAfterField</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD</span>, + <span class='ident'>X509ErrorInCrlLastUpdateField</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD</span>, + <span class='ident'>X509ErrorInCrlNextUpdateField</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD</span>, + <span class='ident'>X509OutOfMem</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_OUT_OF_MEM</span>, + <span class='ident'>X509DepthZeroSelfSignedCert</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT</span>, + <span class='ident'>X509SelfSignedCertInChain</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN</span>, + <span class='ident'>X509UnableToGetIssuerCertLocally</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY</span>, + <span class='ident'>X509UnableToVerifyLeafSignature</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE</span>, + <span class='ident'>X509CertChainTooLong</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_CERT_CHAIN_TOO_LONG</span>, + <span class='ident'>X509CertRevoked</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_CERT_REVOKED</span>, + <span class='ident'>X509InvalidCA</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_INVALID_CA</span>, + <span class='ident'>X509PathLengthExceeded</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_PATH_LENGTH_EXCEEDED</span>, + <span class='ident'>X509InvalidPurpose</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_INVALID_PURPOSE</span>, + <span class='ident'>X509CertUntrusted</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_CERT_UNTRUSTED</span>, + <span class='ident'>X509CertRejected</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_CERT_REJECTED</span>, + <span class='ident'>X509SubjectIssuerMismatch</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_SUBJECT_ISSUER_MISMATCH</span>, + <span class='ident'>X509AkidSkidMismatch</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_AKID_SKID_MISMATCH</span>, + <span class='ident'>X509AkidIssuerSerialMismatch</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH</span>, + <span class='ident'>X509KeyusageNoCertsign</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_KEYUSAGE_NO_CERTSIGN</span>, + <span class='ident'>X509UnableToGetCrlIssuer</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER</span>, + <span class='ident'>X509UnhandledCriticalExtension</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION</span>, + <span class='ident'>X509KeyusageNoCrlSign</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_KEYUSAGE_NO_CRL_SIGN</span>, + <span class='ident'>X509UnhandledCriticalCrlExtension</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION</span>, + <span class='ident'>X509InvalidNonCA</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_INVALID_NON_CA</span>, + <span class='ident'>X509ProxyPathLengthExceeded</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED</span>, + <span class='ident'>X509KeyusageNoDigitalSignature</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE</span>, + <span class='ident'>X509ProxyCertificatesNotAllowed</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED</span>, + <span class='ident'>X509InvalidExtension</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_INVALID_EXTENSION</span>, + <span class='ident'>X509InavlidPolicyExtension</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_INVALID_POLICY_EXTENSION</span>, + <span class='ident'>X509NoExplicitPolicy</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_NO_EXPLICIT_POLICY</span>, + <span class='ident'>X509DifferentCrlScope</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_DIFFERENT_CRL_SCOPE</span>, + <span class='ident'>X509UnsupportedExtensionFeature</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE</span>, + <span class='ident'>X509UnnestedResource</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_UNNESTED_RESOURCE</span>, + <span class='ident'>X509PermittedVolation</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_PERMITTED_VIOLATION</span>, + <span class='ident'>X509ExcludedViolation</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_EXCLUDED_VIOLATION</span>, + <span class='ident'>X509SubtreeMinmax</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_SUBTREE_MINMAX</span>, + <span class='ident'>X509UnsupportedConstraintType</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE</span>, + <span class='ident'>X509UnsupportedConstraintSyntax</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX</span>, + <span class='ident'>X509UnsupportedNameSyntax</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_UNSUPPORTED_NAME_SYNTAX</span>, + <span class='ident'>X509CrlPathValidationError</span><span class='op'>=</span> <span class='ident'>X509_V_ERR_CRL_PATH_VALIDATION_ERROR</span>, + <span class='ident'>X509ApplicationVerification</span> <span class='op'>=</span> <span class='ident'>X509_V_ERR_APPLICATION_VERIFICATION</span>, +); + + +<span class='attribute'>#[<span class='ident'>test</span>]</span> +<span class='kw'>fn</span> <span class='ident'>test_negative_serial</span>() { + <span class='comment'>// I guess that's enough to get a random negative number</span> + <span class='kw'>for</span> _ <span class='kw'>in</span> <span class='number'>0</span>..<span class='number'>1000</span> { + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>X509Generator</span>::<span class='ident'>random_serial</span>() <span class='op'>></span> <span class='number'>0</span>, <span class='string'>"All serials should be positive"</span>); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl"; + window.playgroundUrl = ""; + </script> + <script src="../../../jquery.js"></script> + <script src="../../../main.js"></script> + + <script async src="../../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl_sys/lib.rs.html b/src/openssl_sys/lib.rs.html new file mode 100644 index 0000000..bd0937b --- /dev/null +++ b/src/openssl_sys/lib.rs.html @@ -0,0 +1,1327 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-sys-0.6.3/src/lib.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>lib.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +<span id="313">313</span> +<span id="314">314</span> +<span id="315">315</span> +<span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +<span id="326">326</span> +<span id="327">327</span> +<span id="328">328</span> +<span id="329">329</span> +<span id="330">330</span> +<span id="331">331</span> +<span id="332">332</span> +<span id="333">333</span> +<span id="334">334</span> +<span id="335">335</span> +<span id="336">336</span> +<span id="337">337</span> +<span id="338">338</span> +<span id="339">339</span> +<span id="340">340</span> +<span id="341">341</span> +<span id="342">342</span> +<span id="343">343</span> +<span id="344">344</span> +<span id="345">345</span> +<span id="346">346</span> +<span id="347">347</span> +<span id="348">348</span> +<span id="349">349</span> +<span id="350">350</span> +<span id="351">351</span> +<span id="352">352</span> +<span id="353">353</span> +<span id="354">354</span> +<span id="355">355</span> +<span id="356">356</span> +<span id="357">357</span> +<span id="358">358</span> +<span id="359">359</span> +<span id="360">360</span> +<span id="361">361</span> +<span id="362">362</span> +<span id="363">363</span> +<span id="364">364</span> +<span id="365">365</span> +<span id="366">366</span> +<span id="367">367</span> +<span id="368">368</span> +<span id="369">369</span> +<span id="370">370</span> +<span id="371">371</span> +<span id="372">372</span> +<span id="373">373</span> +<span id="374">374</span> +<span id="375">375</span> +<span id="376">376</span> +<span id="377">377</span> +<span id="378">378</span> +<span id="379">379</span> +<span id="380">380</span> +<span id="381">381</span> +<span id="382">382</span> +<span id="383">383</span> +<span id="384">384</span> +<span id="385">385</span> +<span id="386">386</span> +<span id="387">387</span> +<span id="388">388</span> +<span id="389">389</span> +<span id="390">390</span> +<span id="391">391</span> +<span id="392">392</span> +<span id="393">393</span> +<span id="394">394</span> +<span id="395">395</span> +<span id="396">396</span> +<span id="397">397</span> +<span id="398">398</span> +<span id="399">399</span> +<span id="400">400</span> +<span id="401">401</span> +<span id="402">402</span> +<span id="403">403</span> +<span id="404">404</span> +<span id="405">405</span> +<span id="406">406</span> +<span id="407">407</span> +<span id="408">408</span> +<span id="409">409</span> +<span id="410">410</span> +<span id="411">411</span> +<span id="412">412</span> +<span id="413">413</span> +<span id="414">414</span> +<span id="415">415</span> +<span id="416">416</span> +<span id="417">417</span> +<span id="418">418</span> +<span id="419">419</span> +<span id="420">420</span> +<span id="421">421</span> +<span id="422">422</span> +<span id="423">423</span> +<span id="424">424</span> +<span id="425">425</span> +<span id="426">426</span> +<span id="427">427</span> +<span id="428">428</span> +<span id="429">429</span> +<span id="430">430</span> +<span id="431">431</span> +<span id="432">432</span> +<span id="433">433</span> +<span id="434">434</span> +<span id="435">435</span> +<span id="436">436</span> +<span id="437">437</span> +<span id="438">438</span> +<span id="439">439</span> +<span id="440">440</span> +<span id="441">441</span> +<span id="442">442</span> +<span id="443">443</span> +<span id="444">444</span> +<span id="445">445</span> +<span id="446">446</span> +<span id="447">447</span> +<span id="448">448</span> +<span id="449">449</span> +<span id="450">450</span> +<span id="451">451</span> +<span id="452">452</span> +<span id="453">453</span> +<span id="454">454</span> +<span id="455">455</span> +<span id="456">456</span> +<span id="457">457</span> +<span id="458">458</span> +<span id="459">459</span> +<span id="460">460</span> +<span id="461">461</span> +<span id="462">462</span> +<span id="463">463</span> +<span id="464">464</span> +<span id="465">465</span> +<span id="466">466</span> +<span id="467">467</span> +<span id="468">468</span> +<span id="469">469</span> +<span id="470">470</span> +<span id="471">471</span> +<span id="472">472</span> +<span id="473">473</span> +<span id="474">474</span> +<span id="475">475</span> +<span id="476">476</span> +<span id="477">477</span> +<span id="478">478</span> +<span id="479">479</span> +<span id="480">480</span> +<span id="481">481</span> +<span id="482">482</span> +<span id="483">483</span> +<span id="484">484</span> +<span id="485">485</span> +<span id="486">486</span> +<span id="487">487</span> +<span id="488">488</span> +<span id="489">489</span> +<span id="490">490</span> +<span id="491">491</span> +<span id="492">492</span> +<span id="493">493</span> +<span id="494">494</span> +<span id="495">495</span> +<span id="496">496</span> +<span id="497">497</span> +<span id="498">498</span> +<span id="499">499</span> +<span id="500">500</span> +<span id="501">501</span> +<span id="502">502</span> +<span id="503">503</span> +<span id="504">504</span> +<span id="505">505</span> +<span id="506">506</span> +<span id="507">507</span> +<span id="508">508</span> +<span id="509">509</span> +<span id="510">510</span> +<span id="511">511</span> +<span id="512">512</span> +<span id="513">513</span> +<span id="514">514</span> +<span id="515">515</span> +<span id="516">516</span> +<span id="517">517</span> +<span id="518">518</span> +<span id="519">519</span> +<span id="520">520</span> +<span id="521">521</span> +<span id="522">522</span> +<span id="523">523</span> +<span id="524">524</span> +<span id="525">525</span> +<span id="526">526</span> +<span id="527">527</span> +<span id="528">528</span> +<span id="529">529</span> +<span id="530">530</span> +<span id="531">531</span> +<span id="532">532</span> +<span id="533">533</span> +<span id="534">534</span> +<span id="535">535</span> +<span id="536">536</span> +<span id="537">537</span> +<span id="538">538</span> +<span id="539">539</span> +<span id="540">540</span> +<span id="541">541</span> +<span id="542">542</span> +<span id="543">543</span> +<span id="544">544</span> +<span id="545">545</span> +<span id="546">546</span> +<span id="547">547</span> +<span id="548">548</span> +<span id="549">549</span> +<span id="550">550</span> +<span id="551">551</span> +<span id="552">552</span> +<span id="553">553</span> +<span id="554">554</span> +<span id="555">555</span> +<span id="556">556</span> +<span id="557">557</span> +<span id="558">558</span> +<span id="559">559</span> +<span id="560">560</span> +<span id="561">561</span> +<span id="562">562</span> +<span id="563">563</span> +<span id="564">564</span> +<span id="565">565</span> +<span id="566">566</span> +<span id="567">567</span> +<span id="568">568</span> +<span id="569">569</span> +<span id="570">570</span> +<span id="571">571</span> +<span id="572">572</span> +<span id="573">573</span> +<span id="574">574</span> +<span id="575">575</span> +<span id="576">576</span> +<span id="577">577</span> +<span id="578">578</span> +<span id="579">579</span> +<span id="580">580</span> +<span id="581">581</span> +<span id="582">582</span> +<span id="583">583</span> +<span id="584">584</span> +<span id="585">585</span> +<span id="586">586</span> +<span id="587">587</span> +<span id="588">588</span> +<span id="589">589</span> +<span id="590">590</span> +<span id="591">591</span> +<span id="592">592</span> +<span id="593">593</span> +<span id="594">594</span> +<span id="595">595</span> +<span id="596">596</span> +<span id="597">597</span> +<span id="598">598</span> +<span id="599">599</span> +<span id="600">600</span> +<span id="601">601</span> +<span id="602">602</span> +<span id="603">603</span> +<span id="604">604</span> +<span id="605">605</span> +<span id="606">606</span> +<span id="607">607</span> +<span id="608">608</span> +<span id="609">609</span> +<span id="610">610</span> +<span id="611">611</span> +<span id="612">612</span> +<span id="613">613</span> +<span id="614">614</span> +<span id="615">615</span> +</pre><pre class='rust '> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>allow</span>(<span class='ident'>non_camel_case_types</span>, <span class='ident'>non_upper_case_globals</span>, <span class='ident'>non_snake_case</span>)]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>allow</span>(<span class='ident'>dead_code</span>)]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>doc</span>(<span class='ident'>html_root_url</span><span class='op'>=</span><span class='string'>"https://sfackler.github.io/rust-openssl/doc/v0.6.3"</span>)]</span> + +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>libc</span>; + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>)]</span> +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>libressl_pnacl_sys</span>; + +<span class='kw'>use</span> <span class='ident'>libc</span>::{<span class='ident'>c_void</span>, <span class='ident'>c_int</span>, <span class='ident'>c_char</span>, <span class='ident'>c_ulong</span>, <span class='ident'>c_long</span>, <span class='ident'>c_uint</span>, <span class='ident'>c_uchar</span>, <span class='ident'>size_t</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>mem</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ptr</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>sync</span>::{<span class='ident'>Mutex</span>, <span class='ident'>MutexGuard</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>sync</span>::{<span class='ident'>Once</span>, <span class='ident'>ONCE_INIT</span>}; + +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ASN1_INTEGER</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ASN1_STRING</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ASN1_TIME</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>BIO</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>BIO_METHOD</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>BN_CTX</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>COMP_METHOD</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>CRYPTO_EX_DATA</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>ENGINE</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>EVP_CIPHER</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>EVP_CIPHER_CTX</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>EVP_MD</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>EVP_PKEY</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>EVP_PKEY_CTX</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>RSA</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>SSL</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>SSL_CTX</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>SSL_METHOD</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>X509</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>X509_CRL</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>X509_EXTENSION</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>X509_NAME</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>X509_NAME_ENTRY</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>X509_REQ</span> <span class='op'>=</span> <span class='ident'>c_void</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>X509_STORE_CTX</span> <span class='op'>=</span> <span class='ident'>c_void</span>; + +<span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>EVP_MD_CTX</span> { + <span class='ident'>digest</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_MD</span>, + <span class='ident'>engine</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>flags</span>: <span class='ident'>c_ulong</span>, + <span class='ident'>md_data</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>pctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_PKEY_CTX</span>, + <span class='ident'>update</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span> +} + +<span class='kw'>impl</span> <span class='ident'>Copy</span> <span class='kw'>for</span> <span class='ident'>EVP_MD_CTX</span> {} +<span class='kw'>impl</span> <span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>EVP_MD_CTX</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>EVP_MD_CTX</span> { <span class='op'>*</span><span class='self'>self</span> } +} + +<span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>HMAC_CTX</span> { + <span class='ident'>md</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_MD</span>, + <span class='ident'>md_ctx</span>: <span class='ident'>EVP_MD_CTX</span>, + <span class='ident'>i_ctx</span>: <span class='ident'>EVP_MD_CTX</span>, + <span class='ident'>o_ctx</span>: <span class='ident'>EVP_MD_CTX</span>, + <span class='ident'>key_length</span>: <span class='ident'>c_uint</span>, + <span class='ident'>key</span>: [<span class='ident'>c_uchar</span>; <span class='number'>128</span>] +} + +<span class='kw'>impl</span> <span class='ident'>Copy</span> <span class='kw'>for</span> <span class='ident'>HMAC_CTX</span> {} +<span class='kw'>impl</span> <span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>HMAC_CTX</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>HMAC_CTX</span> { <span class='op'>*</span><span class='self'>self</span> } +} + +<span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>X509V3_CTX</span> { + <span class='ident'>flags</span>: <span class='ident'>c_int</span>, + <span class='ident'>issuer_cert</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>subject_cert</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>subject_req</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>crl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>db_meth</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>db</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='comment'>// I like the last comment line, it is copied from OpenSSL sources:</span> + <span class='comment'>// Maybe more here</span> +} + +<span class='kw'>impl</span> <span class='ident'>Copy</span> <span class='kw'>for</span> <span class='ident'>X509V3_CTX</span> {} +<span class='kw'>impl</span> <span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>X509V3_CTX</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>X509V3_CTX</span> { <span class='op'>*</span><span class='self'>self</span> } +} + +<span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>BIGNUM</span> { + <span class='kw'>pub</span> <span class='ident'>d</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='kw'>pub</span> <span class='ident'>top</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>dmax</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>neg</span>: <span class='ident'>c_int</span>, + <span class='kw'>pub</span> <span class='ident'>flags</span>: <span class='ident'>c_int</span>, +} + +<span class='kw'>impl</span> <span class='ident'>Copy</span> <span class='kw'>for</span> <span class='ident'>BIGNUM</span> {} +<span class='kw'>impl</span> <span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>BIGNUM</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>BIGNUM</span> { <span class='op'>*</span><span class='self'>self</span> } +} + +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>CRYPTO_EX_new</span> <span class='op'>=</span> <span class='kw'>extern</span> <span class='string'>"C"</span> <span class='kw'>fn</span>(<span class='ident'>parent</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>ptr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>ad</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>CRYPTO_EX_DATA</span>, <span class='ident'>idx</span>: <span class='ident'>c_int</span>, + <span class='ident'>argl</span>: <span class='ident'>c_long</span>, <span class='ident'>argp</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>CRYPTO_EX_dup</span> <span class='op'>=</span> <span class='kw'>extern</span> <span class='string'>"C"</span> <span class='kw'>fn</span>(<span class='ident'>to</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>CRYPTO_EX_DATA</span>, + <span class='ident'>from</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>CRYPTO_EX_DATA</span>, <span class='ident'>from_d</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>idx</span>: <span class='ident'>c_int</span>, <span class='ident'>argl</span>: <span class='ident'>c_long</span>, <span class='ident'>argp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>CRYPTO_EX_free</span> <span class='op'>=</span> <span class='kw'>extern</span> <span class='string'>"C"</span> <span class='kw'>fn</span>(<span class='ident'>parent</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>ptr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, + <span class='ident'>ad</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>CRYPTO_EX_DATA</span>, <span class='ident'>idx</span>: <span class='ident'>c_int</span>, + <span class='ident'>argl</span>: <span class='ident'>c_long</span>, <span class='ident'>argp</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>); +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>PasswordCallback</span> <span class='op'>=</span> <span class='kw'>extern</span> <span class='string'>"C"</span> <span class='kw'>fn</span>(<span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, <span class='ident'>size</span>: <span class='ident'>c_int</span>, + <span class='ident'>rwflag</span>: <span class='ident'>c_int</span>, <span class='ident'>user_data</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>BIO_CTRL_EOF</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>BIO_C_SET_BUF_MEM_EOF_RETURN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>130</span>; + +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>CRYPTO_LOCK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; + +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MBSTRING_ASC</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>MBSTRING_FLAG</span> <span class='op'>|</span> <span class='number'>1</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MBSTRING_BMP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>MBSTRING_FLAG</span> <span class='op'>|</span> <span class='number'>2</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MBSTRING_FLAG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0x1000</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MBSTRING_UNIV</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>MBSTRING_FLAG</span> <span class='op'>|</span> <span class='number'>4</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>MBSTRING_UTF8</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='ident'>MBSTRING_FLAG</span>; + +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>NID_ext_key_usage</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>126</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>NID_key_usage</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>83</span>; + +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_CTRL_OPTIONS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>32</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_CTRL_CLEAR_OPTIONS</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>77</span>; + +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_CTRL_SET_TLSEXT_HOSTNAME</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>55</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_CTRL_EXTRA_CHAIN_CERT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; + +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_CTRL_SET_READ_AHEAD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>41</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_ERROR_NONE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_ERROR_SSL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_ERROR_SYSCALL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_ERROR_WANT_ACCEPT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_ERROR_WANT_CONNECT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_ERROR_WANT_READ</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_ERROR_WANT_WRITE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_ERROR_WANT_X509_LOOKUP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_ERROR_ZERO_RETURN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_VERIFY_NONE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_VERIFY_PEER</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_VERIFY_FAIL_IF_NO_PEER_CERT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>TLSEXT_NAMETYPE_host_name</span>: <span class='ident'>c_long</span> <span class='op'>=</span> <span class='number'>0</span>; + +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_TLSEXT_ERR_OK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_TLSEXT_ERR_ALERT_WARNING</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_TLSEXT_ERR_ALERT_FATAL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>SSL_TLSEXT_ERR_NOACK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"npn"</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>OPENSSL_NPN_UNSUPPORTED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"npn"</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>OPENSSL_NPN_NEGOTIATED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"npn"</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>OPENSSL_NPN_NO_OVERLAP</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; + +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>V_ASN1_GENERALIZEDTIME</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>24</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>V_ASN1_UTCTIME</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>23</span>; + +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_FILETYPE_ASN1</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_FILETYPE_DEFAULT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_FILETYPE_PEM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>1</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>31</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_AKID_SKID_MISMATCH</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>30</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_APPLICATION_VERIFICATION</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>50</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_CERT_CHAIN_TOO_LONG</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>22</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_CERT_HAS_EXPIRED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>10</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_CERT_NOT_YET_VALID</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>9</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_CERT_REJECTED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>28</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_CERT_REVOKED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>23</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_CERT_SIGNATURE_FAILURE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>7</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_CERT_UNTRUSTED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>27</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_CRL_HAS_EXPIRED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>12</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_CRL_NOT_YET_VALID</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>11</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_CRL_PATH_VALIDATION_ERROR</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>54</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_CRL_SIGNATURE_FAILURE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>8</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>18</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_DIFFERENT_CRL_SCOPE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>44</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>14</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>13</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>15</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>16</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_EXCLUDED_VIOLATION</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>48</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_INVALID_CA</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>24</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_INVALID_EXTENSION</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>41</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_INVALID_NON_CA</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>37</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_INVALID_POLICY_EXTENSION</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>42</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_INVALID_PURPOSE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>26</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_KEYUSAGE_NO_CERTSIGN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>32</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_KEYUSAGE_NO_CRL_SIGN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>35</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>39</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_NO_EXPLICIT_POLICY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>43</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_OUT_OF_MEM</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>17</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_PATH_LENGTH_EXCEEDED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>25</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_PERMITTED_VIOLATION</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>47</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>40</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>38</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>19</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_SUBJECT_ISSUER_MISMATCH</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>29</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_SUBTREE_MINMAX</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>49</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>6</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>4</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>5</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_UNABLE_TO_GET_CRL</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>3</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>33</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>2</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>20</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>21</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>36</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>34</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_UNNESTED_RESOURCE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>46</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>52</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>51</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>45</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_ERR_UNSUPPORTED_NAME_SYNTAX</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>53</span>; +<span class='kw'>pub</span> <span class='kw'>const</span> <span class='ident'>X509_V_OK</span>: <span class='ident'>c_int</span> <span class='op'>=</span> <span class='number'>0</span>; + +<span class='kw'>static</span> <span class='kw-2'>mut</span> <span class='ident'>MUTEXES</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Mutex</span><span class='op'><</span>()<span class='op'>>></span> <span class='op'>=</span> <span class='number'>0</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Mutex</span><span class='op'><</span>()<span class='op'>>></span>; +<span class='kw'>static</span> <span class='kw-2'>mut</span> <span class='ident'>GUARDS</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>Vec</span><span class='op'><</span><span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>MutexGuard</span><span class='op'><</span><span class='lifetime'>'static</span>, ()<span class='op'>>></span><span class='op'>></span> <span class='op'>=</span> <span class='number'>0</span> <span class='kw'>as</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>Vec</span><span class='op'><</span><span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>MutexGuard</span><span class='op'><</span><span class='lifetime'>'static</span>, ()<span class='op'>>></span><span class='op'>></span>; + +<span class='kw'>extern</span> <span class='kw'>fn</span> <span class='ident'>locking_function</span>(<span class='ident'>mode</span>: <span class='ident'>c_int</span>, <span class='ident'>n</span>: <span class='ident'>c_int</span>, <span class='ident'>_file</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>_line</span>: <span class='ident'>c_int</span>) { + <span class='kw'>unsafe</span> { + <span class='kw'>let</span> <span class='ident'>mutex</span> <span class='op'>=</span> <span class='kw-2'>&</span>(<span class='op'>*</span><span class='ident'>MUTEXES</span>)[<span class='ident'>n</span> <span class='kw'>as</span> <span class='ident'>usize</span>]; + + <span class='kw'>if</span> <span class='ident'>mode</span> <span class='kw-2'>&</span> <span class='ident'>CRYPTO_LOCK</span> <span class='op'>!=</span> <span class='number'>0</span> { + (<span class='op'>*</span><span class='ident'>GUARDS</span>)[<span class='ident'>n</span> <span class='kw'>as</span> <span class='ident'>usize</span>] <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>mutex</span>.<span class='ident'>lock</span>().<span class='ident'>unwrap</span>()); + } <span class='kw'>else</span> { + <span class='kw-2'>&</span>(<span class='op'>*</span><span class='ident'>GUARDS</span>)[<span class='ident'>n</span> <span class='kw'>as</span> <span class='ident'>usize</span>].<span class='ident'>take</span>(); + } + } +} + +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>init</span>() { + <span class='kw'>static</span> <span class='kw-2'>mut</span> <span class='ident'>INIT</span>: <span class='ident'>Once</span> <span class='op'>=</span> <span class='ident'>ONCE_INIT</span>; + + <span class='kw'>unsafe</span> { + <span class='ident'>INIT</span>.<span class='ident'>call_once</span>(<span class='op'>||</span> { + <span class='ident'>SSL_library_init</span>(); + <span class='ident'>SSL_load_error_strings</span>(); + + <span class='kw'>let</span> <span class='ident'>num_locks</span> <span class='op'>=</span> <span class='ident'>CRYPTO_num_locks</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>mutexes</span> <span class='op'>=</span> <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>Vec</span>::<span class='ident'>new</span>()); + <span class='kw'>for</span> _ <span class='kw'>in</span> <span class='number'>0</span>..<span class='ident'>num_locks</span> { + <span class='ident'>mutexes</span>.<span class='ident'>push</span>(<span class='ident'>Mutex</span>::<span class='ident'>new</span>(())); + } + <span class='ident'>MUTEXES</span> <span class='op'>=</span> <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='ident'>mutexes</span>); + <span class='kw'>let</span> <span class='ident'>guards</span>: <span class='ident'>Box</span><span class='op'><</span><span class='ident'>Vec</span><span class='op'><</span><span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>MutexGuard</span><span class='op'><</span>()<span class='op'>>></span><span class='op'>>></span> <span class='op'>=</span> + <span class='ident'>Box</span>::<span class='ident'>new</span>((<span class='number'>0</span>..<span class='ident'>num_locks</span>).<span class='ident'>map</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='prelude-val'>None</span>).<span class='ident'>collect</span>()); + <span class='ident'>GUARDS</span> <span class='op'>=</span> <span class='ident'>mem</span>::<span class='ident'>transmute</span>(<span class='ident'>guards</span>); + + <span class='ident'>CRYPTO_set_locking_callback</span>(<span class='ident'>locking_function</span>); + }) + } +} + +<span class='comment'>// Functions converted from macros</span> +<span class='kw'>pub</span> <span class='kw'>unsafe</span> <span class='kw'>fn</span> <span class='ident'>BIO_eof</span>(<span class='ident'>b</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIO</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='ident'>BIO_ctrl</span>(<span class='ident'>b</span>, <span class='ident'>BIO_CTRL_EOF</span>, <span class='number'>0</span>, <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>()) <span class='op'>==</span> <span class='number'>1</span> +} + +<span class='kw'>pub</span> <span class='kw'>unsafe</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_set_options</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>, <span class='ident'>op</span>: <span class='ident'>c_long</span>) <span class='op'>-></span> <span class='ident'>c_long</span> { + <span class='ident'>SSL_CTX_ctrl</span>(<span class='ident'>ssl</span>, <span class='ident'>SSL_CTRL_OPTIONS</span>, <span class='ident'>op</span>, <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>()) +} + +<span class='kw'>pub</span> <span class='kw'>unsafe</span> <span class='kw'>fn</span> <span class='ident'>BIO_set_mem_eof_return</span>(<span class='ident'>b</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIO</span>, <span class='ident'>v</span>: <span class='ident'>c_int</span>) { + <span class='ident'>BIO_ctrl</span>(<span class='ident'>b</span>, <span class='ident'>BIO_C_SET_BUF_MEM_EOF_RETURN</span>, <span class='ident'>v</span> <span class='kw'>as</span> <span class='ident'>c_long</span>, <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>()); +} + +<span class='kw'>pub</span> <span class='kw'>unsafe</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_get_options</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>) <span class='op'>-></span> <span class='ident'>c_long</span> { + <span class='ident'>SSL_CTX_ctrl</span>(<span class='ident'>ssl</span>, <span class='ident'>SSL_CTRL_OPTIONS</span>, <span class='number'>0</span>, <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>()) +} + +<span class='kw'>pub</span> <span class='kw'>unsafe</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_clear_options</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>, <span class='ident'>op</span>: <span class='ident'>c_long</span>) <span class='op'>-></span> <span class='ident'>c_long</span> { + <span class='ident'>SSL_CTX_ctrl</span>(<span class='ident'>ssl</span>, <span class='ident'>SSL_CTRL_CLEAR_OPTIONS</span>, (<span class='ident'>op</span>), <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>()) +} + +<span class='kw'>pub</span> <span class='kw'>unsafe</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_add_extra_chain_cert</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>, <span class='ident'>cert</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>) <span class='op'>-></span> <span class='ident'>c_long</span> { + <span class='ident'>SSL_CTX_ctrl</span>(<span class='ident'>ssl</span>, <span class='ident'>SSL_CTRL_EXTRA_CHAIN_CERT</span>, <span class='number'>0</span>, <span class='ident'>cert</span>) +} + +<span class='kw'>pub</span> <span class='kw'>unsafe</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_set_read_ahead</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>, <span class='ident'>m</span>: <span class='ident'>c_long</span>) <span class='op'>-></span> <span class='ident'>c_long</span> { + <span class='ident'>SSL_CTX_ctrl</span>(<span class='ident'>ctx</span>, <span class='ident'>SSL_CTRL_SET_READ_AHEAD</span>, <span class='ident'>m</span>, <span class='ident'>ptr</span>::<span class='ident'>null_mut</span>()) +} + +<span class='comment'>// True functions</span> +<span class='kw'>extern</span> <span class='string'>"C"</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ASN1_INTEGER_set</span>(<span class='ident'>dest</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ASN1_INTEGER</span>, <span class='ident'>value</span>: <span class='ident'>c_long</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ASN1_STRING_type_new</span>(<span class='ident'>ty</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ASN1_STRING</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ASN1_TIME_free</span>(<span class='ident'>tm</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ASN1_TIME</span>); + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BIO_ctrl</span>(<span class='ident'>b</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIO</span>, <span class='ident'>cmd</span>: <span class='ident'>c_int</span>, <span class='ident'>larg</span>: <span class='ident'>c_long</span>, <span class='ident'>parg</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>) <span class='op'>-></span> <span class='ident'>c_long</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BIO_free_all</span>(<span class='ident'>b</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIO</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BIO_new</span>(<span class='ident'>type_</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>BIO_METHOD</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIO</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BIO_read</span>(<span class='ident'>b</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIO</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BIO_write</span>(<span class='ident'>b</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIO</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>len</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BIO_s_mem</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>BIO_METHOD</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_new</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_dup</span>(<span class='ident'>n</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_clear_free</span>(<span class='ident'>bn</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>); + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_CTX_new</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BN_CTX</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_CTX_free</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BN_CTX</span>); + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_num_bits</span>(<span class='ident'>bn</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_set_negative</span>(<span class='ident'>bn</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>n</span>: <span class='ident'>c_int</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_set_word</span>(<span class='ident'>bn</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>n</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='comment'>/* Arithmetic operations on BIGNUMs */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_add</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>b</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_div</span>(<span class='ident'>dv</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>rem</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>b</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BN_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_exp</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>p</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BN_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_gcd</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>b</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BN_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_mod_add</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>b</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>m</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BN_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_mod_exp</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>p</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>m</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BN_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_mod_inverse</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>n</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BN_CTX</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>BIGNUM</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_mod_mul</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>b</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>m</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BN_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_mod_sqr</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>m</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BN_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_mod_sub</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>b</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>m</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BN_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_mul</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>b</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BN_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_nnmod</span>(<span class='ident'>rem</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>m</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BN_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_add_word</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>w</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_sub_word</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>w</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_mul_word</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>w</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_div_word</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>w</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='ident'>c_ulong</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_mod_word</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>BIGNUM</span>, <span class='ident'>w</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='ident'>c_ulong</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_sqr</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BN_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_sub</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>b</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='comment'>/* Bit operations on BIGNUMs */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_clear_bit</span>(<span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>n</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_is_bit_set</span>(<span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>n</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_lshift</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>n</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_lshift1</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_mask_bits</span>(<span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>n</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_rshift</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>n</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_set_bit</span>(<span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>n</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_rshift1</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='comment'>/* Comparisons on BIGNUMs */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_cmp</span>(<span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>b</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_ucmp</span>(<span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>b</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='comment'>/* Prime handling */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_generate_prime_ex</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>bits</span>: <span class='ident'>c_int</span>, <span class='ident'>safe</span>: <span class='ident'>c_int</span>, <span class='ident'>add</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>rem</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>cb</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_is_prime_ex</span>(<span class='ident'>p</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>checks</span>: <span class='ident'>c_int</span>, <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BN_CTX</span>, <span class='ident'>cb</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_is_prime_fasttest_ex</span>(<span class='ident'>p</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>checks</span>: <span class='ident'>c_int</span>, <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BN_CTX</span>, <span class='ident'>do_trial_division</span>: <span class='ident'>c_int</span>, <span class='ident'>cb</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='comment'>/* Random number handling */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_rand</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>bits</span>: <span class='ident'>c_int</span>, <span class='ident'>top</span>: <span class='ident'>c_int</span>, <span class='ident'>bottom</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_pseudo_rand</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>bits</span>: <span class='ident'>c_int</span>, <span class='ident'>top</span>: <span class='ident'>c_int</span>, <span class='ident'>bottom</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_rand_range</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>range</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_pseudo_rand_range</span>(<span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>range</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='comment'>/* Conversion from/to binary representation */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_bin2bn</span>(<span class='ident'>s</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>u8</span>, <span class='ident'>size</span>: <span class='ident'>c_int</span>, <span class='ident'>ret</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_bn2bin</span>(<span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>to</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>u8</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='comment'>/* Conversion from/to decimal string representation */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_dec2bn</span>(<span class='ident'>a</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>s</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_bn2dec</span>(<span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>; + + <span class='comment'>/* Conversion from/to hexidecimal string representation */</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_hex2bn</span>(<span class='ident'>a</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>, <span class='ident'>s</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>BN_bn2hex</span>(<span class='ident'>a</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIGNUM</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>CRYPTO_num_locks</span>() <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>CRYPTO_set_locking_callback</span>(<span class='ident'>func</span>: <span class='kw'>extern</span> <span class='string'>"C"</span> <span class='kw'>fn</span>(<span class='ident'>mode</span>: <span class='ident'>c_int</span>, + <span class='ident'>n</span>: <span class='ident'>c_int</span>, + <span class='ident'>file</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>line</span>: <span class='ident'>c_int</span>)); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>CRYPTO_free</span>(<span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>CRYPTO_memcmp</span>(<span class='ident'>a</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>b</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, + <span class='ident'>len</span>: <span class='ident'>size_t</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ERR_get_error</span>() <span class='op'>-></span> <span class='ident'>c_ulong</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ERR_lib_error_string</span>(<span class='ident'>err</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ERR_func_error_string</span>(<span class='ident'>err</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ERR_reason_error_string</span>(<span class='ident'>err</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ERR_load_crypto_strings</span>(); + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_md5</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_MD</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_ripemd160</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_MD</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_sha1</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_MD</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_sha224</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_MD</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_sha256</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_MD</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_sha384</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_MD</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_sha512</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_MD</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_aes_128_cbc</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_CIPHER</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_aes_128_ecb</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_CIPHER</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"aes_xts"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_aes_128_xts</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_CIPHER</span>; + <span class='comment'>// fn EVP_aes_128_ctr() -> EVP_CIPHER;</span> + <span class='comment'>// fn EVP_aes_128_gcm() -> EVP_CIPHER;</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_aes_256_cbc</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_CIPHER</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_aes_256_ecb</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_CIPHER</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"aes_xts"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_aes_256_xts</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_CIPHER</span>; + <span class='comment'>// fn EVP_aes_256_ctr() -> EVP_CIPHER;</span> + <span class='comment'>// fn EVP_aes_256_gcm() -> EVP_CIPHER;</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_rc4</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_CIPHER</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_CIPHER_CTX_new</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_CIPHER_CTX</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_CIPHER_CTX_set_padding</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_CIPHER_CTX</span>, <span class='ident'>padding</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_CIPHER_CTX_free</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_CIPHER_CTX</span>); + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_CipherInit</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_CIPHER_CTX</span>, <span class='ident'>evp</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_CIPHER</span>, + <span class='ident'>key</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>u8</span>, <span class='ident'>iv</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>u8</span>, <span class='ident'>mode</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_CipherUpdate</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_CIPHER_CTX</span>, <span class='ident'>outbuf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>u8</span>, + <span class='ident'>outlen</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>c_int</span>, <span class='ident'>inbuf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>u8</span>, <span class='ident'>inlen</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_CipherFinal</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_CIPHER_CTX</span>, <span class='ident'>res</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>u8</span>, <span class='ident'>len</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_DigestInit</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_MD_CTX</span>, <span class='ident'>typ</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_MD</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_DigestInit_ex</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_MD_CTX</span>, <span class='ident'>typ</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_MD</span>, <span class='ident'>imple</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>ENGINE</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_DigestUpdate</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_MD_CTX</span>, <span class='ident'>data</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>u8</span>, <span class='ident'>n</span>: <span class='ident'>c_uint</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_DigestFinal</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_MD_CTX</span>, <span class='ident'>res</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>u8</span>, <span class='ident'>n</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>u32</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_DigestFinal_ex</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_MD_CTX</span>, <span class='ident'>res</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>u8</span>, <span class='ident'>n</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>u32</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_MD_CTX_create</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_MD_CTX</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_MD_CTX_copy_ex</span>(<span class='ident'>dst</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_MD_CTX</span>, <span class='ident'>src</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_MD_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_MD_CTX_destroy</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_MD_CTX</span>); + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_PKEY_new</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_PKEY</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_PKEY_free</span>(<span class='ident'>k</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_PKEY</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_PKEY_assign</span>(<span class='ident'>pkey</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_PKEY</span>, <span class='ident'>typ</span>: <span class='ident'>c_int</span>, <span class='ident'>key</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_PKEY_get1_RSA</span>(<span class='ident'>k</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_PKEY</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>RSA</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_PKEY_set1_RSA</span>(<span class='ident'>k</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_PKEY</span>, <span class='ident'>r</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>RSA</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>EVP_PKEY_cmp</span>(<span class='ident'>a</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_PKEY</span>, <span class='ident'>b</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_PKEY</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>HMAC_CTX_init</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>HMAC_CTX</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>HMAC_CTX_cleanup</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>HMAC_CTX</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>HMAC_CTX_copy</span>(<span class='ident'>dst</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>HMAC_CTX</span>, <span class='ident'>src</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>HMAC_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='comment'>// Pre-1.0 versions of these didn't return anything, so the shims bridge that gap</span> + <span class='attribute'>#[<span class='ident'>cfg_attr</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>, <span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"HMAC_Init_ex"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>HMAC_Init_ex_shim</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>HMAC_CTX</span>, <span class='ident'>key</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>u8</span>, <span class='ident'>keylen</span>: <span class='ident'>c_int</span>, <span class='ident'>md</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_MD</span>, <span class='ident'>imple</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>ENGINE</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>cfg_attr</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>, <span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"HMAC_Final"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>HMAC_Final_shim</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>HMAC_CTX</span>, <span class='ident'>output</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>u8</span>, <span class='ident'>len</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_uint</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>cfg_attr</span>(<span class='ident'>target_os</span> <span class='op'>=</span> <span class='string'>"nacl"</span>, <span class='ident'>link_name</span> <span class='op'>=</span> <span class='string'>"HMAC_Update"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>HMAC_Update_shim</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>HMAC_CTX</span>, <span class='ident'>input</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>u8</span>, <span class='ident'>len</span>: <span class='ident'>c_uint</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>PEM_read_bio_X509</span>(<span class='ident'>bio</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIO</span>, <span class='ident'>out</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>, <span class='ident'>callback</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>PasswordCallback</span><span class='op'>></span>, + <span class='ident'>user_data</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>PEM_read_bio_X509_REQ</span>(<span class='ident'>bio</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIO</span>, <span class='ident'>out</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_REQ</span>, <span class='ident'>callback</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>PasswordCallback</span><span class='op'>></span>, + <span class='ident'>user_data</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_REQ</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>PEM_read_bio_PrivateKey</span>(<span class='ident'>bio</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIO</span>, <span class='ident'>out</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_PKEY</span>, <span class='ident'>callback</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>PasswordCallback</span><span class='op'>></span>, + <span class='ident'>user_data</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>PEM_write_bio_PrivateKey</span>(<span class='ident'>bio</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIO</span>, <span class='ident'>pkey</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_PKEY</span>, <span class='ident'>cipher</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_CIPHER</span>, + <span class='ident'>kstr</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, <span class='ident'>klen</span>: <span class='ident'>c_int</span>, + <span class='ident'>callback</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>PasswordCallback</span><span class='op'>></span>, + <span class='ident'>user_data</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>PEM_write_bio_X509</span>(<span class='ident'>bio</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIO</span>, <span class='ident'>x509</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>PEM_write_bio_X509_REQ</span>(<span class='ident'>bio</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIO</span>, <span class='ident'>x509</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_REQ</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>PKCS5_PBKDF2_HMAC_SHA1</span>(<span class='ident'>pass</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>u8</span>, <span class='ident'>passlen</span>: <span class='ident'>c_int</span>, + <span class='ident'>salt</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>u8</span>, <span class='ident'>saltlen</span>: <span class='ident'>c_int</span>, + <span class='ident'>iter</span>: <span class='ident'>c_int</span>, <span class='ident'>keylen</span>: <span class='ident'>c_int</span>, + <span class='ident'>out</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>u8</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>RAND_bytes</span>(<span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>u8</span>, <span class='ident'>num</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>RSA_generate_key</span>(<span class='ident'>modsz</span>: <span class='ident'>c_int</span>, <span class='ident'>e</span>: <span class='ident'>c_ulong</span>, <span class='ident'>cb</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>cbarg</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>RSA</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>RSA_private_decrypt</span>(<span class='ident'>flen</span>: <span class='ident'>c_int</span>, <span class='ident'>from</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>u8</span>, <span class='ident'>to</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>u8</span>, <span class='ident'>k</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>RSA</span>, + <span class='ident'>pad</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>RSA_public_encrypt</span>(<span class='ident'>flen</span>: <span class='ident'>c_int</span>, <span class='ident'>from</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>u8</span>, <span class='ident'>to</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>u8</span>, <span class='ident'>k</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>RSA</span>, + <span class='ident'>pad</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>RSA_sign</span>(<span class='ident'>t</span>: <span class='ident'>c_int</span>, <span class='ident'>m</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>u8</span>, <span class='ident'>mlen</span>: <span class='ident'>c_uint</span>, <span class='ident'>sig</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>u8</span>, <span class='ident'>siglen</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_uint</span>, + <span class='ident'>k</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>RSA</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>RSA_size</span>(<span class='ident'>k</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>RSA</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>RSA_verify</span>(<span class='ident'>t</span>: <span class='ident'>c_int</span>, <span class='ident'>m</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>u8</span>, <span class='ident'>mlen</span>: <span class='ident'>c_uint</span>, <span class='ident'>sig</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>u8</span>, <span class='ident'>siglen</span>: <span class='ident'>c_uint</span>, + <span class='ident'>k</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>RSA</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_library_init</span>() <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_load_error_strings</span>(); + + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"sslv2"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSLv2_method</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>SSL_METHOD</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSLv3_method</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>SSL_METHOD</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>TLSv1_method</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>SSL_METHOD</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"tlsv1_1"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>TLSv1_1_method</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>SSL_METHOD</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"tlsv1_2"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>TLSv1_2_method</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>SSL_METHOD</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"dtlsv1"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>DTLSv1_method</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>SSL_METHOD</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"dtlsv1_2"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>DTLSv1_2_method</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>SSL_METHOD</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSLv23_method</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>SSL_METHOD</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_new</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_pending</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>SSL</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_free</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_set_bio</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL</span>, <span class='ident'>rbio</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIO</span>, <span class='ident'>wbio</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIO</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_get_rbio</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIO</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_get_wbio</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>BIO</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_accept</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_connect</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_ctrl</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL</span>, <span class='ident'>cmd</span>: <span class='ident'>c_int</span>, <span class='ident'>larg</span>: <span class='ident'>c_long</span>, + <span class='ident'>parg</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>) <span class='op'>-></span> <span class='ident'>c_long</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_get_error</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL</span>, <span class='ident'>ret</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_read</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>num</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_write</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, <span class='ident'>num</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_get_ex_data_X509_STORE_CTX_idx</span>() <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_get_SSL_CTX</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_get_current_compression</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>COMP_METHOD</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_get_peer_certificate</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_COMP_get_name</span>(<span class='ident'>comp</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>COMP_METHOD</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_new</span>(<span class='ident'>method</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>SSL_METHOD</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_free</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_set_verify</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>, <span class='ident'>mode</span>: <span class='ident'>c_int</span>, + <span class='ident'>verify_callback</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw'>extern</span> <span class='kw'>fn</span>(<span class='ident'>c_int</span>, <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_STORE_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span><span class='op'>></span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_set_verify_depth</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>, <span class='ident'>depth</span>: <span class='ident'>c_int</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_load_verify_locations</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>, <span class='ident'>CAfile</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, + <span class='ident'>CApath</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_get_ex_new_index</span>(<span class='ident'>argl</span>: <span class='ident'>c_long</span>, <span class='ident'>argp</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_void</span>, + <span class='ident'>new_func</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CRYPTO_EX_new</span><span class='op'>></span>, + <span class='ident'>dup_func</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CRYPTO_EX_dup</span><span class='op'>></span>, + <span class='ident'>free_func</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CRYPTO_EX_free</span><span class='op'>></span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_set_ex_data</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>, <span class='ident'>idx</span>: <span class='ident'>c_int</span>, <span class='ident'>data</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>) + <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_get_ex_data</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>, <span class='ident'>idx</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_use_certificate_file</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>, <span class='ident'>cert_file</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>file_type</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_use_certificate</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>, <span class='ident'>cert</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_use_PrivateKey_file</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>, <span class='ident'>key_file</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>file_type</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_use_PrivateKey</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>, <span class='ident'>key</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_PKEY</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_check_private_key</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_set_cipher_list</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>, <span class='ident'>s</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_ctrl</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>, <span class='ident'>cmd</span>: <span class='ident'>c_int</span>, <span class='ident'>larg</span>: <span class='ident'>c_long</span>, <span class='ident'>parg</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>) <span class='op'>-></span> <span class='ident'>c_long</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"npn"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_set_next_protos_advertised_cb</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>, + <span class='ident'>cb</span>: <span class='kw'>extern</span> <span class='string'>"C"</span> <span class='kw'>fn</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL</span>, + <span class='ident'>out</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_uchar</span>, + <span class='ident'>outlen</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_uint</span>, + <span class='ident'>arg</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>) <span class='op'>-></span> <span class='ident'>c_int</span>, + <span class='ident'>arg</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>); + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"npn"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_CTX_set_next_proto_select_cb</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL_CTX</span>, + <span class='ident'>cb</span>: <span class='kw'>extern</span> <span class='string'>"C"</span> <span class='kw'>fn</span>(<span class='ident'>ssl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>SSL</span>, + <span class='ident'>out</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_uchar</span>, + <span class='ident'>outlen</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_uchar</span>, + <span class='ident'>inbuf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_uchar</span>, + <span class='ident'>inlen</span>: <span class='ident'>c_uint</span>, + <span class='ident'>arg</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>) <span class='op'>-></span> <span class='ident'>c_int</span>, + <span class='ident'>arg</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>); + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"npn"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_select_next_proto</span>(<span class='ident'>out</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_uchar</span>, <span class='ident'>outlen</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_uchar</span>, + <span class='ident'>inbuf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_uchar</span>, <span class='ident'>inlen</span>: <span class='ident'>c_uint</span>, + <span class='ident'>client</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_uchar</span>, <span class='ident'>client_len</span>: <span class='ident'>c_uint</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"npn"</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>SSL_get0_next_proto_negotiated</span>(<span class='ident'>s</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>SSL</span>, <span class='ident'>data</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_uchar</span>, <span class='ident'>len</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_uint</span>); + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_add_ext</span>(<span class='ident'>x</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>, <span class='ident'>ext</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_EXTENSION</span>, <span class='ident'>loc</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_digest</span>(<span class='ident'>x</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>, <span class='ident'>digest</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_MD</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, <span class='ident'>len</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_uint</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_free</span>(<span class='ident'>x</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_REQ_free</span>(<span class='ident'>x</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_REQ</span>); + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_get_serialNumber</span>(<span class='ident'>x</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ASN1_INTEGER</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_get_subject_name</span>(<span class='ident'>x</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_NAME</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_gmtime_adj</span>(<span class='ident'>time</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ASN1_TIME</span>, <span class='ident'>adj</span>: <span class='ident'>c_long</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ASN1_TIME</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_new</span>() <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_set_issuer_name</span>(<span class='ident'>x</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>, <span class='ident'>name</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_NAME</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_set_notAfter</span>(<span class='ident'>x</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>, <span class='ident'>tm</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>ASN1_TIME</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_set_notBefore</span>(<span class='ident'>x</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>, <span class='ident'>tm</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>ASN1_TIME</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_set_version</span>(<span class='ident'>x</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>, <span class='ident'>version</span>: <span class='ident'>c_ulong</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_set_pubkey</span>(<span class='ident'>x</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>, <span class='ident'>pkey</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_PKEY</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_sign</span>(<span class='ident'>x</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>, <span class='ident'>pkey</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_PKEY</span>, <span class='ident'>md</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_MD</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_get_pubkey</span>(<span class='ident'>x</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_PKEY</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_to_X509_REQ</span>(<span class='ident'>x</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>, <span class='ident'>pkey</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>EVP_PKEY</span>, <span class='ident'>md</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>EVP_MD</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_REQ</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_EXTENSION_free</span>(<span class='ident'>ext</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_EXTENSION</span>); + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_NAME_add_entry_by_txt</span>(<span class='ident'>x</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>, <span class='ident'>field</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>ty</span>: <span class='ident'>c_int</span>, <span class='ident'>bytes</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>c_char</span>, <span class='ident'>len</span>: <span class='ident'>c_int</span>, <span class='ident'>loc</span>: <span class='ident'>c_int</span>, <span class='ident'>set</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_NAME_get_index_by_NID</span>(<span class='ident'>n</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_NAME</span>, <span class='ident'>nid</span>: <span class='ident'>c_int</span>, <span class='ident'>last_pos</span>: <span class='ident'>c_int</span>) <span class='op'>-></span><span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_NAME_get_entry</span>(<span class='ident'>n</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_NAME</span>, <span class='ident'>loc</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_NAME_ENTRY</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_NAME_ENTRY_get_data</span>(<span class='ident'>ne</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_NAME_ENTRY</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ASN1_STRING</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>ASN1_STRING_to_UTF8</span>(<span class='ident'>out</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>, <span class='ident'>s</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>ASN1_STRING</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_STORE_CTX_get_current_cert</span>(<span class='ident'>ct</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_STORE_CTX</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_STORE_CTX_get_error</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_STORE_CTX</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509_STORE_CTX_get_ex_data</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_STORE_CTX</span>, <span class='ident'>idx</span>: <span class='ident'>c_int</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>; + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509V3_EXT_conf_nid</span>(<span class='ident'>conf</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_void</span>, <span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509V3_CTX</span>, <span class='ident'>ext_nid</span>: <span class='ident'>c_int</span>, <span class='ident'>value</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>c_char</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_EXTENSION</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>X509V3_set_ctx</span>(<span class='ident'>ctx</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509V3_CTX</span>, <span class='ident'>issuer</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>, <span class='ident'>subject</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509</span>, <span class='ident'>req</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_REQ</span>, <span class='ident'>crl</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>X509_CRL</span>, <span class='ident'>flags</span>: <span class='ident'>c_int</span>); + + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>i2d_RSA_PUBKEY</span>(<span class='ident'>k</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>RSA</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>u8</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>d2i_RSA_PUBKEY</span>(<span class='ident'>k</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>RSA</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>u8</span>, <span class='ident'>len</span>: <span class='ident'>c_uint</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>RSA</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>i2d_RSAPrivateKey</span>(<span class='ident'>k</span>: <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>RSA</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>u8</span>) <span class='op'>-></span> <span class='ident'>c_int</span>; + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>d2i_RSAPrivateKey</span>(<span class='ident'>k</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>RSA</span>, <span class='ident'>buf</span>: <span class='op'>*</span><span class='kw'>const</span> <span class='op'>*</span><span class='kw'>const</span> <span class='ident'>u8</span>, <span class='ident'>len</span>: <span class='ident'>c_uint</span>) <span class='op'>-></span> <span class='op'>*</span><span class='kw-2'>mut</span> <span class='ident'>RSA</span>; +} + +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>probe</span>; +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl_sys"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/openssl_sys/probe.rs.html b/src/openssl_sys/probe.rs.html new file mode 100644 index 0000000..402d897 --- /dev/null +++ b/src/openssl_sys/probe.rs.html @@ -0,0 +1,243 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/openssl-sys-0.6.3/src/probe.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>probe.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10">10</span> +<span id="11">11</span> +<span id="12">12</span> +<span id="13">13</span> +<span id="14">14</span> +<span id="15">15</span> +<span id="16">16</span> +<span id="17">17</span> +<span id="18">18</span> +<span id="19">19</span> +<span id="20">20</span> +<span id="21">21</span> +<span id="22">22</span> +<span id="23">23</span> +<span id="24">24</span> +<span id="25">25</span> +<span id="26">26</span> +<span id="27">27</span> +<span id="28">28</span> +<span id="29">29</span> +<span id="30">30</span> +<span id="31">31</span> +<span id="32">32</span> +<span id="33">33</span> +<span id="34">34</span> +<span id="35">35</span> +<span id="36">36</span> +<span id="37">37</span> +<span id="38">38</span> +<span id="39">39</span> +<span id="40">40</span> +<span id="41">41</span> +<span id="42">42</span> +<span id="43">43</span> +<span id="44">44</span> +<span id="45">45</span> +<span id="46">46</span> +<span id="47">47</span> +<span id="48">48</span> +<span id="49">49</span> +<span id="50">50</span> +<span id="51">51</span> +<span id="52">52</span> +<span id="53">53</span> +<span id="54">54</span> +<span id="55">55</span> +<span id="56">56</span> +<span id="57">57</span> +<span id="58">58</span> +<span id="59">59</span> +<span id="60">60</span> +<span id="61">61</span> +<span id="62">62</span> +<span id="63">63</span> +<span id="64">64</span> +<span id="65">65</span> +<span id="66">66</span> +<span id="67">67</span> +<span id="68">68</span> +<span id="69">69</span> +<span id="70">70</span> +<span id="71">71</span> +<span id="72">72</span> +<span id="73">73</span> +</pre><pre class='rust '> +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>env</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>fs</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>path</span>::<span class='ident'>PathBuf</span>; + +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ProbeResult</span> { + <span class='kw'>pub</span> <span class='ident'>cert_file</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>PathBuf</span><span class='op'>></span>, + <span class='kw'>pub</span> <span class='ident'>cert_dir</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>PathBuf</span><span class='op'>></span>, +} + +<span class='doccomment'>/// Probe the system for the directory in which CA certificates should likely be</span> +<span class='doccomment'>/// found.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This will only search known system locations.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>find_certs_dirs</span>() <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>PathBuf</span><span class='op'>></span> { + <span class='comment'>// see http://gagravarr.org/writing/openssl-certs/others.shtml</span> + [ + <span class='string'>"/var/ssl"</span>, + <span class='string'>"/usr/share/ssl"</span>, + <span class='string'>"/usr/local/ssl"</span>, + <span class='string'>"/usr/local/openssl"</span>, + <span class='string'>"/usr/local/share"</span>, + <span class='string'>"/usr/lib/ssl"</span>, + <span class='string'>"/usr/ssl"</span>, + <span class='string'>"/etc/openssl"</span>, + <span class='string'>"/etc/pki/tls"</span>, + <span class='string'>"/etc/ssl"</span>, + ].<span class='ident'>iter</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>s</span><span class='op'>|</span> <span class='ident'>PathBuf</span>::<span class='ident'>from</span>(<span class='op'>*</span><span class='ident'>s</span>)).<span class='ident'>filter</span>(<span class='op'>|</span><span class='ident'>p</span><span class='op'>|</span> { + <span class='ident'>fs</span>::<span class='ident'>metadata</span>(<span class='ident'>p</span>).<span class='ident'>is_ok</span>() + }).<span class='ident'>collect</span>() +} + +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>init_ssl_cert_env_vars</span>() { + <span class='kw'>let</span> <span class='ident'>ProbeResult</span> { <span class='ident'>cert_file</span>, <span class='ident'>cert_dir</span> } <span class='op'>=</span> <span class='ident'>probe</span>(); + <span class='kw'>match</span> <span class='ident'>cert_file</span> { + <span class='prelude-val'>Some</span>(<span class='ident'>path</span>) <span class='op'>=></span> <span class='ident'>put</span>(<span class='string'>"SSL_CERT_FILE"</span>, <span class='ident'>path</span>), + <span class='prelude-val'>None</span> <span class='op'>=></span> {} + } + <span class='kw'>match</span> <span class='ident'>cert_dir</span> { + <span class='prelude-val'>Some</span>(<span class='ident'>path</span>) <span class='op'>=></span> <span class='ident'>put</span>(<span class='string'>"SSL_CERT_DIR"</span>, <span class='ident'>path</span>), + <span class='prelude-val'>None</span> <span class='op'>=></span> {} + } + + <span class='kw'>fn</span> <span class='ident'>put</span>(<span class='ident'>var</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>path</span>: <span class='ident'>PathBuf</span>) { + <span class='comment'>// Don't stomp over what anyone else has set</span> + <span class='kw'>match</span> <span class='ident'>env</span>::<span class='ident'>var</span>(<span class='ident'>var</span>) { + <span class='prelude-val'>Ok</span>(..) <span class='op'>=></span> {} + <span class='prelude-val'>Err</span>(..) <span class='op'>=></span> <span class='ident'>env</span>::<span class='ident'>set_var</span>(<span class='ident'>var</span>, <span class='kw-2'>&</span><span class='ident'>path</span>), + } + } +} + +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>probe</span>() <span class='op'>-></span> <span class='ident'>ProbeResult</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>result</span> <span class='op'>=</span> <span class='ident'>ProbeResult</span> { + <span class='ident'>cert_file</span>: <span class='ident'>env</span>::<span class='ident'>var_os</span>(<span class='string'>"SSL_CERT_FILE"</span>).<span class='ident'>map</span>(<span class='ident'>PathBuf</span>::<span class='ident'>from</span>), + <span class='ident'>cert_dir</span>: <span class='ident'>env</span>::<span class='ident'>var_os</span>(<span class='string'>"SSL_CERT_DIR"</span>).<span class='ident'>map</span>(<span class='ident'>PathBuf</span>::<span class='ident'>from</span>), + }; + <span class='kw'>for</span> <span class='ident'>certs_dir</span> <span class='kw'>in</span> <span class='ident'>find_certs_dirs</span>().<span class='ident'>iter</span>() { + <span class='comment'>// cert.pem looks to be an openssl 1.0.1 thing, while</span> + <span class='comment'>// certs/ca-certificates.crt appears to be a 0.9.8 thing</span> + <span class='ident'>try</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>result</span>.<span class='ident'>cert_file</span>, <span class='ident'>certs_dir</span>.<span class='ident'>join</span>(<span class='string'>"cert.pem"</span>)); + <span class='ident'>try</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>result</span>.<span class='ident'>cert_file</span>, <span class='ident'>certs_dir</span>.<span class='ident'>join</span>(<span class='string'>"certs/ca-certificates.crt"</span>)); + <span class='ident'>try</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>result</span>.<span class='ident'>cert_file</span>, <span class='ident'>certs_dir</span>.<span class='ident'>join</span>(<span class='string'>"certs/ca-root-nss.crt"</span>)); + + <span class='ident'>try</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>result</span>.<span class='ident'>cert_dir</span>, <span class='ident'>certs_dir</span>.<span class='ident'>join</span>(<span class='string'>"certs"</span>)); + } + <span class='ident'>result</span> +} + +<span class='kw'>fn</span> <span class='ident'>try</span>(<span class='ident'>dst</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>PathBuf</span><span class='op'>></span>, <span class='ident'>val</span>: <span class='ident'>PathBuf</span>) { + <span class='kw'>if</span> <span class='ident'>dst</span>.<span class='ident'>is_none</span>() <span class='op'>&&</span> <span class='ident'>fs</span>::<span class='ident'>metadata</span>(<span class='kw-2'>&</span><span class='ident'>val</span>).<span class='ident'>is_ok</span>() { + <span class='op'>*</span><span class='ident'>dst</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>val</span>); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "openssl_sys"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/pkg_config/lib.rs.html b/src/pkg_config/lib.rs.html new file mode 100644 index 0000000..250138e --- /dev/null +++ b/src/pkg_config/lib.rs.html @@ -0,0 +1,679 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/pkg-config-0.3.5/src/lib.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>lib.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +</pre><pre class='rust '> +<span class='doccomment'>//! A build dependency for Cargo libraries to find system artifacts through the</span> +<span class='doccomment'>//! `pkg-config` utility.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! This library will shell out to `pkg-config` as part of build scripts and</span> +<span class='doccomment'>//! probe the system to determine how to link to a specified library. The</span> +<span class='doccomment'>//! `Config` structure serves as a method of configuring how `pkg-config` is</span> +<span class='doccomment'>//! invoked in a builder style.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! A number of environment variables are available to globally configure how</span> +<span class='doccomment'>//! this crate will invoke `pkg-config`:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! * `PKG_CONFIG_ALLOW_CROSS` - if this variable is not set, then `pkg-config`</span> +<span class='doccomment'>//! will automatically be disabled for all cross compiles.</span> +<span class='doccomment'>//! * `FOO_NO_PKG_CONFIG` - if set, this will disable running `pkg-config` when</span> +<span class='doccomment'>//! probing for the library named `foo`.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! There are also a number of environment variables which can configure how a</span> +<span class='doccomment'>//! library is linked to (dynamically vs statically). These variables control</span> +<span class='doccomment'>//! whether the `--static` flag is passed. Note that this behavior can be</span> +<span class='doccomment'>//! overridden by configuring explicitly on `Config`. The variables are checked</span> +<span class='doccomment'>//! in the following order:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! * `FOO_STATIC` - pass `--static` for the library `foo`</span> +<span class='doccomment'>//! * `FOO_DYNAMIC` - do not pass `--static` for the library `foo`</span> +<span class='doccomment'>//! * `PKG_CONFIG_ALL_STATIC` - pass `--static` for all libraries</span> +<span class='doccomment'>//! * `PKG_CONFIG_ALL_DYNAMIC` - do not pass `--static` for all libraries</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! After running `pkg-config` all appropriate Cargo metadata will be printed on</span> +<span class='doccomment'>//! stdout if the search was successful.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # Example</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Find the system library named `foo`.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```no_run</span> +<span class='doccomment'>//! extern crate pkg_config;</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! fn main() {</span> +<span class='doccomment'>//! pkg_config::find_library("foo").unwrap();</span> +<span class='doccomment'>//! }</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Configure how library `foo` is linked to.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```no_run</span> +<span class='doccomment'>//! extern crate pkg_config;</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! fn main() {</span> +<span class='doccomment'>//! pkg_config::Config::new().statik(true).find("foo").unwrap();</span> +<span class='doccomment'>//! }</span> +<span class='doccomment'>//! ```</span> + +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>doc</span>(<span class='ident'>html_root_url</span> <span class='op'>=</span> <span class='string'>"http://alexcrichton.com/pkg-config-rs"</span>)]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>cfg_attr</span>(<span class='ident'>test</span>, <span class='ident'>deny</span>(<span class='ident'>warnings</span>))]</span> + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ascii</span>::<span class='ident'>AsciiExt</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>env</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ffi</span>::{<span class='ident'>OsStr</span>, <span class='ident'>OsString</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>fs</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>path</span>::{<span class='ident'>PathBuf</span>, <span class='ident'>Path</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>process</span>::<span class='ident'>Command</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>str</span>; + +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>target_supported</span>() <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='ident'>env</span>::<span class='ident'>var</span>(<span class='string'>"HOST"</span>) <span class='op'>==</span> <span class='ident'>env</span>::<span class='ident'>var</span>(<span class='string'>"TARGET"</span>) <span class='op'>||</span> + <span class='ident'>env</span>::<span class='ident'>var_os</span>(<span class='string'>"PKG_CONFIG_ALLOW_CROSS"</span>).<span class='ident'>is_some</span>() +} + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Config</span> { + <span class='ident'>statik</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>bool</span><span class='op'>></span>, + <span class='ident'>atleast_version</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span>, + <span class='ident'>extra_args</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>OsString</span><span class='op'>></span>, +} + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Library</span> { + <span class='kw'>pub</span> <span class='ident'>libs</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span>, + <span class='kw'>pub</span> <span class='ident'>link_paths</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>PathBuf</span><span class='op'>></span>, + <span class='kw'>pub</span> <span class='ident'>frameworks</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span>, + <span class='kw'>pub</span> <span class='ident'>framework_paths</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>PathBuf</span><span class='op'>></span>, + <span class='kw'>pub</span> <span class='ident'>include_paths</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>PathBuf</span><span class='op'>></span>, + <span class='kw'>pub</span> <span class='ident'>version</span>: <span class='ident'>String</span>, + <span class='ident'>_priv</span>: (), +} + +<span class='doccomment'>/// Simple shortcut for using all default options for finding a library.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>find_library</span>(<span class='ident'>name</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Library</span>, <span class='ident'>String</span><span class='op'>></span> { + <span class='ident'>Config</span>::<span class='ident'>new</span>().<span class='ident'>find</span>(<span class='ident'>name</span>) +} + +<span class='kw'>impl</span> <span class='ident'>Config</span> { + <span class='doccomment'>/// Creates a new set of configuration options which are all initially set</span> + <span class='doccomment'>/// to "blank".</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>() <span class='op'>-></span> <span class='ident'>Config</span> { + <span class='ident'>Config</span> { + <span class='ident'>statik</span>: <span class='prelude-val'>None</span>, + <span class='ident'>atleast_version</span>: <span class='prelude-val'>None</span>, + <span class='ident'>extra_args</span>: <span class='macro'>vec</span><span class='macro'>!</span>[], + } + } + + <span class='doccomment'>/// Indicate whether the `--static` flag should be passed.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This will override the inference from environment variables described in</span> + <span class='doccomment'>/// the crate documentation.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>statik</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>statik</span>: <span class='ident'>bool</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Config</span> { + <span class='self'>self</span>.<span class='ident'>statik</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>statik</span>); + <span class='self'>self</span> + } + + <span class='doccomment'>/// Indicate that the library must be at least version `vers`.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>atleast_version</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>vers</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Config</span> { + <span class='self'>self</span>.<span class='ident'>atleast_version</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>vers</span>.<span class='ident'>to_string</span>()); + <span class='self'>self</span> + } + + <span class='doccomment'>/// Add an argument to pass to pkg-config.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// It's placed after all of the arguments generated by this library.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>arg</span><span class='op'><</span><span class='ident'>S</span>: <span class='ident'>AsRef</span><span class='op'><</span><span class='ident'>OsStr</span><span class='op'>>></span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>arg</span>: <span class='ident'>S</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Config</span> { + <span class='self'>self</span>.<span class='ident'>extra_args</span>.<span class='ident'>push</span>(<span class='ident'>arg</span>.<span class='ident'>as_ref</span>().<span class='ident'>to_os_string</span>()); + <span class='self'>self</span> + } + + <span class='doccomment'>/// Run `pkg-config` to find the library `name`.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This will use all configuration previously set to specify how</span> + <span class='doccomment'>/// `pkg-config` is run.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>find</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Library</span>, <span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>if</span> <span class='ident'>env</span>::<span class='ident'>var_os</span>(<span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}_NO_PKG_CONFIG"</span>, <span class='ident'>envify</span>(<span class='ident'>name</span>))).<span class='ident'>is_some</span>() { + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"pkg-config requested to be aborted for {}"</span>, <span class='ident'>name</span>)) + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>target_supported</span>() { + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='string'>"pkg-config doesn't handle cross compilation. Use \ + PKG_CONFIG_ALLOW_CROSS=1 to override"</span>.<span class='ident'>to_string</span>()); + } + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>library</span> <span class='op'>=</span> <span class='ident'>Library</span>::<span class='ident'>new</span>(); + + <span class='kw'>let</span> <span class='ident'>output</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>run</span>(<span class='self'>self</span>.<span class='ident'>command</span>(<span class='ident'>name</span>, <span class='kw-2'>&</span>[<span class='string'>"--libs"</span>, <span class='string'>"--cflags"</span>]))); + <span class='ident'>library</span>.<span class='ident'>parse_libs_cflags</span>(<span class='ident'>name</span>, <span class='kw-2'>&</span><span class='ident'>output</span>, <span class='self'>self</span>); + + <span class='kw'>let</span> <span class='ident'>output</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>run</span>(<span class='self'>self</span>.<span class='ident'>command</span>(<span class='ident'>name</span>, <span class='kw-2'>&</span>[<span class='string'>"--modversion"</span>]))); + <span class='ident'>library</span>.<span class='ident'>parse_modversion</span>(<span class='kw-2'>&</span><span class='ident'>output</span>); + + <span class='prelude-val'>Ok</span>(<span class='ident'>library</span>) + } + + <span class='doccomment'>/// Run `pkg-config` to get the value of a variable from a package using</span> + <span class='doccomment'>/// --variable.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>get_variable</span>(<span class='ident'>package</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>variable</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>String</span>, <span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>arg</span> <span class='op'>=</span> <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"--variable={}"</span>, <span class='ident'>variable</span>); + <span class='kw'>let</span> <span class='ident'>cfg</span> <span class='op'>=</span> <span class='ident'>Config</span>::<span class='ident'>new</span>(); + <span class='prelude-val'>Ok</span>(<span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>run</span>(<span class='ident'>cfg</span>.<span class='ident'>command</span>(<span class='ident'>package</span>, <span class='kw-2'>&</span>[<span class='kw-2'>&</span><span class='ident'>arg</span>]))).<span class='ident'>trim_right</span>().<span class='ident'>to_owned</span>()) + } + + <span class='kw'>fn</span> <span class='ident'>is_static</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='self'>self</span>.<span class='ident'>statik</span>.<span class='ident'>unwrap_or_else</span>(<span class='op'>||</span> <span class='ident'>infer_static</span>(<span class='ident'>name</span>)) + } + + <span class='kw'>fn</span> <span class='ident'>command</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>args</span>: <span class='kw-2'>&</span>[<span class='kw-2'>&</span><span class='ident'>str</span>]) <span class='op'>-></span> <span class='ident'>Command</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>cmd</span> <span class='op'>=</span> <span class='ident'>Command</span>::<span class='ident'>new</span>(<span class='string'>"pkg-config"</span>); + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>is_static</span>(<span class='ident'>name</span>) { + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='string'>"--static"</span>); + } + <span class='ident'>cmd</span>.<span class='ident'>args</span>(<span class='ident'>args</span>) + .<span class='ident'>args</span>(<span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>extra_args</span>) + .<span class='ident'>env</span>(<span class='string'>"PKG_CONFIG_ALLOW_SYSTEM_LIBS"</span>, <span class='string'>"1"</span>); + <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>version</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>atleast_version</span> { + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{} >= {}"</span>, <span class='ident'>name</span>, <span class='ident'>version</span>)); + } <span class='kw'>else</span> { + <span class='ident'>cmd</span>.<span class='ident'>arg</span>(<span class='ident'>name</span>); + } + <span class='ident'>cmd</span> + } +} + +<span class='kw'>impl</span> <span class='ident'>Library</span> { + <span class='kw'>fn</span> <span class='ident'>new</span>() <span class='op'>-></span> <span class='ident'>Library</span> { + <span class='ident'>Library</span> { + <span class='ident'>libs</span>: <span class='ident'>Vec</span>::<span class='ident'>new</span>(), + <span class='ident'>link_paths</span>: <span class='ident'>Vec</span>::<span class='ident'>new</span>(), + <span class='ident'>include_paths</span>: <span class='ident'>Vec</span>::<span class='ident'>new</span>(), + <span class='ident'>frameworks</span>: <span class='ident'>Vec</span>::<span class='ident'>new</span>(), + <span class='ident'>framework_paths</span>: <span class='ident'>Vec</span>::<span class='ident'>new</span>(), + <span class='ident'>version</span>: <span class='ident'>String</span>::<span class='ident'>new</span>(), + <span class='ident'>_priv</span>: (), + } + } + + <span class='kw'>fn</span> <span class='ident'>parse_libs_cflags</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>output</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>config</span>: <span class='kw-2'>&</span><span class='ident'>Config</span>) { + <span class='kw'>let</span> <span class='ident'>parts</span> <span class='op'>=</span> <span class='ident'>output</span>.<span class='ident'>split</span>(<span class='string'>' '</span>) + .<span class='ident'>filter</span>(<span class='op'>|</span><span class='ident'>l</span><span class='op'>|</span> <span class='ident'>l</span>.<span class='ident'>len</span>() <span class='op'>></span> <span class='number'>2</span>) + .<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>arg</span><span class='op'>|</span> (<span class='kw-2'>&</span><span class='ident'>arg</span>[<span class='number'>0</span>..<span class='number'>2</span>], <span class='kw-2'>&</span><span class='ident'>arg</span>[<span class='number'>2</span>..])) + .<span class='ident'>collect</span>::<span class='op'><</span><span class='ident'>Vec</span><span class='op'><</span>_<span class='op'>>></span>(); + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>dirs</span> <span class='op'>=</span> <span class='ident'>Vec</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='ident'>statik</span> <span class='op'>=</span> <span class='ident'>config</span>.<span class='ident'>is_static</span>(<span class='ident'>name</span>); + <span class='kw'>for</span> <span class='kw-2'>&</span>(<span class='ident'>flag</span>, <span class='ident'>val</span>) <span class='kw'>in</span> <span class='ident'>parts</span>.<span class='ident'>iter</span>() { + <span class='kw'>match</span> <span class='ident'>flag</span> { + <span class='string'>"-L"</span> <span class='op'>=></span> { + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"cargo:rustc-link-search=native={}"</span>, <span class='ident'>val</span>); + <span class='ident'>dirs</span>.<span class='ident'>push</span>(<span class='ident'>PathBuf</span>::<span class='ident'>from</span>(<span class='ident'>val</span>)); + <span class='self'>self</span>.<span class='ident'>link_paths</span>.<span class='ident'>push</span>(<span class='ident'>PathBuf</span>::<span class='ident'>from</span>(<span class='ident'>val</span>)); + } + <span class='string'>"-F"</span> <span class='op'>=></span> { + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"cargo:rustc-link-search=framework={}"</span>, <span class='ident'>val</span>); + <span class='self'>self</span>.<span class='ident'>framework_paths</span>.<span class='ident'>push</span>(<span class='ident'>PathBuf</span>::<span class='ident'>from</span>(<span class='ident'>val</span>)); + } + <span class='string'>"-I"</span> <span class='op'>=></span> { + <span class='self'>self</span>.<span class='ident'>include_paths</span>.<span class='ident'>push</span>(<span class='ident'>PathBuf</span>::<span class='ident'>from</span>(<span class='ident'>val</span>)); + } + <span class='string'>"-l"</span> <span class='op'>=></span> { + <span class='self'>self</span>.<span class='ident'>libs</span>.<span class='ident'>push</span>(<span class='ident'>val</span>.<span class='ident'>to_string</span>()); + <span class='kw'>if</span> <span class='ident'>statik</span> <span class='op'>&&</span> <span class='op'>!</span><span class='ident'>is_system</span>(<span class='ident'>val</span>, <span class='kw-2'>&</span><span class='ident'>dirs</span>) { + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"cargo:rustc-link-lib=static={}"</span>, <span class='ident'>val</span>); + } <span class='kw'>else</span> { + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"cargo:rustc-link-lib={}"</span>, <span class='ident'>val</span>); + } + } + _ <span class='op'>=></span> {} + } + } + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>iter</span> <span class='op'>=</span> <span class='ident'>output</span>.<span class='ident'>split</span>(<span class='string'>' '</span>); + <span class='kw'>while</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>part</span>) <span class='op'>=</span> <span class='ident'>iter</span>.<span class='ident'>next</span>() { + <span class='kw'>if</span> <span class='ident'>part</span> <span class='op'>!=</span> <span class='string'>"-framework"</span> { <span class='kw'>continue</span> } + <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>lib</span>) <span class='op'>=</span> <span class='ident'>iter</span>.<span class='ident'>next</span>() { + <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"cargo:rustc-link-lib=framework={}"</span>, <span class='ident'>lib</span>); + <span class='self'>self</span>.<span class='ident'>frameworks</span>.<span class='ident'>push</span>(<span class='ident'>lib</span>.<span class='ident'>to_string</span>()); + } + } + } + + <span class='kw'>fn</span> <span class='ident'>parse_modversion</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>output</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) { + <span class='self'>self</span>.<span class='ident'>version</span>.<span class='ident'>push_str</span>(<span class='ident'>output</span>.<span class='ident'>trim</span>()); + } +} + +<span class='kw'>fn</span> <span class='ident'>infer_static</span>(<span class='ident'>name</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>let</span> <span class='ident'>name</span> <span class='op'>=</span> <span class='ident'>envify</span>(<span class='ident'>name</span>); + <span class='kw'>if</span> <span class='ident'>env</span>::<span class='ident'>var_os</span>(<span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}_STATIC"</span>, <span class='ident'>name</span>)).<span class='ident'>is_some</span>() { + <span class='boolval'>true</span> + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>env</span>::<span class='ident'>var_os</span>(<span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}_DYNAMIC"</span>, <span class='ident'>name</span>)).<span class='ident'>is_some</span>() { + <span class='boolval'>false</span> + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>env</span>::<span class='ident'>var_os</span>(<span class='string'>"PKG_CONFIG_ALL_STATIC"</span>).<span class='ident'>is_some</span>() { + <span class='boolval'>true</span> + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>env</span>::<span class='ident'>var_os</span>(<span class='string'>"PKG_CONFIG_ALL_DYNAMIC"</span>).<span class='ident'>is_some</span>() { + <span class='boolval'>false</span> + } <span class='kw'>else</span> { + <span class='boolval'>false</span> + } +} + +<span class='kw'>fn</span> <span class='ident'>envify</span>(<span class='ident'>name</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='ident'>name</span>.<span class='ident'>chars</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span>.<span class='ident'>to_ascii_uppercase</span>()).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> { + <span class='kw'>if</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>'-'</span> {<span class='string'>'_'</span>} <span class='kw'>else</span> {<span class='ident'>c</span>} + }).<span class='ident'>collect</span>() +} + +<span class='kw'>fn</span> <span class='ident'>is_system</span>(<span class='ident'>name</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>dirs</span>: <span class='kw-2'>&</span>[<span class='ident'>PathBuf</span>]) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>let</span> <span class='ident'>libname</span> <span class='op'>=</span> <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"lib{}.a"</span>, <span class='ident'>name</span>); + <span class='kw'>let</span> <span class='ident'>root</span> <span class='op'>=</span> <span class='ident'>Path</span>::<span class='ident'>new</span>(<span class='string'>"/usr"</span>); + <span class='op'>!</span><span class='ident'>dirs</span>.<span class='ident'>iter</span>().<span class='ident'>any</span>(<span class='op'>|</span><span class='ident'>d</span><span class='op'>|</span> { + <span class='op'>!</span><span class='ident'>d</span>.<span class='ident'>starts_with</span>(<span class='ident'>root</span>) <span class='op'>&&</span> <span class='ident'>fs</span>::<span class='ident'>metadata</span>(<span class='kw-2'>&</span><span class='ident'>d</span>.<span class='ident'>join</span>(<span class='kw-2'>&</span><span class='ident'>libname</span>)).<span class='ident'>is_ok</span>() + }) +} + +<span class='kw'>fn</span> <span class='ident'>run</span>(<span class='kw-2'>mut</span> <span class='ident'>cmd</span>: <span class='ident'>Command</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>String</span>, <span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>out</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>cmd</span>.<span class='ident'>output</span>().<span class='ident'>map_err</span>(<span class='op'>|</span><span class='ident'>e</span><span class='op'>|</span> { + <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"failed to run `{:?}`: {}"</span>, <span class='ident'>cmd</span>, <span class='ident'>e</span>) + })); + + <span class='kw'>let</span> <span class='ident'>stdout</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from_utf8</span>(<span class='ident'>out</span>.<span class='ident'>stdout</span>).<span class='ident'>unwrap</span>(); + <span class='kw'>if</span> <span class='ident'>out</span>.<span class='ident'>status</span>.<span class='ident'>success</span>() { + <span class='kw'>return</span> <span class='prelude-val'>Ok</span>(<span class='ident'>stdout</span>); + } + + <span class='kw'>let</span> <span class='ident'>stderr</span> <span class='op'>=</span> <span class='ident'>str</span>::<span class='ident'>from_utf8</span>(<span class='kw-2'>&</span><span class='ident'>out</span>.<span class='ident'>stderr</span>).<span class='ident'>unwrap</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>msg</span> <span class='op'>=</span> <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"`{:?}` did not exit successfully: {}"</span>, <span class='ident'>cmd</span>, <span class='ident'>out</span>.<span class='ident'>status</span>); + <span class='kw'>if</span> <span class='ident'>stdout</span>.<span class='ident'>len</span>() <span class='op'>></span> <span class='number'>0</span> { + <span class='ident'>msg</span>.<span class='ident'>push_str</span>(<span class='string'>"\n--- stdout\n"</span>); + <span class='ident'>msg</span>.<span class='ident'>push_str</span>(<span class='kw-2'>&</span><span class='ident'>stdout</span>); + } + <span class='kw'>if</span> <span class='ident'>stderr</span>.<span class='ident'>len</span>() <span class='op'>></span> <span class='number'>0</span> { + <span class='ident'>msg</span>.<span class='ident'>push_str</span>(<span class='string'>"\n--- stderr\n"</span>); + <span class='ident'>msg</span>.<span class='ident'>push_str</span>(<span class='ident'>stderr</span>); + } + + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='ident'>msg</span>); +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "pkg_config"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/regex/char.rs.html b/src/regex/char.rs.html new file mode 100644 index 0000000..f830f03 --- /dev/null +++ b/src/regex/char.rs.html @@ -0,0 +1,311 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/regex-0.1.38/src/char.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>char.rs.html -- source</title> + + <link rel="stylesheet" type="text/css" href="../../main.css"> + + <link rel="shortcut icon" href="http://www.rust-lang.org/favicon.ico"> + +</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"> + <a href='../../regex/index.html'><img src='http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png' alt='' width='100'></a> + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +</pre><pre class='rust '> +<span class='comment'>// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT</span> +<span class='comment'>// file at the top-level directory of this distribution and at</span> +<span class='comment'>// http://rust-lang.org/COPYRIGHT.</span> +<span class='comment'>//</span> +<span class='comment'>// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or</span> +<span class='comment'>// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license</span> +<span class='comment'>// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your</span> +<span class='comment'>// option. This file may not be copied, modified, or distributed</span> +<span class='comment'>// except according to those terms.</span> + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>char</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>cmp</span>::<span class='ident'>Ordering</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>fmt</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>u32</span>; + +<span class='kw'>use</span> <span class='ident'>syntax</span>; + +<span class='doccomment'>/// An inline representation of `Option<char>`.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This eliminates the need to do case analysis on `Option<char>` to determine</span> +<span class='doccomment'>/// ordinality with other characters.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// (The `Option<char>` is not related to encoding. Instead, it is used in the</span> +<span class='doccomment'>/// matching engines to represent the beginning and ending boundaries of the</span> +<span class='doccomment'>/// search text.)</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Copy</span>, <span class='ident'>Hash</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>, <span class='ident'>PartialOrd</span>, <span class='ident'>Ord</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Char</span>(<span class='ident'>u32</span>); + +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Debug</span> <span class='kw'>for</span> <span class='ident'>Char</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='kw'>match</span> <span class='ident'>char</span>::<span class='ident'>from_u32</span>(<span class='self'>self</span>.<span class='number'>0</span>) { + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Empty"</span>), + <span class='prelude-val'>Some</span>(<span class='ident'>c</span>) <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"{:?}"</span>, <span class='ident'>c</span>), + } + } +} + +<span class='kw'>impl</span> <span class='ident'>Char</span> { + <span class='doccomment'>/// Returns true iff the character is absent.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_none</span>(<span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { <span class='self'>self</span>.<span class='number'>0</span> <span class='op'>==</span> <span class='ident'>u32</span>::<span class='ident'>MAX</span> } + + <span class='doccomment'>/// Returns the length of the character's UTF-8 encoding.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If the character is absent, then `0` is returned.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>len_utf8</span>(<span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='ident'>char</span>::<span class='ident'>from_u32</span>(<span class='self'>self</span>.<span class='number'>0</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span>.<span class='ident'>len_utf8</span>()).<span class='ident'>unwrap_or</span>(<span class='number'>0</span>) + } + + <span class='doccomment'>/// Returns the simple case folding of this character.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If the character is absent, then absence is returned.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>case_fold</span>(<span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Char</span> { + <span class='ident'>char</span>::<span class='ident'>from_u32</span>(<span class='self'>self</span>.<span class='number'>0</span>).<span class='ident'>map</span>(<span class='ident'>syntax</span>::<span class='ident'>simple_case_fold</span>).<span class='ident'>into</span>() + } + + <span class='doccomment'>/// Returns true iff the character is a word character.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If the character is absent, then false is returned.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_word_char</span>(<span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='ident'>char</span>::<span class='ident'>from_u32</span>(<span class='self'>self</span>.<span class='number'>0</span>).<span class='ident'>map</span>(<span class='ident'>syntax</span>::<span class='ident'>is_word_char</span>).<span class='ident'>unwrap_or</span>(<span class='boolval'>false</span>) + } + + <span class='doccomment'>/// Converts the character to a real primitive `char`.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If the character is absent, then `None` is returned.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>as_char</span>(<span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>char</span><span class='op'>></span> { + <span class='comment'>// This is only used in the `regex!` macro because it expands char</span> + <span class='comment'>// classes into `match` expressions (instead of binary search).</span> + <span class='ident'>char</span>::<span class='ident'>from_u32</span>(<span class='self'>self</span>.<span class='number'>0</span>) + } +} + +<span class='kw'>impl</span> <span class='ident'>From</span><span class='op'><</span><span class='ident'>char</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>Char</span> { + <span class='kw'>fn</span> <span class='ident'>from</span>(<span class='ident'>c</span>: <span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>Char</span> { <span class='ident'>Char</span>(<span class='ident'>c</span> <span class='kw'>as</span> <span class='ident'>u32</span>) } +} + +<span class='kw'>impl</span> <span class='ident'>From</span><span class='op'><</span><span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>char</span><span class='op'>>></span> <span class='kw'>for</span> <span class='ident'>Char</span> { + <span class='kw'>fn</span> <span class='ident'>from</span>(<span class='ident'>c</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>char</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>Char</span> { + <span class='ident'>c</span>.<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span>.<span class='ident'>into</span>()).<span class='ident'>unwrap_or</span>(<span class='ident'>Char</span>(<span class='ident'>u32</span>::<span class='ident'>MAX</span>)) + } +} + +<span class='kw'>impl</span> <span class='ident'>PartialEq</span><span class='op'><</span><span class='ident'>char</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>Char</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>eq</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>bool</span> { <span class='self'>self</span>.<span class='number'>0</span> <span class='op'>==</span> <span class='op'>*</span><span class='ident'>other</span> <span class='kw'>as</span> <span class='ident'>u32</span> } +} + +<span class='kw'>impl</span> <span class='ident'>PartialEq</span><span class='op'><</span><span class='ident'>Char</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>char</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>eq</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>Char</span>) <span class='op'>-></span> <span class='ident'>bool</span> { <span class='op'>*</span><span class='self'>self</span> <span class='kw'>as</span> <span class='ident'>u32</span> <span class='op'>==</span> <span class='ident'>other</span>.<span class='number'>0</span> } +} + +<span class='kw'>impl</span> <span class='ident'>PartialOrd</span><span class='op'><</span><span class='ident'>char</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>Char</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>partial_cmp</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>char</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Ordering</span><span class='op'>></span> { + <span class='self'>self</span>.<span class='number'>0</span>.<span class='ident'>partial_cmp</span>(<span class='kw-2'>&</span>(<span class='op'>*</span><span class='ident'>other</span> <span class='kw'>as</span> <span class='ident'>u32</span>)) + } +} + +<span class='kw'>impl</span> <span class='ident'>PartialOrd</span><span class='op'><</span><span class='ident'>Char</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>char</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>partial_cmp</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>Char</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Ordering</span><span class='op'>></span> { + (<span class='op'>*</span><span class='self'>self</span> <span class='kw'>as</span> <span class='ident'>u32</span>).<span class='ident'>partial_cmp</span>(<span class='kw-2'>&</span><span class='ident'>other</span>.<span class='number'>0</span>) + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "regex"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/regex/input.rs.html b/src/regex/input.rs.html new file mode 100644 index 0000000..dfe5571 --- /dev/null +++ b/src/regex/input.rs.html @@ -0,0 +1,325 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/regex-0.1.38/src/input.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>input.rs.html -- source</title> + + <link rel="stylesheet" type="text/css" href="../../main.css"> + + <link rel="shortcut icon" href="http://www.rust-lang.org/favicon.ico"> + +</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"> + <a href='../../regex/index.html'><img src='http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png' alt='' width='100'></a> + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +</pre><pre class='rust '> +<span class='comment'>// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT</span> +<span class='comment'>// file at the top-level directory of this distribution and at</span> +<span class='comment'>// http://rust-lang.org/COPYRIGHT.</span> +<span class='comment'>//</span> +<span class='comment'>// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or</span> +<span class='comment'>// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license</span> +<span class='comment'>// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your</span> +<span class='comment'>// option. This file may not be copied, modified, or distributed</span> +<span class='comment'>// except according to those terms.</span> + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ops</span>; + +<span class='kw'>use</span> <span class='ident'>char</span>::<span class='ident'>Char</span>; +<span class='kw'>use</span> <span class='ident'>prefix</span>::<span class='ident'>Prefix</span>; + +<span class='doccomment'>/// Represents a location in the input.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Copy</span>, <span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>InputAt</span> { + <span class='ident'>pos</span>: <span class='ident'>usize</span>, + <span class='ident'>c</span>: <span class='ident'>Char</span>, + <span class='ident'>len</span>: <span class='ident'>usize</span>, +} + +<span class='kw'>impl</span> <span class='ident'>InputAt</span> { + <span class='doccomment'>/// Returns true iff this position is at the beginning of the input.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_beginning</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='self'>self</span>.<span class='ident'>pos</span> <span class='op'>==</span> <span class='number'>0</span> + } + + <span class='doccomment'>/// Returns the character at this position.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If this position is just before or after the input, then an absent</span> + <span class='doccomment'>/// character is returned.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>char</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Char</span> { + <span class='self'>self</span>.<span class='ident'>c</span> + } + + <span class='doccomment'>/// Returns the UTF-8 width of the character at this position.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>len</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='self'>self</span>.<span class='ident'>len</span> + } + + <span class='doccomment'>/// Returns the byte offset of this position.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>pos</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='self'>self</span>.<span class='ident'>pos</span> + } + + <span class='doccomment'>/// Returns the byte offset of the next position in the input.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>next_pos</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='self'>self</span>.<span class='ident'>pos</span> <span class='op'>+</span> <span class='self'>self</span>.<span class='ident'>len</span> + } +} + +<span class='doccomment'>/// An abstraction over input used in the matching engines.</span> +<span class='kw'>pub</span> <span class='kw'>trait</span> <span class='ident'>Input</span> { + <span class='doccomment'>/// Return an encoding of the position at byte offset `i`.</span> + <span class='kw'>fn</span> <span class='ident'>at</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>i</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>InputAt</span>; + <span class='doccomment'>/// Return an encoding of the char position just prior to byte offset `i`.</span> + <span class='kw'>fn</span> <span class='ident'>previous_at</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>i</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>InputAt</span>; + <span class='doccomment'>/// Scan the input for a matching prefix.</span> + <span class='kw'>fn</span> <span class='ident'>prefix_at</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>prefixes</span>: <span class='kw-2'>&</span><span class='ident'>Prefix</span>, <span class='ident'>at</span>: <span class='ident'>InputAt</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>InputAt</span><span class='op'>></span>; +} + +<span class='doccomment'>/// An input reader over characters.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// (This is the only implementation of `Input` at the moment.)</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>CharInput</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>); + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> <span class='ident'>CharInput</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='doccomment'>/// Return a new character input reader for the given string.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>CharInput</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>CharInput</span>(<span class='ident'>s</span>) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> <span class='ident'>ops</span>::<span class='ident'>Deref</span> <span class='kw'>for</span> <span class='ident'>CharInput</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Target</span> <span class='op'>=</span> <span class='ident'>str</span>; + + <span class='kw'>fn</span> <span class='ident'>deref</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>str</span> { + <span class='self'>self</span>.<span class='number'>0</span> + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> <span class='ident'>Input</span> <span class='kw'>for</span> <span class='ident'>CharInput</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='comment'>// This `inline(always)` increases throughput by almost 25% on the `hard`</span> + <span class='comment'>// benchmarks over a normal `inline` annotation.</span> + <span class='comment'>//</span> + <span class='comment'>// I'm not sure why `#[inline]` isn't enough to convince LLVM, but it is</span> + <span class='comment'>// used *a lot* in the guts of the matching engines.</span> + <span class='attribute'>#[<span class='ident'>inline</span>(<span class='ident'>always</span>)]</span> + <span class='kw'>fn</span> <span class='ident'>at</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>i</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>InputAt</span> { + <span class='kw'>let</span> <span class='ident'>c</span> <span class='op'>=</span> <span class='self'>self</span>[<span class='ident'>i</span>..].<span class='ident'>chars</span>().<span class='ident'>next</span>().<span class='ident'>into</span>(); + <span class='ident'>InputAt</span> { + <span class='ident'>pos</span>: <span class='ident'>i</span>, + <span class='ident'>c</span>: <span class='ident'>c</span>, + <span class='ident'>len</span>: <span class='ident'>c</span>.<span class='ident'>len_utf8</span>(), + } + } + + <span class='kw'>fn</span> <span class='ident'>previous_at</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>i</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>InputAt</span> { + <span class='kw'>let</span> <span class='ident'>c</span>: <span class='ident'>Char</span> <span class='op'>=</span> <span class='self'>self</span>[..<span class='ident'>i</span>].<span class='ident'>chars</span>().<span class='ident'>rev</span>().<span class='ident'>next</span>().<span class='ident'>into</span>(); + <span class='kw'>let</span> <span class='ident'>len</span> <span class='op'>=</span> <span class='ident'>c</span>.<span class='ident'>len_utf8</span>(); + <span class='ident'>InputAt</span> { + <span class='ident'>pos</span>: <span class='ident'>i</span> <span class='op'>-</span> <span class='ident'>len</span>, + <span class='ident'>c</span>: <span class='ident'>c</span>, + <span class='ident'>len</span>: <span class='ident'>len</span>, + } + } + + <span class='kw'>fn</span> <span class='ident'>prefix_at</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>prefixes</span>: <span class='kw-2'>&</span><span class='ident'>Prefix</span>, <span class='ident'>at</span>: <span class='ident'>InputAt</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>InputAt</span><span class='op'>></span> { + <span class='ident'>prefixes</span>.<span class='ident'>find</span>(<span class='kw-2'>&</span><span class='self'>self</span>[<span class='ident'>at</span>.<span class='ident'>pos</span>()..]).<span class='ident'>map</span>(<span class='op'>|</span>(<span class='ident'>s</span>, _)<span class='op'>|</span> <span class='self'>self</span>.<span class='ident'>at</span>(<span class='ident'>at</span>.<span class='ident'>pos</span>() <span class='op'>+</span> <span class='ident'>s</span>)) + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "regex"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/regex/lib.rs.html b/src/regex/lib.rs.html new file mode 100644 index 0000000..8331db1 --- /dev/null +++ b/src/regex/lib.rs.html @@ -0,0 +1,959 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/regex-0.1.38/src/lib.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>lib.rs.html -- source</title> + + <link rel="stylesheet" type="text/css" href="../../main.css"> + + <link rel="shortcut icon" href="http://www.rust-lang.org/favicon.ico"> + +</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"> + <a href='../../regex/index.html'><img src='http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png' alt='' width='100'></a> + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +<span id="313">313</span> +<span id="314">314</span> +<span id="315">315</span> +<span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +<span id="326">326</span> +<span id="327">327</span> +<span id="328">328</span> +<span id="329">329</span> +<span id="330">330</span> +<span id="331">331</span> +<span id="332">332</span> +<span id="333">333</span> +<span id="334">334</span> +<span id="335">335</span> +<span id="336">336</span> +<span id="337">337</span> +<span id="338">338</span> +<span id="339">339</span> +<span id="340">340</span> +<span id="341">341</span> +<span id="342">342</span> +<span id="343">343</span> +<span id="344">344</span> +<span id="345">345</span> +<span id="346">346</span> +<span id="347">347</span> +<span id="348">348</span> +<span id="349">349</span> +<span id="350">350</span> +<span id="351">351</span> +<span id="352">352</span> +<span id="353">353</span> +<span id="354">354</span> +<span id="355">355</span> +<span id="356">356</span> +<span id="357">357</span> +<span id="358">358</span> +<span id="359">359</span> +<span id="360">360</span> +<span id="361">361</span> +<span id="362">362</span> +<span id="363">363</span> +<span id="364">364</span> +<span id="365">365</span> +<span id="366">366</span> +<span id="367">367</span> +<span id="368">368</span> +<span id="369">369</span> +<span id="370">370</span> +<span id="371">371</span> +<span id="372">372</span> +<span id="373">373</span> +<span id="374">374</span> +<span id="375">375</span> +<span id="376">376</span> +<span id="377">377</span> +<span id="378">378</span> +<span id="379">379</span> +<span id="380">380</span> +<span id="381">381</span> +<span id="382">382</span> +<span id="383">383</span> +<span id="384">384</span> +<span id="385">385</span> +<span id="386">386</span> +<span id="387">387</span> +<span id="388">388</span> +<span id="389">389</span> +<span id="390">390</span> +<span id="391">391</span> +<span id="392">392</span> +<span id="393">393</span> +<span id="394">394</span> +<span id="395">395</span> +<span id="396">396</span> +<span id="397">397</span> +<span id="398">398</span> +<span id="399">399</span> +<span id="400">400</span> +<span id="401">401</span> +<span id="402">402</span> +<span id="403">403</span> +<span id="404">404</span> +<span id="405">405</span> +<span id="406">406</span> +<span id="407">407</span> +<span id="408">408</span> +<span id="409">409</span> +<span id="410">410</span> +<span id="411">411</span> +<span id="412">412</span> +<span id="413">413</span> +<span id="414">414</span> +<span id="415">415</span> +<span id="416">416</span> +<span id="417">417</span> +<span id="418">418</span> +<span id="419">419</span> +<span id="420">420</span> +<span id="421">421</span> +<span id="422">422</span> +<span id="423">423</span> +<span id="424">424</span> +<span id="425">425</span> +<span id="426">426</span> +<span id="427">427</span> +<span id="428">428</span> +<span id="429">429</span> +<span id="430">430</span> +<span id="431">431</span> +</pre><pre class='rust '> +<span class='comment'>// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT</span> +<span class='comment'>// file at the top-level directory of this distribution and at</span> +<span class='comment'>// http://rust-lang.org/COPYRIGHT.</span> +<span class='comment'>//</span> +<span class='comment'>// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or</span> +<span class='comment'>// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license</span> +<span class='comment'>// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your</span> +<span class='comment'>// option. This file may not be copied, modified, or distributed</span> +<span class='comment'>// except according to those terms.</span> + +<span class='doccomment'>//! This crate provides a native implementation of regular expressions that is</span> +<span class='doccomment'>//! heavily based on RE2 both in syntax and in implementation. Notably,</span> +<span class='doccomment'>//! backreferences and arbitrary lookahead/lookbehind assertions are not</span> +<span class='doccomment'>//! provided. In return, regular expression searching provided by this package</span> +<span class='doccomment'>//! has excellent worst-case performance. The specific syntax supported is</span> +<span class='doccomment'>//! documented further down.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! This crate's documentation provides some simple examples, describes Unicode</span> +<span class='doccomment'>//! support and exhaustively lists the supported syntax. For more specific</span> +<span class='doccomment'>//! details on the API, please see the documentation for the `Regex` type.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # Usage</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! This crate is [on crates.io](https://crates.io/crates/regex) and can be</span> +<span class='doccomment'>//! used by adding `regex` to your dependencies in your project's `Cargo.toml`.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```toml</span> +<span class='doccomment'>//! [dependencies]</span> +<span class='doccomment'>//! regex = "0.1.8"</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! and this to your crate root:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```rust</span> +<span class='doccomment'>//! extern crate regex;</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # First example: find a date</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! General use of regular expressions in this package involves compiling an</span> +<span class='doccomment'>//! expression and then using it to search, split or replace text. For example,</span> +<span class='doccomment'>//! to confirm that some text resembles a date:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```rust</span> +<span class='doccomment'>//! use regex::Regex;</span> +<span class='doccomment'>//! let re = Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap();</span> +<span class='doccomment'>//! assert!(re.is_match("2014-01-01"));</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Notice the use of the `^` and `$` anchors. In this crate, every expression</span> +<span class='doccomment'>//! is executed with an implicit `.*?` at the beginning and end, which allows</span> +<span class='doccomment'>//! it to match anywhere in the text. Anchors can be used to ensure that the</span> +<span class='doccomment'>//! full text matches an expression.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! This example also demonstrates the utility of</span> +<span class='doccomment'>//! [raw strings](http://doc.rust-lang.org/stable/reference.html#raw-byte-string-literals)</span> +<span class='doccomment'>//! in Rust, which</span> +<span class='doccomment'>//! are just like regular strings except they are prefixed with an `r` and do</span> +<span class='doccomment'>//! not process any escape sequences. For example, `"\\d"` is the same</span> +<span class='doccomment'>//! expression as `r"\d"`.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # The `regex!` macro</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Rust's compile-time meta-programming facilities provide a way to write a</span> +<span class='doccomment'>//! `regex!` macro which compiles regular expressions *when your program</span> +<span class='doccomment'>//! compiles*. Said differently, if you only use `regex!` to build regular</span> +<span class='doccomment'>//! expressions in your program, then your program cannot compile with an</span> +<span class='doccomment'>//! invalid regular expression. Moreover, the `regex!` macro compiles the</span> +<span class='doccomment'>//! given expression to native Rust code, which ideally makes it faster.</span> +<span class='doccomment'>//! Unfortunately (or fortunately), the dynamic implementation has had a lot</span> +<span class='doccomment'>//! more optimization work put it into it currently, so it is faster than</span> +<span class='doccomment'>//! the `regex!` macro in most cases.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! To use the `regex!` macro, you must enable the `plugin` feature and import</span> +<span class='doccomment'>//! the `regex_macros` crate as a syntax extension:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```ignore</span> +<span class='doccomment'>//! #![feature(plugin)]</span> +<span class='doccomment'>//! #![plugin(regex_macros)]</span> +<span class='doccomment'>//! extern crate regex;</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! fn main() {</span> +<span class='doccomment'>//! let re = regex!(r"^\d{4}-\d{2}-\d{2}$");</span> +<span class='doccomment'>//! assert!(re.is_match("2014-01-01"));</span> +<span class='doccomment'>//! }</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! There are a few things worth mentioning about using the `regex!` macro.</span> +<span class='doccomment'>//! Firstly, the `regex!` macro *only* accepts string *literals*.</span> +<span class='doccomment'>//! Secondly, the `regex` crate *must* be linked with the name `regex` since</span> +<span class='doccomment'>//! the generated code depends on finding symbols in the `regex` crate.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! One downside of using the `regex!` macro is that it can increase the</span> +<span class='doccomment'>//! size of your program's binary since it generates specialized Rust code.</span> +<span class='doccomment'>//! The extra size probably won't be significant for a small number of</span> +<span class='doccomment'>//! expressions, but 100+ calls to `regex!` will probably result in a</span> +<span class='doccomment'>//! noticeably bigger binary.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! **NOTE**: This is implemented using a compiler plugin, which is not</span> +<span class='doccomment'>//! available on the Rust 1.0 beta/stable channels. Therefore, you'll only</span> +<span class='doccomment'>//! be able to use `regex!` on the nightlies.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # Example: iterating over capture groups</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! This crate provides convenient iterators for matching an expression</span> +<span class='doccomment'>//! repeatedly against a search string to find successive non-overlapping</span> +<span class='doccomment'>//! matches. For example, to find all dates in a string and be able to access</span> +<span class='doccomment'>//! them by their component pieces:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```rust</span> +<span class='doccomment'>//! # extern crate regex; use regex::Regex;</span> +<span class='doccomment'>//! # fn main() {</span> +<span class='doccomment'>//! let re = Regex::new(r"(\d{4})-(\d{2})-(\d{2})").unwrap();</span> +<span class='doccomment'>//! let text = "2012-03-14, 2013-01-01 and 2014-07-05";</span> +<span class='doccomment'>//! for cap in re.captures_iter(text) {</span> +<span class='doccomment'>//! println!("Month: {} Day: {} Year: {}",</span> +<span class='doccomment'>//! cap.at(2).unwrap_or(""), cap.at(3).unwrap_or(""),</span> +<span class='doccomment'>//! cap.at(1).unwrap_or(""));</span> +<span class='doccomment'>//! }</span> +<span class='doccomment'>//! // Output:</span> +<span class='doccomment'>//! // Month: 03 Day: 14 Year: 2012</span> +<span class='doccomment'>//! // Month: 01 Day: 01 Year: 2013</span> +<span class='doccomment'>//! // Month: 07 Day: 05 Year: 2014</span> +<span class='doccomment'>//! # }</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Notice that the year is in the capture group indexed at `1`. This is</span> +<span class='doccomment'>//! because the *entire match* is stored in the capture group at index `0`.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # Example: replacement with named capture groups</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Building on the previous example, perhaps we'd like to rearrange the date</span> +<span class='doccomment'>//! formats. This can be done with text replacement. But to make the code</span> +<span class='doccomment'>//! clearer, we can *name* our capture groups and use those names as variables</span> +<span class='doccomment'>//! in our replacement text:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```rust</span> +<span class='doccomment'>//! # extern crate regex; use regex::Regex;</span> +<span class='doccomment'>//! # fn main() {</span> +<span class='doccomment'>//! let re = Regex::new(r"(?P<y>\d{4})-(?P<m>\d{2})-(?P<d>\d{2})").unwrap();</span> +<span class='doccomment'>//! let before = "2012-03-14, 2013-01-01 and 2014-07-05";</span> +<span class='doccomment'>//! let after = re.replace_all(before, "$m/$d/$y");</span> +<span class='doccomment'>//! assert_eq!(after, "03/14/2012, 01/01/2013 and 07/05/2014");</span> +<span class='doccomment'>//! # }</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! The `replace` methods are actually polymorphic in the replacement, which</span> +<span class='doccomment'>//! provides more flexibility than is seen here. (See the documentation for</span> +<span class='doccomment'>//! `Regex::replace` for more details.)</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Note that if your regex gets complicated, you can use the `x` flag to</span> +<span class='doccomment'>//! enable insigificant whitespace mode, which also lets you write comments:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```rust</span> +<span class='doccomment'>//! # extern crate regex; use regex::Regex;</span> +<span class='doccomment'>//! # fn main() {</span> +<span class='doccomment'>//! let re = Regex::new(r"(?x)</span> +<span class='doccomment'>//! (?P<y>\d{4}) # the year</span> +<span class='doccomment'>//! -</span> +<span class='doccomment'>//! (?P<m>\d{2}) # the month</span> +<span class='doccomment'>//! -</span> +<span class='doccomment'>//! (?P<d>\d{2}) # the day</span> +<span class='doccomment'>//! ").unwrap();</span> +<span class='doccomment'>//! let before = "2012-03-14, 2013-01-01 and 2014-07-05";</span> +<span class='doccomment'>//! let after = re.replace_all(before, "$m/$d/$y");</span> +<span class='doccomment'>//! assert_eq!(after, "03/14/2012, 01/01/2013 and 07/05/2014");</span> +<span class='doccomment'>//! # }</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # Pay for what you use</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! With respect to searching text with a regular expression, there are three</span> +<span class='doccomment'>//! questions that can be asked:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! 1. Does the text match this expression?</span> +<span class='doccomment'>//! 2. If so, where does it match?</span> +<span class='doccomment'>//! 3. Where are the submatches?</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Generally speaking, this crate could provide a function to answer only #3,</span> +<span class='doccomment'>//! which would subsume #1 and #2 automatically. However, it can be</span> +<span class='doccomment'>//! significantly more expensive to compute the location of submatches, so it's</span> +<span class='doccomment'>//! best not to do it if you don't need to.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Therefore, only use what you need. For example, don't use `find` if you</span> +<span class='doccomment'>//! only need to test if an expression matches a string. (Use `is_match`</span> +<span class='doccomment'>//! instead.)</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # Unicode</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! This implementation executes regular expressions **only** on sequences of</span> +<span class='doccomment'>//! Unicode scalar values while exposing match locations as byte indices into</span> +<span class='doccomment'>//! the search string.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Currently, only simple case folding is supported. Namely, when matching</span> +<span class='doccomment'>//! case-insensitively, the characters are first mapped using the</span> +<span class='doccomment'>//! [simple case folding](ftp://ftp.unicode.org/Public/UNIDATA/CaseFolding.txt)</span> +<span class='doccomment'>//! mapping.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Regular expressions themselves are also **only** interpreted as a sequence</span> +<span class='doccomment'>//! of Unicode scalar values. This means you can use Unicode characters</span> +<span class='doccomment'>//! directly in your expression:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```rust</span> +<span class='doccomment'>//! # extern crate regex; use regex::Regex;</span> +<span class='doccomment'>//! # fn main() {</span> +<span class='doccomment'>//! let re = Regex::new(r"(?i)Δ+").unwrap();</span> +<span class='doccomment'>//! assert_eq!(re.find("ΔδΔ"), Some((0, 6)));</span> +<span class='doccomment'>//! # }</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Finally, Unicode general categories and scripts are available as character</span> +<span class='doccomment'>//! classes. For example, you can match a sequence of numerals, Greek or</span> +<span class='doccomment'>//! Cherokee letters:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```rust</span> +<span class='doccomment'>//! # extern crate regex; use regex::Regex;</span> +<span class='doccomment'>//! # fn main() {</span> +<span class='doccomment'>//! let re = Regex::new(r"[\pN\p{Greek}\p{Cherokee}]+").unwrap();</span> +<span class='doccomment'>//! assert_eq!(re.find("abcΔᎠβⅠᏴγδⅡxyz"), Some((3, 23)));</span> +<span class='doccomment'>//! # }</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # Syntax</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! The syntax supported in this crate is almost in an exact correspondence</span> +<span class='doccomment'>//! with the syntax supported by RE2. It is documented below.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Note that the regular expression parser and abstract syntax are exposed in</span> +<span class='doccomment'>//! a separate crate,</span> +<span class='doccomment'>//! [`regex-syntax`](../regex_syntax/index.html).</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ## Matching one character</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! <pre class="rust"></span> +<span class='doccomment'>//! . any character except new line (includes new line with s flag)</span> +<span class='doccomment'>//! [xyz] A character class matching either x, y or z.</span> +<span class='doccomment'>//! [^xyz] A character class matching any character except x, y and z.</span> +<span class='doccomment'>//! [a-z] A character class matching any character in range a-z.</span> +<span class='doccomment'>//! \d digit (\p{Nd})</span> +<span class='doccomment'>//! \D not digit</span> +<span class='doccomment'>//! [:alpha:] ASCII character class ([A-Za-z])</span> +<span class='doccomment'>//! [:^alpha:] Negated ASCII character class ([^A-Za-z])</span> +<span class='doccomment'>//! \pN One-letter name Unicode character class</span> +<span class='doccomment'>//! \p{Greek} Unicode character class (general category or script)</span> +<span class='doccomment'>//! \PN Negated one-letter name Unicode character class</span> +<span class='doccomment'>//! \P{Greek} negated Unicode character class (general category or script)</span> +<span class='doccomment'>//! </pre></span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Any named character class may appear inside a bracketed `[...]` character</span> +<span class='doccomment'>//! class. For example, `[\p{Greek}\pN]` matches any Greek or numeral</span> +<span class='doccomment'>//! character.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ## Composites</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! <pre class="rust"></span> +<span class='doccomment'>//! xy concatenation (x followed by y)</span> +<span class='doccomment'>//! x|y alternation (x or y, prefer x)</span> +<span class='doccomment'>//! </pre></span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ## Repetitions</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! <pre class="rust"></span> +<span class='doccomment'>//! x* zero or more of x (greedy)</span> +<span class='doccomment'>//! x+ one or more of x (greedy)</span> +<span class='doccomment'>//! x? zero or one of x (greedy)</span> +<span class='doccomment'>//! x*? zero or more of x (ungreedy)</span> +<span class='doccomment'>//! x+? one or more of x (ungreedy)</span> +<span class='doccomment'>//! x?? zero or one of x (ungreedy)</span> +<span class='doccomment'>//! x{n,m} at least n x and at most m x (greedy)</span> +<span class='doccomment'>//! x{n,} at least n x (greedy)</span> +<span class='doccomment'>//! x{n} exactly n x</span> +<span class='doccomment'>//! x{n,m}? at least n x and at most m x (ungreedy)</span> +<span class='doccomment'>//! x{n,}? at least n x (ungreedy)</span> +<span class='doccomment'>//! x{n}? exactly n x</span> +<span class='doccomment'>//! </pre></span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ## Empty matches</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! <pre class="rust"></span> +<span class='doccomment'>//! ^ the beginning of text (or start-of-line with multi-line mode)</span> +<span class='doccomment'>//! $ the end of text (or end-of-line with multi-line mode)</span> +<span class='doccomment'>//! \A only the beginning of text (even with multi-line mode enabled)</span> +<span class='doccomment'>//! \z only the end of text (even with multi-line mode enabled)</span> +<span class='doccomment'>//! \b a Unicode word boundary (\w on one side and \W, \A, or \z on other)</span> +<span class='doccomment'>//! \B not a Unicode word boundary</span> +<span class='doccomment'>//! </pre></span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ## Grouping and flags</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! <pre class="rust"></span> +<span class='doccomment'>//! (exp) numbered capture group (indexed by opening parenthesis)</span> +<span class='doccomment'>//! (?P&lt;name&gt;exp) named (also numbered) capture group (allowed chars: [_0-9a-zA-Z])</span> +<span class='doccomment'>//! (?:exp) non-capturing group</span> +<span class='doccomment'>//! (?flags) set flags within current group</span> +<span class='doccomment'>//! (?flags:exp) set flags for exp (non-capturing)</span> +<span class='doccomment'>//! </pre></span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Flags are each a single character. For example, `(?x)` sets the flag `x`</span> +<span class='doccomment'>//! and `(?-x)` clears the flag `x`. Multiple flags can be set or cleared at</span> +<span class='doccomment'>//! the same time: `(?xy)` sets both the `x` and `y` flags and `(?x-y)` sets</span> +<span class='doccomment'>//! the `x` flag and clears the `y` flag.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! All flags are by default disabled. They are:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! <pre class="rust"></span> +<span class='doccomment'>//! i case-insensitive</span> +<span class='doccomment'>//! m multi-line mode: ^ and $ match begin/end of line</span> +<span class='doccomment'>//! s allow . to match \n</span> +<span class='doccomment'>//! U swap the meaning of x* and x*?</span> +<span class='doccomment'>//! x ignore whitespace and allow line comments (starting with `#`)</span> +<span class='doccomment'>//! </pre></span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Here's an example that matches case-insensitively for only part of the</span> +<span class='doccomment'>//! expression:</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ```rust</span> +<span class='doccomment'>//! # extern crate regex; use regex::Regex;</span> +<span class='doccomment'>//! # fn main() {</span> +<span class='doccomment'>//! let re = Regex::new(r"(?i)a+(?-i)b+").unwrap();</span> +<span class='doccomment'>//! let cap = re.captures("AaAaAbbBBBb").unwrap();</span> +<span class='doccomment'>//! assert_eq!(cap.at(0), Some("AaAaAbb"));</span> +<span class='doccomment'>//! # }</span> +<span class='doccomment'>//! ```</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Notice that the `a+` matches either `a` or `A`, but the `b+` only matches</span> +<span class='doccomment'>//! `b`.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ## Escape sequences</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! <pre class="rust"></span> +<span class='doccomment'>//! \* literal *, works for any punctuation character: \.+*?()|[]{}^$</span> +<span class='doccomment'>//! \a bell (\x07)</span> +<span class='doccomment'>//! \f form feed (\x0C)</span> +<span class='doccomment'>//! \t horizontal tab</span> +<span class='doccomment'>//! \n new line</span> +<span class='doccomment'>//! \r carriage return</span> +<span class='doccomment'>//! \v vertical tab (\x0B)</span> +<span class='doccomment'>//! \123 octal character code (up to three digits)</span> +<span class='doccomment'>//! \x7F hex character code (exactly two digits)</span> +<span class='doccomment'>//! \x{10FFFF} any hex character code corresponding to a Unicode code point</span> +<span class='doccomment'>//! </pre></span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ## Perl character classes (Unicode friendly)</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! These classes are based on the definitions provided in</span> +<span class='doccomment'>//! [UTS#18](http://www.unicode.org/reports/tr18/#Compatibility_Properties):</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! <pre class="rust"></span> +<span class='doccomment'>//! \d digit (\p{Nd})</span> +<span class='doccomment'>//! \D not digit</span> +<span class='doccomment'>//! \s whitespace (\p{White_Space})</span> +<span class='doccomment'>//! \S not whitespace</span> +<span class='doccomment'>//! \w word character (\p{Alphabetic} + \p{M} + \d + \p{Pc} + \p{Join_Control})</span> +<span class='doccomment'>//! \W not word character</span> +<span class='doccomment'>//! </pre></span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! ## ASCII character classes</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! <pre class="rust"></span> +<span class='doccomment'>//! [:alnum:] alphanumeric ([0-9A-Za-z])</span> +<span class='doccomment'>//! [:alpha:] alphabetic ([A-Za-z])</span> +<span class='doccomment'>//! [:ascii:] ASCII ([\x00-\x7F])</span> +<span class='doccomment'>//! [:blank:] blank ([\t ])</span> +<span class='doccomment'>//! [:cntrl:] control ([\x00-\x1F\x7F])</span> +<span class='doccomment'>//! [:digit:] digits ([0-9])</span> +<span class='doccomment'>//! [:graph:] graphical ([!-~])</span> +<span class='doccomment'>//! [:lower:] lower case ([a-z])</span> +<span class='doccomment'>//! [:print:] printable ([ -~])</span> +<span class='doccomment'>//! [:punct:] punctuation ([!-/:-@[-`{-~])</span> +<span class='doccomment'>//! [:space:] whitespace ([\t\n\v\f\r ])</span> +<span class='doccomment'>//! [:upper:] upper case ([A-Z])</span> +<span class='doccomment'>//! [:word:] word characters ([0-9A-Za-z_])</span> +<span class='doccomment'>//! [:xdigit:] hex digit ([0-9A-Fa-f])</span> +<span class='doccomment'>//! </pre></span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! # Untrusted input</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! This crate can handle both untrusted regular expressions and untrusted</span> +<span class='doccomment'>//! search text.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Untrusted regular expressions are handled by capping the size of a compiled</span> +<span class='doccomment'>//! regular expression. (See `Regex::with_size_limit`.) Without this, it would</span> +<span class='doccomment'>//! be trivial for an attacker to exhaust your system's memory with expressions</span> +<span class='doccomment'>//! like `a{100}{100}{100}`.</span> +<span class='doccomment'>//!</span> +<span class='doccomment'>//! Untrusted search text is allowed because the matching engine(s) in this</span> +<span class='doccomment'>//! crate have time complexity `O(mn)` (with `m ~ regex` and `n ~ search</span> +<span class='doccomment'>//! text`), which means there's no way to cause exponential blow-up like with</span> +<span class='doccomment'>//! some other regular expression engines. (We pay for this by disallowing</span> +<span class='doccomment'>//! features like arbitrary look-ahead and back-references.)</span> + +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>deny</span>(<span class='ident'>missing_docs</span>)]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>cfg_attr</span>(<span class='ident'>test</span>, <span class='ident'>deny</span>(<span class='ident'>warnings</span>))]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>cfg_attr</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"pattern"</span>, <span class='ident'>feature</span>(<span class='ident'>pattern</span>))]</span> +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>doc</span>(<span class='ident'>html_logo_url</span> <span class='op'>=</span> <span class='string'>"http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png"</span>, + <span class='ident'>html_favicon_url</span> <span class='op'>=</span> <span class='string'>"http://www.rust-lang.org/favicon.ico"</span>, + <span class='ident'>html_root_url</span> <span class='op'>=</span> <span class='string'>"http://doc.rust-lang.org/regex/"</span>)]</span> + +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>aho_corasick</span>; +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>memchr</span>; +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>regex_syntax</span> <span class='kw'>as</span> <span class='ident'>syntax</span>; + +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>re</span>::{ + <span class='ident'>Regex</span>, <span class='ident'>Error</span>, <span class='ident'>Captures</span>, <span class='ident'>SubCaptures</span>, <span class='ident'>SubCapturesPos</span>, <span class='ident'>SubCapturesNamed</span>, + <span class='ident'>FindCaptures</span>, <span class='ident'>FindMatches</span>, + <span class='ident'>Replacer</span>, <span class='ident'>NoExpand</span>, <span class='ident'>RegexSplits</span>, <span class='ident'>RegexSplitsN</span>, + <span class='ident'>quote</span>, <span class='ident'>is_match</span>, +}; + +<span class='kw'>mod</span> <span class='ident'>backtrack</span>; +<span class='kw'>mod</span> <span class='ident'>char</span>; +<span class='kw'>mod</span> <span class='ident'>compile</span>; +<span class='kw'>mod</span> <span class='ident'>input</span>; +<span class='kw'>mod</span> <span class='ident'>pool</span>; +<span class='kw'>mod</span> <span class='ident'>prefix</span>; +<span class='kw'>mod</span> <span class='ident'>program</span>; +<span class='kw'>mod</span> <span class='ident'>nfa</span>; +<span class='kw'>mod</span> <span class='ident'>re</span>; + +<span class='doccomment'>/// The `internal` module exists to support the `regex!` macro and other</span> +<span class='doccomment'>/// suspicious activity, such as testing different matching engines.</span> +<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>internal</span> { + <span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>char</span>::<span class='ident'>Char</span>; + <span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>input</span>::{<span class='ident'>Input</span>, <span class='ident'>CharInput</span>, <span class='ident'>InputAt</span>}; + <span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>program</span>::{ + <span class='ident'>Program</span>, <span class='ident'>MatchEngine</span>, <span class='ident'>CharRanges</span>, <span class='ident'>Inst</span>, <span class='ident'>LookInst</span>, <span class='ident'>OneChar</span>, + }; + <span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>re</span>::<span class='ident'>ExNative</span>; + <span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>re</span>::<span class='ident'>Regex</span>::{<span class='ident'>Dynamic</span>, <span class='ident'>Native</span>}; +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "regex"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/regex/program.rs.html b/src/regex/program.rs.html new file mode 100644 index 0000000..8f6ed02 --- /dev/null +++ b/src/regex/program.rs.html @@ -0,0 +1,1057 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/regex-0.1.38/src/program.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>program.rs.html -- source</title> + + <link rel="stylesheet" type="text/css" href="../../main.css"> + + <link rel="shortcut icon" href="http://www.rust-lang.org/favicon.ico"> + +</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"> + <a href='../../regex/index.html'><img src='http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png' alt='' width='100'></a> + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +<span id="313">313</span> +<span id="314">314</span> +<span id="315">315</span> +<span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +<span id="326">326</span> +<span id="327">327</span> +<span id="328">328</span> +<span id="329">329</span> +<span id="330">330</span> +<span id="331">331</span> +<span id="332">332</span> +<span id="333">333</span> +<span id="334">334</span> +<span id="335">335</span> +<span id="336">336</span> +<span id="337">337</span> +<span id="338">338</span> +<span id="339">339</span> +<span id="340">340</span> +<span id="341">341</span> +<span id="342">342</span> +<span id="343">343</span> +<span id="344">344</span> +<span id="345">345</span> +<span id="346">346</span> +<span id="347">347</span> +<span id="348">348</span> +<span id="349">349</span> +<span id="350">350</span> +<span id="351">351</span> +<span id="352">352</span> +<span id="353">353</span> +<span id="354">354</span> +<span id="355">355</span> +<span id="356">356</span> +<span id="357">357</span> +<span id="358">358</span> +<span id="359">359</span> +<span id="360">360</span> +<span id="361">361</span> +<span id="362">362</span> +<span id="363">363</span> +<span id="364">364</span> +<span id="365">365</span> +<span id="366">366</span> +<span id="367">367</span> +<span id="368">368</span> +<span id="369">369</span> +<span id="370">370</span> +<span id="371">371</span> +<span id="372">372</span> +<span id="373">373</span> +<span id="374">374</span> +<span id="375">375</span> +<span id="376">376</span> +<span id="377">377</span> +<span id="378">378</span> +<span id="379">379</span> +<span id="380">380</span> +<span id="381">381</span> +<span id="382">382</span> +<span id="383">383</span> +<span id="384">384</span> +<span id="385">385</span> +<span id="386">386</span> +<span id="387">387</span> +<span id="388">388</span> +<span id="389">389</span> +<span id="390">390</span> +<span id="391">391</span> +<span id="392">392</span> +<span id="393">393</span> +<span id="394">394</span> +<span id="395">395</span> +<span id="396">396</span> +<span id="397">397</span> +<span id="398">398</span> +<span id="399">399</span> +<span id="400">400</span> +<span id="401">401</span> +<span id="402">402</span> +<span id="403">403</span> +<span id="404">404</span> +<span id="405">405</span> +<span id="406">406</span> +<span id="407">407</span> +<span id="408">408</span> +<span id="409">409</span> +<span id="410">410</span> +<span id="411">411</span> +<span id="412">412</span> +<span id="413">413</span> +<span id="414">414</span> +<span id="415">415</span> +<span id="416">416</span> +<span id="417">417</span> +<span id="418">418</span> +<span id="419">419</span> +<span id="420">420</span> +<span id="421">421</span> +<span id="422">422</span> +<span id="423">423</span> +<span id="424">424</span> +<span id="425">425</span> +<span id="426">426</span> +<span id="427">427</span> +<span id="428">428</span> +<span id="429">429</span> +<span id="430">430</span> +<span id="431">431</span> +<span id="432">432</span> +<span id="433">433</span> +<span id="434">434</span> +<span id="435">435</span> +<span id="436">436</span> +<span id="437">437</span> +<span id="438">438</span> +<span id="439">439</span> +<span id="440">440</span> +<span id="441">441</span> +<span id="442">442</span> +<span id="443">443</span> +<span id="444">444</span> +<span id="445">445</span> +<span id="446">446</span> +<span id="447">447</span> +<span id="448">448</span> +<span id="449">449</span> +<span id="450">450</span> +<span id="451">451</span> +<span id="452">452</span> +<span id="453">453</span> +<span id="454">454</span> +<span id="455">455</span> +<span id="456">456</span> +<span id="457">457</span> +<span id="458">458</span> +<span id="459">459</span> +<span id="460">460</span> +<span id="461">461</span> +<span id="462">462</span> +<span id="463">463</span> +<span id="464">464</span> +<span id="465">465</span> +<span id="466">466</span> +<span id="467">467</span> +<span id="468">468</span> +<span id="469">469</span> +<span id="470">470</span> +<span id="471">471</span> +<span id="472">472</span> +<span id="473">473</span> +<span id="474">474</span> +<span id="475">475</span> +<span id="476">476</span> +<span id="477">477</span> +<span id="478">478</span> +<span id="479">479</span> +<span id="480">480</span> +</pre><pre class='rust '> +<span class='comment'>// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT</span> +<span class='comment'>// file at the top-level directory of this distribution and at</span> +<span class='comment'>// http://rust-lang.org/COPYRIGHT.</span> +<span class='comment'>//</span> +<span class='comment'>// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or</span> +<span class='comment'>// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license</span> +<span class='comment'>// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your</span> +<span class='comment'>// option. This file may not be copied, modified, or distributed</span> +<span class='comment'>// except according to those terms.</span> + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>cmp</span>::{<span class='self'>self</span>, <span class='ident'>Ordering</span>}; + +<span class='kw'>use</span> <span class='ident'>syntax</span>; + +<span class='kw'>use</span> <span class='ident'>Error</span>; +<span class='kw'>use</span> <span class='ident'>backtrack</span>::{<span class='ident'>Backtrack</span>, <span class='ident'>BackMachine</span>}; +<span class='kw'>use</span> <span class='ident'>char</span>::<span class='ident'>Char</span>; +<span class='kw'>use</span> <span class='ident'>compile</span>::<span class='ident'>Compiler</span>; +<span class='kw'>use</span> <span class='ident'>nfa</span>::{<span class='ident'>Nfa</span>, <span class='ident'>NfaThreads</span>}; +<span class='kw'>use</span> <span class='ident'>pool</span>::<span class='ident'>Pool</span>; +<span class='kw'>use</span> <span class='ident'>prefix</span>::<span class='ident'>Prefix</span>; +<span class='kw'>use</span> <span class='ident'>re</span>::<span class='ident'>CaptureIdxs</span>; + +<span class='kw'>const</span> <span class='ident'>NUM_PREFIX_LIMIT</span>: <span class='ident'>usize</span> <span class='op'>=</span> <span class='number'>30</span>; +<span class='kw'>const</span> <span class='ident'>PREFIX_LENGTH_LIMIT</span>: <span class='ident'>usize</span> <span class='op'>=</span> <span class='number'>15</span>; + +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>InstIdx</span> <span class='op'>=</span> <span class='ident'>usize</span>; + +<span class='doccomment'>/// An instruction, the underlying unit of a compiled regular expression</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Inst</span> { + <span class='doccomment'>/// A match has occurred.</span> + <span class='doccomment'>/// This is always the last instruction and only occurs in a single spot.</span> + <span class='doccomment'>/// We could special case this in the code, but it is much clearer to</span> + <span class='doccomment'>/// handle it as a proper instruction.</span> + <span class='ident'>Match</span>, + <span class='doccomment'>/// Save the current location in the input into the given capture location.</span> + <span class='ident'>Save</span>(<span class='ident'>usize</span>), + <span class='doccomment'>/// Jump to the instruction given.</span> + <span class='ident'>Jump</span>(<span class='ident'>InstIdx</span>), + <span class='doccomment'>/// Match either instruction, preferring the first.</span> + <span class='ident'>Split</span>(<span class='ident'>InstIdx</span>, <span class='ident'>InstIdx</span>), + <span class='doccomment'>/// A zero-width instruction. When this instruction matches, the input</span> + <span class='doccomment'>/// is not advanced.</span> + <span class='ident'>EmptyLook</span>(<span class='ident'>LookInst</span>), + <span class='doccomment'>/// Match a single possibly case insensitive character.</span> + <span class='ident'>Char</span>(<span class='ident'>OneChar</span>), + <span class='doccomment'>/// Match one or more possibly case insensitive character ranges.</span> + <span class='ident'>Ranges</span>(<span class='ident'>CharRanges</span>), +} + +<span class='doccomment'>/// A single character instruction.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>OneChar</span> { + <span class='doccomment'>/// The character.</span> + <span class='kw'>pub</span> <span class='ident'>c</span>: <span class='ident'>char</span>, + <span class='doccomment'>/// True if the character should be matched case insensitively.</span> + <span class='doccomment'>/// (i.e., The input character will need to be case folded.)</span> + <span class='kw'>pub</span> <span class='ident'>casei</span>: <span class='ident'>bool</span>, +} + +<span class='doccomment'>/// A multi-range character class instruction.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>CharRanges</span> { + <span class='doccomment'>/// Sorted sequence of non-overlapping ranges.</span> + <span class='kw'>pub</span> <span class='ident'>ranges</span>: <span class='ident'>Vec</span><span class='op'><</span>(<span class='ident'>char</span>, <span class='ident'>char</span>)<span class='op'>></span>, + <span class='doccomment'>/// Whether to match case insensitively.</span> + <span class='kw'>pub</span> <span class='ident'>casei</span>: <span class='ident'>bool</span>, +} + +<span class='doccomment'>/// The set of zero-width match instructions.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Debug</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>LookInst</span> { + <span class='doccomment'>/// Start of line or input.</span> + <span class='ident'>StartLine</span>, + <span class='doccomment'>/// End of line or input.</span> + <span class='ident'>EndLine</span>, + <span class='doccomment'>/// Start of input.</span> + <span class='ident'>StartText</span>, + <span class='doccomment'>/// End of input.</span> + <span class='ident'>EndText</span>, + <span class='doccomment'>/// Word character on one side and non-word character on other.</span> + <span class='ident'>WordBoundary</span>, + <span class='doccomment'>/// Word character on both sides or non-word character on both sides.</span> + <span class='ident'>NotWordBoundary</span>, +} + +<span class='kw'>impl</span> <span class='ident'>OneChar</span> { + <span class='doccomment'>/// Tests whether the given input character matches this instruction.</span> + <span class='attribute'>#[<span class='ident'>inline</span>(<span class='ident'>always</span>)]</span> <span class='comment'>// About ~5-15% more throughput then `#[inline]`</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>matches</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>c</span>: <span class='ident'>Char</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='self'>self</span>.<span class='ident'>c</span> <span class='op'>==</span> <span class='ident'>c</span> <span class='op'>||</span> (<span class='self'>self</span>.<span class='ident'>casei</span> <span class='op'>&&</span> <span class='self'>self</span>.<span class='ident'>c</span> <span class='op'>==</span> <span class='ident'>c</span>.<span class='ident'>case_fold</span>()) + } +} + +<span class='kw'>impl</span> <span class='ident'>CharRanges</span> { + <span class='doccomment'>/// Emits a range specifically for the `.` expression.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>any</span>() <span class='op'>-></span> <span class='ident'>CharRanges</span> { + <span class='ident'>CharRanges</span> { + <span class='ident'>ranges</span>: <span class='macro'>vec</span><span class='macro'>!</span>[(<span class='string'>'\x00'</span>, <span class='string'>'\u{10ffff}'</span>)], + <span class='ident'>casei</span>: <span class='boolval'>false</span>, + } + } + + <span class='doccomment'>/// Emits a range specifically for the `(?s).` expression.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>any_nonl</span>() <span class='op'>-></span> <span class='ident'>CharRanges</span> { + <span class='ident'>CharRanges</span> { + <span class='ident'>ranges</span>: <span class='macro'>vec</span><span class='macro'>!</span>[(<span class='string'>'\x00'</span>, <span class='string'>'\x09'</span>), (<span class='string'>'\x0B'</span>, <span class='string'>'\u{10ffff}'</span>)], + <span class='ident'>casei</span>: <span class='boolval'>false</span>, + } + } + + <span class='doccomment'>/// Emits a range from the AST character class.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>from_class</span>(<span class='ident'>cls</span>: <span class='ident'>syntax</span>::<span class='ident'>CharClass</span>) <span class='op'>-></span> <span class='ident'>CharRanges</span> { + <span class='kw'>let</span> <span class='ident'>casei</span> <span class='op'>=</span> <span class='ident'>cls</span>.<span class='ident'>is_case_insensitive</span>(); + <span class='ident'>CharRanges</span> { + <span class='ident'>ranges</span>: <span class='ident'>cls</span>.<span class='ident'>into_iter</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>r</span><span class='op'>|</span> (<span class='ident'>r</span>.<span class='ident'>start</span>, <span class='ident'>r</span>.<span class='ident'>end</span>)).<span class='ident'>collect</span>(), + <span class='ident'>casei</span>: <span class='ident'>casei</span>, + } + } + + <span class='doccomment'>/// Tests whether the given input character matches this instruction.</span> + <span class='attribute'>#[<span class='ident'>inline</span>(<span class='ident'>always</span>)]</span> <span class='comment'>// About ~5-15% more throughput then `#[inline]`</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>matches</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='kw-2'>mut</span> <span class='ident'>c</span>: <span class='ident'>Char</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>casei</span> { + <span class='ident'>c</span> <span class='op'>=</span> <span class='ident'>c</span>.<span class='ident'>case_fold</span>(); + } + <span class='comment'>// This speeds up the `match_class_unicode` benchmark by checking</span> + <span class='comment'>// some common cases quickly without binary search. e.g., Matching</span> + <span class='comment'>// a Unicode class on predominantly ASCII text.</span> + <span class='kw'>for</span> <span class='ident'>i</span> <span class='kw'>in</span> <span class='number'>0</span>..<span class='ident'>cmp</span>::<span class='ident'>min</span>(<span class='self'>self</span>.<span class='ident'>ranges</span>.<span class='ident'>len</span>(), <span class='number'>4</span>) { + <span class='kw'>let</span> <span class='ident'>r</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>ranges</span>[<span class='ident'>i</span>]; + <span class='kw'>if</span> <span class='ident'>c</span> <span class='op'><</span> <span class='ident'>r</span>.<span class='number'>0</span> { + <span class='kw'>return</span> <span class='prelude-val'>None</span>; + } + <span class='kw'>if</span> <span class='ident'>c</span> <span class='op'><=</span> <span class='ident'>r</span>.<span class='number'>1</span> { + <span class='kw'>return</span> <span class='prelude-val'>Some</span>(<span class='ident'>i</span>); + } + } + <span class='self'>self</span>.<span class='ident'>ranges</span>.<span class='ident'>binary_search_by</span>(<span class='op'>|</span><span class='ident'>r</span><span class='op'>|</span> { + <span class='kw'>if</span> <span class='ident'>r</span>.<span class='number'>1</span> <span class='op'><</span> <span class='ident'>c</span> { + <span class='ident'>Ordering</span>::<span class='ident'>Less</span> + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>r</span>.<span class='number'>0</span> <span class='op'>></span> <span class='ident'>c</span> { + <span class='ident'>Ordering</span>::<span class='ident'>Greater</span> + } <span class='kw'>else</span> { + <span class='ident'>Ordering</span>::<span class='ident'>Equal</span> + } + }).<span class='ident'>ok</span>() + } +} + +<span class='kw'>impl</span> <span class='ident'>LookInst</span> { + <span class='doccomment'>/// Tests whether the pair of characters matches this zero-width</span> + <span class='doccomment'>/// instruction.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>matches</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>c1</span>: <span class='ident'>Char</span>, <span class='ident'>c2</span>: <span class='ident'>Char</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>LookInst</span>::<span class='op'>*</span>; + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>StartLine</span> <span class='op'>=></span> <span class='ident'>c1</span>.<span class='ident'>is_none</span>() <span class='op'>||</span> <span class='ident'>c1</span> <span class='op'>==</span> <span class='string'>'\n'</span>, + <span class='ident'>EndLine</span> <span class='op'>=></span> <span class='ident'>c2</span>.<span class='ident'>is_none</span>() <span class='op'>||</span> <span class='ident'>c2</span> <span class='op'>==</span> <span class='string'>'\n'</span>, + <span class='ident'>StartText</span> <span class='op'>=></span> <span class='ident'>c1</span>.<span class='ident'>is_none</span>(), + <span class='ident'>EndText</span> <span class='op'>=></span> <span class='ident'>c2</span>.<span class='ident'>is_none</span>(), + <span class='kw-2'>ref</span> <span class='ident'>wbty</span> <span class='op'>=></span> { + <span class='kw'>let</span> (<span class='ident'>w1</span>, <span class='ident'>w2</span>) <span class='op'>=</span> (<span class='ident'>c1</span>.<span class='ident'>is_word_char</span>(), <span class='ident'>c2</span>.<span class='ident'>is_word_char</span>()); + (<span class='op'>*</span><span class='ident'>wbty</span> <span class='op'>==</span> <span class='ident'>WordBoundary</span> <span class='op'>&&</span> <span class='ident'>w1</span> <span class='op'>^</span> <span class='ident'>w2</span>) + <span class='op'>||</span> (<span class='op'>*</span><span class='ident'>wbty</span> <span class='op'>==</span> <span class='ident'>NotWordBoundary</span> <span class='op'>&&</span> <span class='op'>!</span>(<span class='ident'>w1</span> <span class='op'>^</span> <span class='ident'>w2</span>)) + } + } + } +} + +<span class='doccomment'>/// The matching engines offered by this regex implementation.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// N.B. This is exported for use in testing.</span> +<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Copy</span>, <span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>MatchEngine</span> { + <span class='doccomment'>/// A bounded backtracking implementation. About twice as fast as the</span> + <span class='doccomment'>/// NFA, but can only work on small regexes and small input.</span> + <span class='ident'>Backtrack</span>, + <span class='doccomment'>/// A full NFA simulation. Can always be employed but almost always the</span> + <span class='doccomment'>/// slowest choice.</span> + <span class='ident'>Nfa</span>, + <span class='doccomment'>/// If the entire regex is a literal and no capture groups have been</span> + <span class='doccomment'>/// requested, then we can degrade to a simple substring match.</span> + <span class='ident'>Literals</span>, +} + +<span class='doccomment'>/// Program represents a compiled regular expression. Once an expression is</span> +<span class='doccomment'>/// compiled, its representation is immutable and will never change.</span> +<span class='doccomment'>/// (Well, almost. In fact, the matching engines cache state that can be</span> +<span class='doccomment'>/// reused on subsequent searches. But this is interior mutability that</span> +<span class='doccomment'>/// shouldn't be observable by the caller.)</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Program</span> { + <span class='doccomment'>/// The original regular expression string.</span> + <span class='kw'>pub</span> <span class='ident'>original</span>: <span class='ident'>String</span>, + <span class='doccomment'>/// A sequence of instructions.</span> + <span class='kw'>pub</span> <span class='ident'>insts</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Inst</span><span class='op'>></span>, + <span class='doccomment'>/// The sequence of capture group names. There is an entry for each capture</span> + <span class='doccomment'>/// group index and a name exists only if the capture group is named.</span> + <span class='kw'>pub</span> <span class='ident'>cap_names</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>String</span><span class='op'>>></span>, + <span class='doccomment'>/// If the regular expression requires a literal prefix in order to have a</span> + <span class='doccomment'>/// match, that prefix is stored here as a DFA.</span> + <span class='kw'>pub</span> <span class='ident'>prefixes</span>: <span class='ident'>Prefix</span>, + <span class='doccomment'>/// True iff matching any literal prefix indicates a match.</span> + <span class='kw'>pub</span> <span class='ident'>prefixes_complete</span>: <span class='ident'>bool</span>, + <span class='doccomment'>/// True iff program is anchored at the beginning.</span> + <span class='kw'>pub</span> <span class='ident'>anchored_begin</span>: <span class='ident'>bool</span>, + <span class='doccomment'>/// True iff program is anchored at the end.</span> + <span class='kw'>pub</span> <span class='ident'>anchored_end</span>: <span class='ident'>bool</span>, + <span class='doccomment'>/// The type of matching engine to use.</span> + <span class='doccomment'>/// When `None` (the default), pick an engine automatically.</span> + <span class='kw'>pub</span> <span class='ident'>engine</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>MatchEngine</span><span class='op'>></span>, + <span class='doccomment'>/// Cached NFA threads.</span> + <span class='kw'>pub</span> <span class='ident'>nfa_threads</span>: <span class='ident'>Pool</span><span class='op'><</span><span class='ident'>NfaThreads</span><span class='op'>></span>, + <span class='doccomment'>/// Cached backtracking memory.</span> + <span class='kw'>pub</span> <span class='ident'>backtrack</span>: <span class='ident'>Pool</span><span class='op'><</span><span class='ident'>BackMachine</span><span class='op'>></span>, +} + +<span class='kw'>impl</span> <span class='ident'>Program</span> { + <span class='doccomment'>/// Compiles a Regex.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>( + <span class='ident'>engine</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>MatchEngine</span><span class='op'>></span>, + <span class='ident'>size_limit</span>: <span class='ident'>usize</span>, + <span class='ident'>re</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, + ) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Program</span>, <span class='ident'>Error</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>expr</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>syntax</span>::<span class='ident'>Expr</span>::<span class='ident'>parse</span>(<span class='ident'>re</span>)); + <span class='kw'>let</span> (<span class='ident'>insts</span>, <span class='ident'>cap_names</span>) <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>Compiler</span>::<span class='ident'>new</span>(<span class='ident'>size_limit</span>).<span class='ident'>compile</span>(<span class='ident'>expr</span>)); + <span class='kw'>let</span> (<span class='ident'>insts_len</span>, <span class='ident'>ncaps</span>) <span class='op'>=</span> (<span class='ident'>insts</span>.<span class='ident'>len</span>(), <span class='ident'>num_captures</span>(<span class='kw-2'>&</span><span class='ident'>insts</span>)); + <span class='kw'>let</span> <span class='ident'>create_threads</span> <span class='op'>=</span> <span class='kw'>move</span> <span class='op'>||</span> <span class='ident'>NfaThreads</span>::<span class='ident'>new</span>(<span class='ident'>insts_len</span>, <span class='ident'>ncaps</span>); + <span class='kw'>let</span> <span class='ident'>create_backtrack</span> <span class='op'>=</span> <span class='kw'>move</span> <span class='op'>||</span> <span class='ident'>BackMachine</span>::<span class='ident'>new</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>prog</span> <span class='op'>=</span> <span class='ident'>Program</span> { + <span class='ident'>original</span>: <span class='ident'>re</span>.<span class='ident'>into</span>(), + <span class='ident'>insts</span>: <span class='ident'>insts</span>, + <span class='ident'>cap_names</span>: <span class='ident'>cap_names</span>, + <span class='ident'>prefixes</span>: <span class='ident'>Prefix</span>::<span class='ident'>Empty</span>, + <span class='ident'>prefixes_complete</span>: <span class='boolval'>false</span>, + <span class='ident'>anchored_begin</span>: <span class='boolval'>false</span>, + <span class='ident'>anchored_end</span>: <span class='boolval'>false</span>, + <span class='ident'>engine</span>: <span class='ident'>engine</span>, + <span class='ident'>nfa_threads</span>: <span class='ident'>Pool</span>::<span class='ident'>new</span>(<span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>create_threads</span>)), + <span class='ident'>backtrack</span>: <span class='ident'>Pool</span>::<span class='ident'>new</span>(<span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>create_backtrack</span>)), + }; + + <span class='ident'>prog</span>.<span class='ident'>find_prefixes</span>(); + <span class='ident'>prog</span>.<span class='ident'>anchored_begin</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>prog</span>.<span class='ident'>insts</span>[<span class='number'>1</span>] { + <span class='ident'>Inst</span>::<span class='ident'>EmptyLook</span>(<span class='ident'>LookInst</span>::<span class='ident'>StartText</span>) <span class='op'>=></span> <span class='boolval'>true</span>, + _ <span class='op'>=></span> <span class='boolval'>false</span>, + }; + <span class='ident'>prog</span>.<span class='ident'>anchored_end</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>prog</span>.<span class='ident'>insts</span>[<span class='ident'>prog</span>.<span class='ident'>insts</span>.<span class='ident'>len</span>() <span class='op'>-</span> <span class='number'>3</span>] { + <span class='ident'>Inst</span>::<span class='ident'>EmptyLook</span>(<span class='ident'>LookInst</span>::<span class='ident'>EndText</span>) <span class='op'>=></span> <span class='boolval'>true</span>, + _ <span class='op'>=></span> <span class='boolval'>false</span>, + }; + <span class='prelude-val'>Ok</span>(<span class='ident'>prog</span>) + } + + <span class='doccomment'>/// Executes a compiled regex program.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>exec</span>( + <span class='kw-2'>&</span><span class='self'>self</span>, + <span class='ident'>caps</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>CaptureIdxs</span>, + <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, + <span class='ident'>start</span>: <span class='ident'>usize</span>, + ) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>choose_engine</span>(<span class='ident'>caps</span>.<span class='ident'>len</span>(), <span class='ident'>text</span>) { + <span class='ident'>MatchEngine</span>::<span class='ident'>Backtrack</span> <span class='op'>=></span> <span class='ident'>Backtrack</span>::<span class='ident'>exec</span>(<span class='self'>self</span>, <span class='ident'>caps</span>, <span class='ident'>text</span>, <span class='ident'>start</span>), + <span class='ident'>MatchEngine</span>::<span class='ident'>Nfa</span> <span class='op'>=></span> <span class='ident'>Nfa</span>::<span class='ident'>exec</span>(<span class='self'>self</span>, <span class='ident'>caps</span>, <span class='ident'>text</span>, <span class='ident'>start</span>), + <span class='ident'>MatchEngine</span>::<span class='ident'>Literals</span> <span class='op'>=></span> { + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>prefixes</span>.<span class='ident'>find</span>(<span class='kw-2'>&</span><span class='ident'>text</span>[<span class='ident'>start</span>..]) { + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='boolval'>false</span>, + <span class='prelude-val'>Some</span>((<span class='ident'>s</span>, <span class='ident'>e</span>)) <span class='op'>=></span> { + <span class='kw'>if</span> <span class='ident'>caps</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>2</span> { + <span class='ident'>caps</span>[<span class='number'>0</span>] <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>start</span> <span class='op'>+</span> <span class='ident'>s</span>); + <span class='ident'>caps</span>[<span class='number'>1</span>] <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>start</span> <span class='op'>+</span> <span class='ident'>e</span>); + } + <span class='boolval'>true</span> + } + } + } + } + } + + <span class='kw'>fn</span> <span class='ident'>choose_engine</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>cap_len</span>: <span class='ident'>usize</span>, <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>MatchEngine</span> { + <span class='comment'>// If the engine is already chosen, then we use it.</span> + <span class='comment'>// But that might not be a good idea. e.g., What if `Literals` is</span> + <span class='comment'>// chosen and it can't work? I guess we should probably check whether</span> + <span class='comment'>// the chosen engine is appropriate or not.</span> + <span class='self'>self</span>.<span class='ident'>engine</span>.<span class='ident'>unwrap_or_else</span>(<span class='op'>||</span> { + <span class='kw'>if</span> <span class='ident'>cap_len</span> <span class='op'><=</span> <span class='number'>2</span> + <span class='op'>&&</span> <span class='self'>self</span>.<span class='ident'>prefixes</span>.<span class='ident'>preserves_priority</span>() + <span class='op'>&&</span> <span class='self'>self</span>.<span class='ident'>prefixes_complete</span> { + <span class='ident'>MatchEngine</span>::<span class='ident'>Literals</span> + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>Backtrack</span>::<span class='ident'>should_exec</span>(<span class='self'>self</span>, <span class='ident'>text</span>) { + <span class='comment'>// We're only here if the input and regex combined are small.</span> + <span class='ident'>MatchEngine</span>::<span class='ident'>Backtrack</span> + } <span class='kw'>else</span> { + <span class='ident'>MatchEngine</span>::<span class='ident'>Nfa</span> + } + }) + } + + <span class='doccomment'>/// Returns the total number of capture groups in the regular expression.</span> + <span class='doccomment'>/// This includes the zeroth capture.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>num_captures</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='ident'>num_captures</span>(<span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>insts</span>) + } + + <span class='doccomment'>/// Allocate new capture groups.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>alloc_captures</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>>></span> { + <span class='macro'>vec</span><span class='macro'>!</span>[<span class='prelude-val'>None</span>; <span class='number'>2</span> <span class='op'>*</span> <span class='self'>self</span>.<span class='ident'>num_captures</span>()] + } + + <span class='doccomment'>/// Find and store a prefix machine for the current program.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>find_prefixes</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>Inst</span>::<span class='op'>*</span>; + + <span class='kw'>let</span> (<span class='ident'>ps</span>, <span class='ident'>complete</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>prefixes_from_insts</span>(<span class='number'>1</span>); + <span class='kw'>if</span> <span class='ident'>ps</span>.<span class='ident'>len</span>() <span class='op'>></span> <span class='number'>0</span> { + <span class='self'>self</span>.<span class='ident'>prefixes</span> <span class='op'>=</span> <span class='ident'>Prefix</span>::<span class='ident'>new</span>(<span class='ident'>ps</span>); + <span class='self'>self</span>.<span class='ident'>prefixes_complete</span> <span class='op'>=</span> <span class='ident'>complete</span>; + <span class='kw'>return</span>; + } + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>pc</span> <span class='op'>=</span> <span class='number'>1</span>; + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>prefixes</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[]; + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>pcomplete</span> <span class='op'>=</span> <span class='boolval'>true</span>; + <span class='kw'>while</span> <span class='kw'>let</span> <span class='ident'>Split</span>(<span class='ident'>x</span>, <span class='ident'>y</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>insts</span>[<span class='ident'>pc</span>] { + <span class='kw'>let</span> (<span class='ident'>xps</span>, <span class='ident'>xcomplete</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>prefixes_from_insts</span>(<span class='ident'>x</span>); + <span class='kw'>let</span> (<span class='ident'>yps</span>, <span class='ident'>ycomplete</span>) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>prefixes_from_insts</span>(<span class='ident'>y</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>done</span> <span class='op'>=</span> <span class='boolval'>false</span>; + <span class='kw'>match</span> (<span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>insts</span>[<span class='ident'>x</span>], <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>insts</span>[<span class='ident'>y</span>]) { + <span class='comment'>// We should be able to support this. Add explicit stack. ---AG</span> + (<span class='kw-2'>&</span><span class='ident'>Split</span>(_, _), <span class='kw-2'>&</span><span class='ident'>Split</span>(_, _)) <span class='op'>=></span> <span class='kw'>return</span>, + (_, <span class='kw-2'>&</span><span class='ident'>Split</span>(_, _)) <span class='kw'>if</span> <span class='ident'>xps</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>0</span> <span class='op'>=></span> <span class='kw'>return</span>, + (_, <span class='kw-2'>&</span><span class='ident'>Split</span>(_, _)) <span class='op'>=></span> { + <span class='ident'>pcomplete</span> <span class='op'>=</span> <span class='ident'>pcomplete</span> <span class='op'>&&</span> <span class='ident'>xcomplete</span>; + <span class='ident'>prefixes</span>.<span class='ident'>extend</span>(<span class='ident'>xps</span>); + <span class='ident'>pc</span> <span class='op'>=</span> <span class='ident'>y</span>; + } + (<span class='kw-2'>&</span><span class='ident'>Split</span>(_, _), _) <span class='kw'>if</span> <span class='ident'>yps</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>0</span> <span class='op'>=></span> <span class='kw'>return</span>, + (<span class='kw-2'>&</span><span class='ident'>Split</span>(_, _), _) <span class='op'>=></span> { + <span class='ident'>pcomplete</span> <span class='op'>=</span> <span class='ident'>pcomplete</span> <span class='op'>&&</span> <span class='ident'>ycomplete</span>; + <span class='ident'>prefixes</span>.<span class='ident'>extend</span>(<span class='ident'>yps</span>); + <span class='ident'>pc</span> <span class='op'>=</span> <span class='ident'>x</span>; + } + _ <span class='kw'>if</span> <span class='ident'>xps</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>0</span> <span class='op'>||</span> <span class='ident'>yps</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>0</span> <span class='op'>=></span> <span class='kw'>return</span>, + <span class='comment'>// This is our base case. We've followed splits the whole</span> + <span class='comment'>// way, which means both instructions lead to a match.</span> + _ <span class='op'>=></span> { + <span class='ident'>pcomplete</span> <span class='op'>=</span> <span class='ident'>pcomplete</span> <span class='op'>&&</span> <span class='ident'>xcomplete</span> <span class='op'>&&</span> <span class='ident'>ycomplete</span>; + <span class='ident'>prefixes</span>.<span class='ident'>extend</span>(<span class='ident'>xps</span>); + <span class='ident'>prefixes</span>.<span class='ident'>extend</span>(<span class='ident'>yps</span>); + <span class='ident'>done</span> <span class='op'>=</span> <span class='boolval'>true</span>; + } + } + <span class='comment'>// Arg. We've over-extended ourselves, quit with nothing to</span> + <span class='comment'>// show for it.</span> + <span class='kw'>if</span> <span class='ident'>prefixes</span>.<span class='ident'>len</span>() <span class='op'>></span> <span class='ident'>NUM_PREFIX_LIMIT</span> { + <span class='kw'>return</span>; + } + <span class='kw'>if</span> <span class='ident'>done</span> { <span class='kw'>break</span>; } + } + <span class='self'>self</span>.<span class='ident'>prefixes</span> <span class='op'>=</span> <span class='ident'>Prefix</span>::<span class='ident'>new</span>(<span class='ident'>prefixes</span>); + <span class='self'>self</span>.<span class='ident'>prefixes_complete</span> <span class='op'>=</span> <span class='ident'>pcomplete</span> <span class='op'>&&</span> <span class='self'>self</span>.<span class='ident'>prefixes</span>.<span class='ident'>len</span>() <span class='op'>></span> <span class='number'>0</span>; + } + + <span class='doccomment'>/// Find a prefix starting at the given instruction.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Returns `true` in the tuple if the end of the prefix leads trivially</span> + <span class='doccomment'>/// to a match. (This may report false negatives, but being conservative</span> + <span class='doccomment'>/// is OK.)</span> + <span class='kw'>fn</span> <span class='ident'>prefixes_from_insts</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='kw-2'>mut</span> <span class='ident'>pc</span>: <span class='ident'>usize</span>) <span class='op'>-></span> (<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span>, <span class='ident'>bool</span>) { + <span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>Inst</span>::<span class='op'>*</span>; + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>complete</span> <span class='op'>=</span> <span class='boolval'>true</span>; + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>alts</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>String</span>::<span class='ident'>new</span>()]; + <span class='kw'>while</span> <span class='ident'>pc</span> <span class='op'><</span> <span class='self'>self</span>.<span class='ident'>insts</span>.<span class='ident'>len</span>() { + <span class='kw'>let</span> <span class='ident'>inst</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>insts</span>[<span class='ident'>pc</span>]; + + <span class='comment'>// Each iteration adds one character to every alternate prefix *or*</span> + <span class='comment'>// it stops. Thus, the prefix alternates grow in lock step, and it</span> + <span class='comment'>// suffices to check one of them to see if the prefix limit has been</span> + <span class='comment'>// exceeded.</span> + <span class='kw'>if</span> <span class='ident'>alts</span>[<span class='number'>0</span>].<span class='ident'>len</span>() <span class='op'>></span> <span class='ident'>PREFIX_LENGTH_LIMIT</span> { + <span class='ident'>complete</span> <span class='op'>=</span> <span class='boolval'>false</span>; + <span class='kw'>break</span>; + } + <span class='kw'>match</span> <span class='op'>*</span><span class='ident'>inst</span> { + <span class='ident'>Save</span>(_) <span class='op'>=></span> { <span class='ident'>pc</span> <span class='op'>+=</span> <span class='number'>1</span>; <span class='kw'>continue</span> } <span class='comment'>// completely ignore it</span> + <span class='ident'>Char</span>(<span class='ident'>OneChar</span> { <span class='ident'>c</span>, <span class='ident'>casei</span>: <span class='boolval'>false</span> }) <span class='op'>=></span> { + <span class='kw'>for</span> <span class='ident'>alt</span> <span class='kw'>in</span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>alts</span> { + <span class='ident'>alt</span>.<span class='ident'>push</span>(<span class='ident'>c</span>); + } + <span class='ident'>pc</span> <span class='op'>+=</span> <span class='number'>1</span>; + } + <span class='ident'>Ranges</span>(<span class='ident'>CharRanges</span> { <span class='kw-2'>ref</span> <span class='ident'>ranges</span>, <span class='ident'>casei</span>: <span class='boolval'>false</span> }) <span class='op'>=></span> { + <span class='kw'>let</span> <span class='ident'>nchars</span> <span class='op'>=</span> <span class='ident'>num_chars_in_ranges</span>(<span class='ident'>ranges</span>); + <span class='kw'>if</span> <span class='ident'>alts</span>.<span class='ident'>len</span>() <span class='op'>*</span> <span class='ident'>nchars</span> <span class='op'>></span> <span class='ident'>NUM_PREFIX_LIMIT</span> { + <span class='ident'>complete</span> <span class='op'>=</span> <span class='boolval'>false</span>; + <span class='kw'>break</span>; + } + + <span class='kw'>let</span> <span class='ident'>orig</span> <span class='op'>=</span> <span class='ident'>alts</span>; + <span class='ident'>alts</span> <span class='op'>=</span> <span class='ident'>Vec</span>::<span class='ident'>with_capacity</span>(<span class='ident'>orig</span>.<span class='ident'>len</span>()); + <span class='kw'>for</span> <span class='kw-2'>&</span>(<span class='ident'>s</span>, <span class='ident'>e</span>) <span class='kw'>in</span> <span class='ident'>ranges</span> { + <span class='kw'>for</span> <span class='ident'>c</span> <span class='kw'>in</span> (<span class='ident'>s</span> <span class='kw'>as</span> <span class='ident'>u32</span>)..(<span class='ident'>e</span> <span class='kw'>as</span> <span class='ident'>u32</span> <span class='op'>+</span> <span class='number'>1</span>){ + <span class='kw'>for</span> <span class='ident'>alt</span> <span class='kw'>in</span> <span class='kw-2'>&</span><span class='ident'>orig</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>alt</span> <span class='op'>=</span> <span class='ident'>alt</span>.<span class='ident'>clone</span>(); + <span class='ident'>alt</span>.<span class='ident'>push</span>(::<span class='ident'>std</span>::<span class='ident'>char</span>::<span class='ident'>from_u32</span>(<span class='ident'>c</span>).<span class='ident'>unwrap</span>()); + <span class='ident'>alts</span>.<span class='ident'>push</span>(<span class='ident'>alt</span>); + } + } + } + <span class='ident'>pc</span> <span class='op'>+=</span> <span class='number'>1</span>; + } + <span class='ident'>Jump</span>(<span class='ident'>pc2</span>) <span class='op'>=></span> <span class='ident'>pc</span> <span class='op'>=</span> <span class='ident'>pc2</span>, + _ <span class='op'>=></span> { <span class='ident'>complete</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>leads_to_match</span>(<span class='ident'>pc</span>); <span class='kw'>break</span> } + } + } + <span class='kw'>if</span> <span class='ident'>alts</span>[<span class='number'>0</span>].<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>0</span> { + (<span class='macro'>vec</span><span class='macro'>!</span>[], <span class='boolval'>false</span>) + } <span class='kw'>else</span> { + (<span class='ident'>alts</span>, <span class='ident'>complete</span>) + } + } + + <span class='kw'>fn</span> <span class='ident'>leads_to_match</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='kw-2'>mut</span> <span class='ident'>pc</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='comment'>// I'm pretty sure this is conservative, so it might have some</span> + <span class='comment'>// false negatives.</span> + <span class='kw'>loop</span> { + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>insts</span>[<span class='ident'>pc</span>] { + <span class='ident'>Inst</span>::<span class='ident'>Match</span> <span class='op'>=></span> <span class='kw'>return</span> <span class='boolval'>true</span>, + <span class='ident'>Inst</span>::<span class='ident'>Save</span>(_) <span class='op'>=></span> <span class='ident'>pc</span> <span class='op'>+=</span> <span class='number'>1</span>, + <span class='ident'>Inst</span>::<span class='ident'>Jump</span>(<span class='ident'>pc2</span>) <span class='op'>=></span> <span class='ident'>pc</span> <span class='op'>=</span> <span class='ident'>pc2</span>, + _ <span class='op'>=></span> <span class='kw'>return</span> <span class='boolval'>false</span>, + } + } + } +} + +<span class='kw'>impl</span> <span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>Program</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Program</span> { + <span class='kw'>let</span> (<span class='ident'>insts_len</span>, <span class='ident'>ncaps</span>) <span class='op'>=</span> (<span class='self'>self</span>.<span class='ident'>insts</span>.<span class='ident'>len</span>(), <span class='self'>self</span>.<span class='ident'>num_captures</span>()); + <span class='kw'>let</span> <span class='ident'>create_threads</span> <span class='op'>=</span> <span class='kw'>move</span> <span class='op'>||</span> <span class='ident'>NfaThreads</span>::<span class='ident'>new</span>(<span class='ident'>insts_len</span>, <span class='ident'>ncaps</span>); + <span class='kw'>let</span> <span class='ident'>create_backtrack</span> <span class='op'>=</span> <span class='kw'>move</span> <span class='op'>||</span> <span class='ident'>BackMachine</span>::<span class='ident'>new</span>(); + <span class='ident'>Program</span> { + <span class='ident'>original</span>: <span class='self'>self</span>.<span class='ident'>original</span>.<span class='ident'>clone</span>(), + <span class='ident'>insts</span>: <span class='self'>self</span>.<span class='ident'>insts</span>.<span class='ident'>clone</span>(), + <span class='ident'>cap_names</span>: <span class='self'>self</span>.<span class='ident'>cap_names</span>.<span class='ident'>clone</span>(), + <span class='ident'>prefixes</span>: <span class='self'>self</span>.<span class='ident'>prefixes</span>.<span class='ident'>clone</span>(), + <span class='ident'>prefixes_complete</span>: <span class='self'>self</span>.<span class='ident'>prefixes_complete</span>, + <span class='ident'>anchored_begin</span>: <span class='self'>self</span>.<span class='ident'>anchored_begin</span>, + <span class='ident'>anchored_end</span>: <span class='self'>self</span>.<span class='ident'>anchored_end</span>, + <span class='ident'>engine</span>: <span class='self'>self</span>.<span class='ident'>engine</span>, + <span class='ident'>nfa_threads</span>: <span class='ident'>Pool</span>::<span class='ident'>new</span>(<span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>create_threads</span>)), + <span class='ident'>backtrack</span>: <span class='ident'>Pool</span>::<span class='ident'>new</span>(<span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>create_backtrack</span>)), + } + } +} + +<span class='doccomment'>/// Return the number of captures in the given sequence of instructions.</span> +<span class='kw'>fn</span> <span class='ident'>num_captures</span>(<span class='ident'>insts</span>: <span class='kw-2'>&</span>[<span class='ident'>Inst</span>]) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>n</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>for</span> <span class='ident'>inst</span> <span class='kw'>in</span> <span class='ident'>insts</span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='ident'>inst</span> { + <span class='ident'>Inst</span>::<span class='ident'>Save</span>(<span class='ident'>c</span>) <span class='op'>=></span> <span class='ident'>n</span> <span class='op'>=</span> <span class='ident'>cmp</span>::<span class='ident'>max</span>(<span class='ident'>n</span>, <span class='ident'>c</span><span class='op'>+</span><span class='number'>1</span>), + _ <span class='op'>=></span> {} + } + } + <span class='comment'>// There's exactly 2 Save slots for every capture.</span> + <span class='ident'>n</span> <span class='op'>/</span> <span class='number'>2</span> +} + +<span class='doccomment'>/// Count the number of characters in the given range.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This is useful for pre-emptively limiting the number of prefix literals</span> +<span class='doccomment'>/// we extract from a regex program.</span> +<span class='kw'>fn</span> <span class='ident'>num_chars_in_ranges</span>(<span class='ident'>ranges</span>: <span class='kw-2'>&</span>[(<span class='ident'>char</span>, <span class='ident'>char</span>)]) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='ident'>ranges</span>.<span class='ident'>iter</span>() + .<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span>(<span class='ident'>s</span>, <span class='ident'>e</span>)<span class='op'>|</span> (<span class='ident'>e</span> <span class='kw'>as</span> <span class='ident'>u32</span>) <span class='op'>-</span> (<span class='ident'>s</span> <span class='kw'>as</span> <span class='ident'>u32</span>)) + .<span class='ident'>fold</span>(<span class='number'>0</span>, <span class='op'>|</span><span class='ident'>acc</span>, <span class='ident'>len</span><span class='op'>|</span> <span class='ident'>acc</span> <span class='op'>+</span> <span class='ident'>len</span>) <span class='kw'>as</span> <span class='ident'>usize</span> +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "regex"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/regex/re.rs.html b/src/regex/re.rs.html new file mode 100644 index 0000000..3472b45 --- /dev/null +++ b/src/regex/re.rs.html @@ -0,0 +1,2393 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/regex-0.1.38/src/re.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>re.rs.html -- source</title> + + <link rel="stylesheet" type="text/css" href="../../main.css"> + + <link rel="shortcut icon" href="http://www.rust-lang.org/favicon.ico"> + +</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"> + <a href='../../regex/index.html'><img src='http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png' alt='' width='100'></a> + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100"> 100</span> +<span id="101"> 101</span> +<span id="102"> 102</span> +<span id="103"> 103</span> +<span id="104"> 104</span> +<span id="105"> 105</span> +<span id="106"> 106</span> +<span id="107"> 107</span> +<span id="108"> 108</span> +<span id="109"> 109</span> +<span id="110"> 110</span> +<span id="111"> 111</span> +<span id="112"> 112</span> +<span id="113"> 113</span> +<span id="114"> 114</span> +<span id="115"> 115</span> +<span id="116"> 116</span> +<span id="117"> 117</span> +<span id="118"> 118</span> +<span id="119"> 119</span> +<span id="120"> 120</span> +<span id="121"> 121</span> +<span id="122"> 122</span> +<span id="123"> 123</span> +<span id="124"> 124</span> +<span id="125"> 125</span> +<span id="126"> 126</span> +<span id="127"> 127</span> +<span id="128"> 128</span> +<span id="129"> 129</span> +<span id="130"> 130</span> +<span id="131"> 131</span> +<span id="132"> 132</span> +<span id="133"> 133</span> +<span id="134"> 134</span> +<span id="135"> 135</span> +<span id="136"> 136</span> +<span id="137"> 137</span> +<span id="138"> 138</span> +<span id="139"> 139</span> +<span id="140"> 140</span> +<span id="141"> 141</span> +<span id="142"> 142</span> +<span id="143"> 143</span> +<span id="144"> 144</span> +<span id="145"> 145</span> +<span id="146"> 146</span> +<span id="147"> 147</span> +<span id="148"> 148</span> +<span id="149"> 149</span> +<span id="150"> 150</span> +<span id="151"> 151</span> +<span id="152"> 152</span> +<span id="153"> 153</span> +<span id="154"> 154</span> +<span id="155"> 155</span> +<span id="156"> 156</span> +<span id="157"> 157</span> +<span id="158"> 158</span> +<span id="159"> 159</span> +<span id="160"> 160</span> +<span id="161"> 161</span> +<span id="162"> 162</span> +<span id="163"> 163</span> +<span id="164"> 164</span> +<span id="165"> 165</span> +<span id="166"> 166</span> +<span id="167"> 167</span> +<span id="168"> 168</span> +<span id="169"> 169</span> +<span id="170"> 170</span> +<span id="171"> 171</span> +<span id="172"> 172</span> +<span id="173"> 173</span> +<span id="174"> 174</span> +<span id="175"> 175</span> +<span id="176"> 176</span> +<span id="177"> 177</span> +<span id="178"> 178</span> +<span id="179"> 179</span> +<span id="180"> 180</span> +<span id="181"> 181</span> +<span id="182"> 182</span> +<span id="183"> 183</span> +<span id="184"> 184</span> +<span id="185"> 185</span> +<span id="186"> 186</span> +<span id="187"> 187</span> +<span id="188"> 188</span> +<span id="189"> 189</span> +<span id="190"> 190</span> +<span id="191"> 191</span> +<span id="192"> 192</span> +<span id="193"> 193</span> +<span id="194"> 194</span> +<span id="195"> 195</span> +<span id="196"> 196</span> +<span id="197"> 197</span> +<span id="198"> 198</span> +<span id="199"> 199</span> +<span id="200"> 200</span> +<span id="201"> 201</span> +<span id="202"> 202</span> +<span id="203"> 203</span> +<span id="204"> 204</span> +<span id="205"> 205</span> +<span id="206"> 206</span> +<span id="207"> 207</span> +<span id="208"> 208</span> +<span id="209"> 209</span> +<span id="210"> 210</span> +<span id="211"> 211</span> +<span id="212"> 212</span> +<span id="213"> 213</span> +<span id="214"> 214</span> +<span id="215"> 215</span> +<span id="216"> 216</span> +<span id="217"> 217</span> +<span id="218"> 218</span> +<span id="219"> 219</span> +<span id="220"> 220</span> +<span id="221"> 221</span> +<span id="222"> 222</span> +<span id="223"> 223</span> +<span id="224"> 224</span> +<span id="225"> 225</span> +<span id="226"> 226</span> +<span id="227"> 227</span> +<span id="228"> 228</span> +<span id="229"> 229</span> +<span id="230"> 230</span> +<span id="231"> 231</span> +<span id="232"> 232</span> +<span id="233"> 233</span> +<span id="234"> 234</span> +<span id="235"> 235</span> +<span id="236"> 236</span> +<span id="237"> 237</span> +<span id="238"> 238</span> +<span id="239"> 239</span> +<span id="240"> 240</span> +<span id="241"> 241</span> +<span id="242"> 242</span> +<span id="243"> 243</span> +<span id="244"> 244</span> +<span id="245"> 245</span> +<span id="246"> 246</span> +<span id="247"> 247</span> +<span id="248"> 248</span> +<span id="249"> 249</span> +<span id="250"> 250</span> +<span id="251"> 251</span> +<span id="252"> 252</span> +<span id="253"> 253</span> +<span id="254"> 254</span> +<span id="255"> 255</span> +<span id="256"> 256</span> +<span id="257"> 257</span> +<span id="258"> 258</span> +<span id="259"> 259</span> +<span id="260"> 260</span> +<span id="261"> 261</span> +<span id="262"> 262</span> +<span id="263"> 263</span> +<span id="264"> 264</span> +<span id="265"> 265</span> +<span id="266"> 266</span> +<span id="267"> 267</span> +<span id="268"> 268</span> +<span id="269"> 269</span> +<span id="270"> 270</span> +<span id="271"> 271</span> +<span id="272"> 272</span> +<span id="273"> 273</span> +<span id="274"> 274</span> +<span id="275"> 275</span> +<span id="276"> 276</span> +<span id="277"> 277</span> +<span id="278"> 278</span> +<span id="279"> 279</span> +<span id="280"> 280</span> +<span id="281"> 281</span> +<span id="282"> 282</span> +<span id="283"> 283</span> +<span id="284"> 284</span> +<span id="285"> 285</span> +<span id="286"> 286</span> +<span id="287"> 287</span> +<span id="288"> 288</span> +<span id="289"> 289</span> +<span id="290"> 290</span> +<span id="291"> 291</span> +<span id="292"> 292</span> +<span id="293"> 293</span> +<span id="294"> 294</span> +<span id="295"> 295</span> +<span id="296"> 296</span> +<span id="297"> 297</span> +<span id="298"> 298</span> +<span id="299"> 299</span> +<span id="300"> 300</span> +<span id="301"> 301</span> +<span id="302"> 302</span> +<span id="303"> 303</span> +<span id="304"> 304</span> +<span id="305"> 305</span> +<span id="306"> 306</span> +<span id="307"> 307</span> +<span id="308"> 308</span> +<span id="309"> 309</span> +<span id="310"> 310</span> +<span id="311"> 311</span> +<span id="312"> 312</span> +<span id="313"> 313</span> +<span id="314"> 314</span> +<span id="315"> 315</span> +<span id="316"> 316</span> +<span id="317"> 317</span> +<span id="318"> 318</span> +<span id="319"> 319</span> +<span id="320"> 320</span> +<span id="321"> 321</span> +<span id="322"> 322</span> +<span id="323"> 323</span> +<span id="324"> 324</span> +<span id="325"> 325</span> +<span id="326"> 326</span> +<span id="327"> 327</span> +<span id="328"> 328</span> +<span id="329"> 329</span> +<span id="330"> 330</span> +<span id="331"> 331</span> +<span id="332"> 332</span> +<span id="333"> 333</span> +<span id="334"> 334</span> +<span id="335"> 335</span> +<span id="336"> 336</span> +<span id="337"> 337</span> +<span id="338"> 338</span> +<span id="339"> 339</span> +<span id="340"> 340</span> +<span id="341"> 341</span> +<span id="342"> 342</span> +<span id="343"> 343</span> +<span id="344"> 344</span> +<span id="345"> 345</span> +<span id="346"> 346</span> +<span id="347"> 347</span> +<span id="348"> 348</span> +<span id="349"> 349</span> +<span id="350"> 350</span> +<span id="351"> 351</span> +<span id="352"> 352</span> +<span id="353"> 353</span> +<span id="354"> 354</span> +<span id="355"> 355</span> +<span id="356"> 356</span> +<span id="357"> 357</span> +<span id="358"> 358</span> +<span id="359"> 359</span> +<span id="360"> 360</span> +<span id="361"> 361</span> +<span id="362"> 362</span> +<span id="363"> 363</span> +<span id="364"> 364</span> +<span id="365"> 365</span> +<span id="366"> 366</span> +<span id="367"> 367</span> +<span id="368"> 368</span> +<span id="369"> 369</span> +<span id="370"> 370</span> +<span id="371"> 371</span> +<span id="372"> 372</span> +<span id="373"> 373</span> +<span id="374"> 374</span> +<span id="375"> 375</span> +<span id="376"> 376</span> +<span id="377"> 377</span> +<span id="378"> 378</span> +<span id="379"> 379</span> +<span id="380"> 380</span> +<span id="381"> 381</span> +<span id="382"> 382</span> +<span id="383"> 383</span> +<span id="384"> 384</span> +<span id="385"> 385</span> +<span id="386"> 386</span> +<span id="387"> 387</span> +<span id="388"> 388</span> +<span id="389"> 389</span> +<span id="390"> 390</span> +<span id="391"> 391</span> +<span id="392"> 392</span> +<span id="393"> 393</span> +<span id="394"> 394</span> +<span id="395"> 395</span> +<span id="396"> 396</span> +<span id="397"> 397</span> +<span id="398"> 398</span> +<span id="399"> 399</span> +<span id="400"> 400</span> +<span id="401"> 401</span> +<span id="402"> 402</span> +<span id="403"> 403</span> +<span id="404"> 404</span> +<span id="405"> 405</span> +<span id="406"> 406</span> +<span id="407"> 407</span> +<span id="408"> 408</span> +<span id="409"> 409</span> +<span id="410"> 410</span> +<span id="411"> 411</span> +<span id="412"> 412</span> +<span id="413"> 413</span> +<span id="414"> 414</span> +<span id="415"> 415</span> +<span id="416"> 416</span> +<span id="417"> 417</span> +<span id="418"> 418</span> +<span id="419"> 419</span> +<span id="420"> 420</span> +<span id="421"> 421</span> +<span id="422"> 422</span> +<span id="423"> 423</span> +<span id="424"> 424</span> +<span id="425"> 425</span> +<span id="426"> 426</span> +<span id="427"> 427</span> +<span id="428"> 428</span> +<span id="429"> 429</span> +<span id="430"> 430</span> +<span id="431"> 431</span> +<span id="432"> 432</span> +<span id="433"> 433</span> +<span id="434"> 434</span> +<span id="435"> 435</span> +<span id="436"> 436</span> +<span id="437"> 437</span> +<span id="438"> 438</span> +<span id="439"> 439</span> +<span id="440"> 440</span> +<span id="441"> 441</span> +<span id="442"> 442</span> +<span id="443"> 443</span> +<span id="444"> 444</span> +<span id="445"> 445</span> +<span id="446"> 446</span> +<span id="447"> 447</span> +<span id="448"> 448</span> +<span id="449"> 449</span> +<span id="450"> 450</span> +<span id="451"> 451</span> +<span id="452"> 452</span> +<span id="453"> 453</span> +<span id="454"> 454</span> +<span id="455"> 455</span> +<span id="456"> 456</span> +<span id="457"> 457</span> +<span id="458"> 458</span> +<span id="459"> 459</span> +<span id="460"> 460</span> +<span id="461"> 461</span> +<span id="462"> 462</span> +<span id="463"> 463</span> +<span id="464"> 464</span> +<span id="465"> 465</span> +<span id="466"> 466</span> +<span id="467"> 467</span> +<span id="468"> 468</span> +<span id="469"> 469</span> +<span id="470"> 470</span> +<span id="471"> 471</span> +<span id="472"> 472</span> +<span id="473"> 473</span> +<span id="474"> 474</span> +<span id="475"> 475</span> +<span id="476"> 476</span> +<span id="477"> 477</span> +<span id="478"> 478</span> +<span id="479"> 479</span> +<span id="480"> 480</span> +<span id="481"> 481</span> +<span id="482"> 482</span> +<span id="483"> 483</span> +<span id="484"> 484</span> +<span id="485"> 485</span> +<span id="486"> 486</span> +<span id="487"> 487</span> +<span id="488"> 488</span> +<span id="489"> 489</span> +<span id="490"> 490</span> +<span id="491"> 491</span> +<span id="492"> 492</span> +<span id="493"> 493</span> +<span id="494"> 494</span> +<span id="495"> 495</span> +<span id="496"> 496</span> +<span id="497"> 497</span> +<span id="498"> 498</span> +<span id="499"> 499</span> +<span id="500"> 500</span> +<span id="501"> 501</span> +<span id="502"> 502</span> +<span id="503"> 503</span> +<span id="504"> 504</span> +<span id="505"> 505</span> +<span id="506"> 506</span> +<span id="507"> 507</span> +<span id="508"> 508</span> +<span id="509"> 509</span> +<span id="510"> 510</span> +<span id="511"> 511</span> +<span id="512"> 512</span> +<span id="513"> 513</span> +<span id="514"> 514</span> +<span id="515"> 515</span> +<span id="516"> 516</span> +<span id="517"> 517</span> +<span id="518"> 518</span> +<span id="519"> 519</span> +<span id="520"> 520</span> +<span id="521"> 521</span> +<span id="522"> 522</span> +<span id="523"> 523</span> +<span id="524"> 524</span> +<span id="525"> 525</span> +<span id="526"> 526</span> +<span id="527"> 527</span> +<span id="528"> 528</span> +<span id="529"> 529</span> +<span id="530"> 530</span> +<span id="531"> 531</span> +<span id="532"> 532</span> +<span id="533"> 533</span> +<span id="534"> 534</span> +<span id="535"> 535</span> +<span id="536"> 536</span> +<span id="537"> 537</span> +<span id="538"> 538</span> +<span id="539"> 539</span> +<span id="540"> 540</span> +<span id="541"> 541</span> +<span id="542"> 542</span> +<span id="543"> 543</span> +<span id="544"> 544</span> +<span id="545"> 545</span> +<span id="546"> 546</span> +<span id="547"> 547</span> +<span id="548"> 548</span> +<span id="549"> 549</span> +<span id="550"> 550</span> +<span id="551"> 551</span> +<span id="552"> 552</span> +<span id="553"> 553</span> +<span id="554"> 554</span> +<span id="555"> 555</span> +<span id="556"> 556</span> +<span id="557"> 557</span> +<span id="558"> 558</span> +<span id="559"> 559</span> +<span id="560"> 560</span> +<span id="561"> 561</span> +<span id="562"> 562</span> +<span id="563"> 563</span> +<span id="564"> 564</span> +<span id="565"> 565</span> +<span id="566"> 566</span> +<span id="567"> 567</span> +<span id="568"> 568</span> +<span id="569"> 569</span> +<span id="570"> 570</span> +<span id="571"> 571</span> +<span id="572"> 572</span> +<span id="573"> 573</span> +<span id="574"> 574</span> +<span id="575"> 575</span> +<span id="576"> 576</span> +<span id="577"> 577</span> +<span id="578"> 578</span> +<span id="579"> 579</span> +<span id="580"> 580</span> +<span id="581"> 581</span> +<span id="582"> 582</span> +<span id="583"> 583</span> +<span id="584"> 584</span> +<span id="585"> 585</span> +<span id="586"> 586</span> +<span id="587"> 587</span> +<span id="588"> 588</span> +<span id="589"> 589</span> +<span id="590"> 590</span> +<span id="591"> 591</span> +<span id="592"> 592</span> +<span id="593"> 593</span> +<span id="594"> 594</span> +<span id="595"> 595</span> +<span id="596"> 596</span> +<span id="597"> 597</span> +<span id="598"> 598</span> +<span id="599"> 599</span> +<span id="600"> 600</span> +<span id="601"> 601</span> +<span id="602"> 602</span> +<span id="603"> 603</span> +<span id="604"> 604</span> +<span id="605"> 605</span> +<span id="606"> 606</span> +<span id="607"> 607</span> +<span id="608"> 608</span> +<span id="609"> 609</span> +<span id="610"> 610</span> +<span id="611"> 611</span> +<span id="612"> 612</span> +<span id="613"> 613</span> +<span id="614"> 614</span> +<span id="615"> 615</span> +<span id="616"> 616</span> +<span id="617"> 617</span> +<span id="618"> 618</span> +<span id="619"> 619</span> +<span id="620"> 620</span> +<span id="621"> 621</span> +<span id="622"> 622</span> +<span id="623"> 623</span> +<span id="624"> 624</span> +<span id="625"> 625</span> +<span id="626"> 626</span> +<span id="627"> 627</span> +<span id="628"> 628</span> +<span id="629"> 629</span> +<span id="630"> 630</span> +<span id="631"> 631</span> +<span id="632"> 632</span> +<span id="633"> 633</span> +<span id="634"> 634</span> +<span id="635"> 635</span> +<span id="636"> 636</span> +<span id="637"> 637</span> +<span id="638"> 638</span> +<span id="639"> 639</span> +<span id="640"> 640</span> +<span id="641"> 641</span> +<span id="642"> 642</span> +<span id="643"> 643</span> +<span id="644"> 644</span> +<span id="645"> 645</span> +<span id="646"> 646</span> +<span id="647"> 647</span> +<span id="648"> 648</span> +<span id="649"> 649</span> +<span id="650"> 650</span> +<span id="651"> 651</span> +<span id="652"> 652</span> +<span id="653"> 653</span> +<span id="654"> 654</span> +<span id="655"> 655</span> +<span id="656"> 656</span> +<span id="657"> 657</span> +<span id="658"> 658</span> +<span id="659"> 659</span> +<span id="660"> 660</span> +<span id="661"> 661</span> +<span id="662"> 662</span> +<span id="663"> 663</span> +<span id="664"> 664</span> +<span id="665"> 665</span> +<span id="666"> 666</span> +<span id="667"> 667</span> +<span id="668"> 668</span> +<span id="669"> 669</span> +<span id="670"> 670</span> +<span id="671"> 671</span> +<span id="672"> 672</span> +<span id="673"> 673</span> +<span id="674"> 674</span> +<span id="675"> 675</span> +<span id="676"> 676</span> +<span id="677"> 677</span> +<span id="678"> 678</span> +<span id="679"> 679</span> +<span id="680"> 680</span> +<span id="681"> 681</span> +<span id="682"> 682</span> +<span id="683"> 683</span> +<span id="684"> 684</span> +<span id="685"> 685</span> +<span id="686"> 686</span> +<span id="687"> 687</span> +<span id="688"> 688</span> +<span id="689"> 689</span> +<span id="690"> 690</span> +<span id="691"> 691</span> +<span id="692"> 692</span> +<span id="693"> 693</span> +<span id="694"> 694</span> +<span id="695"> 695</span> +<span id="696"> 696</span> +<span id="697"> 697</span> +<span id="698"> 698</span> +<span id="699"> 699</span> +<span id="700"> 700</span> +<span id="701"> 701</span> +<span id="702"> 702</span> +<span id="703"> 703</span> +<span id="704"> 704</span> +<span id="705"> 705</span> +<span id="706"> 706</span> +<span id="707"> 707</span> +<span id="708"> 708</span> +<span id="709"> 709</span> +<span id="710"> 710</span> +<span id="711"> 711</span> +<span id="712"> 712</span> +<span id="713"> 713</span> +<span id="714"> 714</span> +<span id="715"> 715</span> +<span id="716"> 716</span> +<span id="717"> 717</span> +<span id="718"> 718</span> +<span id="719"> 719</span> +<span id="720"> 720</span> +<span id="721"> 721</span> +<span id="722"> 722</span> +<span id="723"> 723</span> +<span id="724"> 724</span> +<span id="725"> 725</span> +<span id="726"> 726</span> +<span id="727"> 727</span> +<span id="728"> 728</span> +<span id="729"> 729</span> +<span id="730"> 730</span> +<span id="731"> 731</span> +<span id="732"> 732</span> +<span id="733"> 733</span> +<span id="734"> 734</span> +<span id="735"> 735</span> +<span id="736"> 736</span> +<span id="737"> 737</span> +<span id="738"> 738</span> +<span id="739"> 739</span> +<span id="740"> 740</span> +<span id="741"> 741</span> +<span id="742"> 742</span> +<span id="743"> 743</span> +<span id="744"> 744</span> +<span id="745"> 745</span> +<span id="746"> 746</span> +<span id="747"> 747</span> +<span id="748"> 748</span> +<span id="749"> 749</span> +<span id="750"> 750</span> +<span id="751"> 751</span> +<span id="752"> 752</span> +<span id="753"> 753</span> +<span id="754"> 754</span> +<span id="755"> 755</span> +<span id="756"> 756</span> +<span id="757"> 757</span> +<span id="758"> 758</span> +<span id="759"> 759</span> +<span id="760"> 760</span> +<span id="761"> 761</span> +<span id="762"> 762</span> +<span id="763"> 763</span> +<span id="764"> 764</span> +<span id="765"> 765</span> +<span id="766"> 766</span> +<span id="767"> 767</span> +<span id="768"> 768</span> +<span id="769"> 769</span> +<span id="770"> 770</span> +<span id="771"> 771</span> +<span id="772"> 772</span> +<span id="773"> 773</span> +<span id="774"> 774</span> +<span id="775"> 775</span> +<span id="776"> 776</span> +<span id="777"> 777</span> +<span id="778"> 778</span> +<span id="779"> 779</span> +<span id="780"> 780</span> +<span id="781"> 781</span> +<span id="782"> 782</span> +<span id="783"> 783</span> +<span id="784"> 784</span> +<span id="785"> 785</span> +<span id="786"> 786</span> +<span id="787"> 787</span> +<span id="788"> 788</span> +<span id="789"> 789</span> +<span id="790"> 790</span> +<span id="791"> 791</span> +<span id="792"> 792</span> +<span id="793"> 793</span> +<span id="794"> 794</span> +<span id="795"> 795</span> +<span id="796"> 796</span> +<span id="797"> 797</span> +<span id="798"> 798</span> +<span id="799"> 799</span> +<span id="800"> 800</span> +<span id="801"> 801</span> +<span id="802"> 802</span> +<span id="803"> 803</span> +<span id="804"> 804</span> +<span id="805"> 805</span> +<span id="806"> 806</span> +<span id="807"> 807</span> +<span id="808"> 808</span> +<span id="809"> 809</span> +<span id="810"> 810</span> +<span id="811"> 811</span> +<span id="812"> 812</span> +<span id="813"> 813</span> +<span id="814"> 814</span> +<span id="815"> 815</span> +<span id="816"> 816</span> +<span id="817"> 817</span> +<span id="818"> 818</span> +<span id="819"> 819</span> +<span id="820"> 820</span> +<span id="821"> 821</span> +<span id="822"> 822</span> +<span id="823"> 823</span> +<span id="824"> 824</span> +<span id="825"> 825</span> +<span id="826"> 826</span> +<span id="827"> 827</span> +<span id="828"> 828</span> +<span id="829"> 829</span> +<span id="830"> 830</span> +<span id="831"> 831</span> +<span id="832"> 832</span> +<span id="833"> 833</span> +<span id="834"> 834</span> +<span id="835"> 835</span> +<span id="836"> 836</span> +<span id="837"> 837</span> +<span id="838"> 838</span> +<span id="839"> 839</span> +<span id="840"> 840</span> +<span id="841"> 841</span> +<span id="842"> 842</span> +<span id="843"> 843</span> +<span id="844"> 844</span> +<span id="845"> 845</span> +<span id="846"> 846</span> +<span id="847"> 847</span> +<span id="848"> 848</span> +<span id="849"> 849</span> +<span id="850"> 850</span> +<span id="851"> 851</span> +<span id="852"> 852</span> +<span id="853"> 853</span> +<span id="854"> 854</span> +<span id="855"> 855</span> +<span id="856"> 856</span> +<span id="857"> 857</span> +<span id="858"> 858</span> +<span id="859"> 859</span> +<span id="860"> 860</span> +<span id="861"> 861</span> +<span id="862"> 862</span> +<span id="863"> 863</span> +<span id="864"> 864</span> +<span id="865"> 865</span> +<span id="866"> 866</span> +<span id="867"> 867</span> +<span id="868"> 868</span> +<span id="869"> 869</span> +<span id="870"> 870</span> +<span id="871"> 871</span> +<span id="872"> 872</span> +<span id="873"> 873</span> +<span id="874"> 874</span> +<span id="875"> 875</span> +<span id="876"> 876</span> +<span id="877"> 877</span> +<span id="878"> 878</span> +<span id="879"> 879</span> +<span id="880"> 880</span> +<span id="881"> 881</span> +<span id="882"> 882</span> +<span id="883"> 883</span> +<span id="884"> 884</span> +<span id="885"> 885</span> +<span id="886"> 886</span> +<span id="887"> 887</span> +<span id="888"> 888</span> +<span id="889"> 889</span> +<span id="890"> 890</span> +<span id="891"> 891</span> +<span id="892"> 892</span> +<span id="893"> 893</span> +<span id="894"> 894</span> +<span id="895"> 895</span> +<span id="896"> 896</span> +<span id="897"> 897</span> +<span id="898"> 898</span> +<span id="899"> 899</span> +<span id="900"> 900</span> +<span id="901"> 901</span> +<span id="902"> 902</span> +<span id="903"> 903</span> +<span id="904"> 904</span> +<span id="905"> 905</span> +<span id="906"> 906</span> +<span id="907"> 907</span> +<span id="908"> 908</span> +<span id="909"> 909</span> +<span id="910"> 910</span> +<span id="911"> 911</span> +<span id="912"> 912</span> +<span id="913"> 913</span> +<span id="914"> 914</span> +<span id="915"> 915</span> +<span id="916"> 916</span> +<span id="917"> 917</span> +<span id="918"> 918</span> +<span id="919"> 919</span> +<span id="920"> 920</span> +<span id="921"> 921</span> +<span id="922"> 922</span> +<span id="923"> 923</span> +<span id="924"> 924</span> +<span id="925"> 925</span> +<span id="926"> 926</span> +<span id="927"> 927</span> +<span id="928"> 928</span> +<span id="929"> 929</span> +<span id="930"> 930</span> +<span id="931"> 931</span> +<span id="932"> 932</span> +<span id="933"> 933</span> +<span id="934"> 934</span> +<span id="935"> 935</span> +<span id="936"> 936</span> +<span id="937"> 937</span> +<span id="938"> 938</span> +<span id="939"> 939</span> +<span id="940"> 940</span> +<span id="941"> 941</span> +<span id="942"> 942</span> +<span id="943"> 943</span> +<span id="944"> 944</span> +<span id="945"> 945</span> +<span id="946"> 946</span> +<span id="947"> 947</span> +<span id="948"> 948</span> +<span id="949"> 949</span> +<span id="950"> 950</span> +<span id="951"> 951</span> +<span id="952"> 952</span> +<span id="953"> 953</span> +<span id="954"> 954</span> +<span id="955"> 955</span> +<span id="956"> 956</span> +<span id="957"> 957</span> +<span id="958"> 958</span> +<span id="959"> 959</span> +<span id="960"> 960</span> +<span id="961"> 961</span> +<span id="962"> 962</span> +<span id="963"> 963</span> +<span id="964"> 964</span> +<span id="965"> 965</span> +<span id="966"> 966</span> +<span id="967"> 967</span> +<span id="968"> 968</span> +<span id="969"> 969</span> +<span id="970"> 970</span> +<span id="971"> 971</span> +<span id="972"> 972</span> +<span id="973"> 973</span> +<span id="974"> 974</span> +<span id="975"> 975</span> +<span id="976"> 976</span> +<span id="977"> 977</span> +<span id="978"> 978</span> +<span id="979"> 979</span> +<span id="980"> 980</span> +<span id="981"> 981</span> +<span id="982"> 982</span> +<span id="983"> 983</span> +<span id="984"> 984</span> +<span id="985"> 985</span> +<span id="986"> 986</span> +<span id="987"> 987</span> +<span id="988"> 988</span> +<span id="989"> 989</span> +<span id="990"> 990</span> +<span id="991"> 991</span> +<span id="992"> 992</span> +<span id="993"> 993</span> +<span id="994"> 994</span> +<span id="995"> 995</span> +<span id="996"> 996</span> +<span id="997"> 997</span> +<span id="998"> 998</span> +<span id="999"> 999</span> +<span id="1000">1000</span> +<span id="1001">1001</span> +<span id="1002">1002</span> +<span id="1003">1003</span> +<span id="1004">1004</span> +<span id="1005">1005</span> +<span id="1006">1006</span> +<span id="1007">1007</span> +<span id="1008">1008</span> +<span id="1009">1009</span> +<span id="1010">1010</span> +<span id="1011">1011</span> +<span id="1012">1012</span> +<span id="1013">1013</span> +<span id="1014">1014</span> +<span id="1015">1015</span> +<span id="1016">1016</span> +<span id="1017">1017</span> +<span id="1018">1018</span> +<span id="1019">1019</span> +<span id="1020">1020</span> +<span id="1021">1021</span> +<span id="1022">1022</span> +<span id="1023">1023</span> +<span id="1024">1024</span> +<span id="1025">1025</span> +<span id="1026">1026</span> +<span id="1027">1027</span> +<span id="1028">1028</span> +<span id="1029">1029</span> +<span id="1030">1030</span> +<span id="1031">1031</span> +<span id="1032">1032</span> +<span id="1033">1033</span> +<span id="1034">1034</span> +<span id="1035">1035</span> +<span id="1036">1036</span> +<span id="1037">1037</span> +<span id="1038">1038</span> +<span id="1039">1039</span> +<span id="1040">1040</span> +<span id="1041">1041</span> +<span id="1042">1042</span> +<span id="1043">1043</span> +<span id="1044">1044</span> +<span id="1045">1045</span> +<span id="1046">1046</span> +<span id="1047">1047</span> +<span id="1048">1048</span> +<span id="1049">1049</span> +<span id="1050">1050</span> +<span id="1051">1051</span> +<span id="1052">1052</span> +<span id="1053">1053</span> +<span id="1054">1054</span> +<span id="1055">1055</span> +<span id="1056">1056</span> +<span id="1057">1057</span> +<span id="1058">1058</span> +<span id="1059">1059</span> +<span id="1060">1060</span> +<span id="1061">1061</span> +<span id="1062">1062</span> +<span id="1063">1063</span> +<span id="1064">1064</span> +<span id="1065">1065</span> +<span id="1066">1066</span> +<span id="1067">1067</span> +<span id="1068">1068</span> +<span id="1069">1069</span> +<span id="1070">1070</span> +<span id="1071">1071</span> +<span id="1072">1072</span> +<span id="1073">1073</span> +<span id="1074">1074</span> +<span id="1075">1075</span> +<span id="1076">1076</span> +<span id="1077">1077</span> +<span id="1078">1078</span> +<span id="1079">1079</span> +<span id="1080">1080</span> +<span id="1081">1081</span> +<span id="1082">1082</span> +<span id="1083">1083</span> +<span id="1084">1084</span> +<span id="1085">1085</span> +<span id="1086">1086</span> +<span id="1087">1087</span> +<span id="1088">1088</span> +<span id="1089">1089</span> +<span id="1090">1090</span> +<span id="1091">1091</span> +<span id="1092">1092</span> +<span id="1093">1093</span> +<span id="1094">1094</span> +<span id="1095">1095</span> +<span id="1096">1096</span> +<span id="1097">1097</span> +<span id="1098">1098</span> +<span id="1099">1099</span> +<span id="1100">1100</span> +<span id="1101">1101</span> +<span id="1102">1102</span> +<span id="1103">1103</span> +<span id="1104">1104</span> +<span id="1105">1105</span> +<span id="1106">1106</span> +<span id="1107">1107</span> +<span id="1108">1108</span> +<span id="1109">1109</span> +<span id="1110">1110</span> +<span id="1111">1111</span> +<span id="1112">1112</span> +<span id="1113">1113</span> +<span id="1114">1114</span> +<span id="1115">1115</span> +<span id="1116">1116</span> +<span id="1117">1117</span> +<span id="1118">1118</span> +<span id="1119">1119</span> +<span id="1120">1120</span> +<span id="1121">1121</span> +<span id="1122">1122</span> +<span id="1123">1123</span> +<span id="1124">1124</span> +<span id="1125">1125</span> +<span id="1126">1126</span> +<span id="1127">1127</span> +<span id="1128">1128</span> +<span id="1129">1129</span> +<span id="1130">1130</span> +<span id="1131">1131</span> +<span id="1132">1132</span> +<span id="1133">1133</span> +<span id="1134">1134</span> +<span id="1135">1135</span> +<span id="1136">1136</span> +<span id="1137">1137</span> +<span id="1138">1138</span> +<span id="1139">1139</span> +<span id="1140">1140</span> +<span id="1141">1141</span> +<span id="1142">1142</span> +<span id="1143">1143</span> +<span id="1144">1144</span> +<span id="1145">1145</span> +<span id="1146">1146</span> +<span id="1147">1147</span> +<span id="1148">1148</span> +</pre><pre class='rust '> +<span class='comment'>// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT</span> +<span class='comment'>// file at the top-level directory of this distribution and at</span> +<span class='comment'>// http://rust-lang.org/COPYRIGHT.</span> +<span class='comment'>//</span> +<span class='comment'>// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or</span> +<span class='comment'>// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license</span> +<span class='comment'>// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your</span> +<span class='comment'>// option. This file may not be copied, modified, or distributed</span> +<span class='comment'>// except according to those terms.</span> + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>borrow</span>::<span class='ident'>Cow</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>hash_map</span>::<span class='ident'>Iter</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>fmt</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"pattern"</span>)]</span> +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>pattern</span>::{<span class='ident'>Pattern</span>, <span class='ident'>Searcher</span>, <span class='ident'>SearchStep</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>str</span>::<span class='ident'>FromStr</span>; + +<span class='kw'>use</span> <span class='ident'>program</span>::{<span class='ident'>Program</span>, <span class='ident'>MatchEngine</span>}; +<span class='kw'>use</span> <span class='ident'>syntax</span>; + +<span class='kw'>const</span> <span class='ident'>REPLACE_EXPAND</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span> <span class='op'>=</span> <span class='string'>r"(?x) + (?P<before>^|\b|[^$]) # Ignore `$$name`. + \$ + (?P<name> # Match the actual capture name. Can be... + [0-9]+ # A sequence of digits (for indexed captures), or... + | + [_a-zA-Z][_0-9a-zA-Z]* # A name for named captures. + ) +"</span>; + +<span class='doccomment'>/// Type alias for representing capture indices.</span> +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>CaptureIdxs</span> <span class='op'>=</span> [<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span>]; + +<span class='doccomment'>/// Escapes all regular expression meta characters in `text`.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The string returned may be safely used as a literal in a regular</span> +<span class='doccomment'>/// expression.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>quote</span>(<span class='ident'>text</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>quoted</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='ident'>text</span>.<span class='ident'>len</span>()); + <span class='kw'>for</span> <span class='ident'>c</span> <span class='kw'>in</span> <span class='ident'>text</span>.<span class='ident'>chars</span>() { + <span class='kw'>if</span> <span class='ident'>syntax</span>::<span class='ident'>is_punct</span>(<span class='ident'>c</span>) { + <span class='ident'>quoted</span>.<span class='ident'>push</span>(<span class='string'>'\\'</span>) + } + <span class='ident'>quoted</span>.<span class='ident'>push</span>(<span class='ident'>c</span>); + } + <span class='ident'>quoted</span> +} + +<span class='doccomment'>/// Tests if the given regular expression matches somewhere in the text given.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// If there was a problem compiling the regular expression, an error is</span> +<span class='doccomment'>/// returned.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// To find submatches, split or replace text, you'll need to compile an</span> +<span class='doccomment'>/// expression first.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_match</span>(<span class='ident'>regex</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>bool</span>, <span class='ident'>Error</span><span class='op'>></span> { + <span class='ident'>Regex</span>::<span class='ident'>new</span>(<span class='ident'>regex</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>r</span><span class='op'>|</span> <span class='ident'>r</span>.<span class='ident'>is_match</span>(<span class='ident'>text</span>)) +} + +<span class='doccomment'>/// An error that occurred during parsing or compiling a regular expression.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Error</span> { + <span class='doccomment'>/// A syntax error.</span> + <span class='ident'>Syntax</span>(<span class='ident'>syntax</span>::<span class='ident'>Error</span>), + <span class='doccomment'>/// The compiled program exceeded the set size limit.</span> + <span class='doccomment'>/// The argument is the size limit imposed.</span> + <span class='ident'>CompiledTooBig</span>(<span class='ident'>usize</span>), + <span class='doccomment'>/// Hints that destructuring should not be exhaustive.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This enum may grow additional variants, so this makes sure clients</span> + <span class='doccomment'>/// don't count on exhaustive matching. (Otherwise, adding a new variant</span> + <span class='doccomment'>/// could break existing code.)</span> + <span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> + <span class='ident'>__Nonexhaustive</span>, +} + +<span class='kw'>impl</span> ::<span class='ident'>std</span>::<span class='ident'>error</span>::<span class='ident'>Error</span> <span class='kw'>for</span> <span class='ident'>Error</span> { + <span class='kw'>fn</span> <span class='ident'>description</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>str</span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>Error</span>::<span class='ident'>Syntax</span>(<span class='kw-2'>ref</span> <span class='ident'>err</span>) <span class='op'>=></span> <span class='ident'>err</span>.<span class='ident'>description</span>(), + <span class='ident'>Error</span>::<span class='ident'>CompiledTooBig</span>(_) <span class='op'>=></span> <span class='string'>"compiled program too big"</span>, + <span class='ident'>Error</span>::<span class='ident'>__Nonexhaustive</span> <span class='op'>=></span> <span class='macro'>unreachable</span><span class='macro'>!</span>(), + } + } + + <span class='kw'>fn</span> <span class='ident'>cause</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span>::<span class='ident'>std</span>::<span class='ident'>error</span>::<span class='ident'>Error</span><span class='op'>></span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>Error</span>::<span class='ident'>Syntax</span>(<span class='kw-2'>ref</span> <span class='ident'>err</span>) <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='ident'>err</span>), + _ <span class='op'>=></span> <span class='prelude-val'>None</span>, + } + } +} + +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Display</span> <span class='kw'>for</span> <span class='ident'>Error</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>Error</span>::<span class='ident'>Syntax</span>(<span class='kw-2'>ref</span> <span class='ident'>err</span>) <span class='op'>=></span> <span class='ident'>err</span>.<span class='ident'>fmt</span>(<span class='ident'>f</span>), + <span class='ident'>Error</span>::<span class='ident'>CompiledTooBig</span>(<span class='ident'>limit</span>) <span class='op'>=></span> { + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Compiled regex exceeds size limit of {} bytes."</span>, + <span class='ident'>limit</span>) + } + <span class='ident'>Error</span>::<span class='ident'>__Nonexhaustive</span> <span class='op'>=></span> <span class='macro'>unreachable</span><span class='macro'>!</span>(), + } + } +} + +<span class='kw'>impl</span> <span class='ident'>From</span><span class='op'><</span><span class='ident'>syntax</span>::<span class='ident'>Error</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>Error</span> { + <span class='kw'>fn</span> <span class='ident'>from</span>(<span class='ident'>err</span>: <span class='ident'>syntax</span>::<span class='ident'>Error</span>) <span class='op'>-></span> <span class='ident'>Error</span> { + <span class='ident'>Error</span>::<span class='ident'>Syntax</span>(<span class='ident'>err</span>) + } +} + +<span class='doccomment'>/// A compiled regular expression</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// It is represented as either a sequence of bytecode instructions (dynamic)</span> +<span class='doccomment'>/// or as a specialized Rust function (native). It can be used to search, split</span> +<span class='doccomment'>/// or replace text. All searching is done with an implicit `.*?` at the</span> +<span class='doccomment'>/// beginning and end of an expression. To force an expression to match the</span> +<span class='doccomment'>/// whole string (or a prefix or a suffix), you must use an anchor like `^` or</span> +<span class='doccomment'>/// `$` (or `\A` and `\z`).</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// While this crate will handle Unicode strings (whether in the regular</span> +<span class='doccomment'>/// expression or in the search text), all positions returned are **byte</span> +<span class='doccomment'>/// indices**. Every byte index is guaranteed to be at a Unicode code point</span> +<span class='doccomment'>/// boundary.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The lifetimes `'r` and `'t` in this crate correspond to the lifetime of a</span> +<span class='doccomment'>/// compiled regular expression and text to search, respectively.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The only methods that allocate new strings are the string replacement</span> +<span class='doccomment'>/// methods. All other methods (searching and splitting) return borrowed</span> +<span class='doccomment'>/// pointers into the string given.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Examples</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Find the location of a US phone number:</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ```rust</span> +<span class='doccomment'>/// # use regex::Regex;</span> +<span class='doccomment'>/// let re = Regex::new("[0-9]{3}-[0-9]{3}-[0-9]{4}").unwrap();</span> +<span class='doccomment'>/// assert_eq!(re.find("phone: 111-222-3333"), Some((7, 19)));</span> +<span class='doccomment'>/// ```</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// # Using the `std::str::StrExt` methods with `Regex`</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// > **Note**: This section requires that this crate is currently compiled with</span> +<span class='doccomment'>/// > the `pattern` Cargo feature enabled.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Since `Regex` implements `Pattern`, you can use regexes with methods</span> +<span class='doccomment'>/// defined on `std::str::StrExt`. For example, `is_match`, `find`, `find_iter`</span> +<span class='doccomment'>/// and `split` can be replaced with `StrExt::contains`, `StrExt::find`,</span> +<span class='doccomment'>/// `StrExt::match_indices` and `StrExt::split`.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Here are some examples:</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// ```rust,ignore</span> +<span class='doccomment'>/// # use regex::Regex;</span> +<span class='doccomment'>/// let re = Regex::new(r"\d+").unwrap();</span> +<span class='doccomment'>/// let haystack = "a111b222c";</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// assert!(haystack.contains(&re));</span> +<span class='doccomment'>/// assert_eq!(haystack.find(&re), Some(1));</span> +<span class='doccomment'>/// assert_eq!(haystack.match_indices(&re).collect::<Vec<_>>(),</span> +<span class='doccomment'>/// vec![(1, 4), (5, 8)]);</span> +<span class='doccomment'>/// assert_eq!(haystack.split(&re).collect::<Vec<_>>(), vec!["a", "b", "c"]);</span> +<span class='doccomment'>/// ```</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Regex</span> { + <span class='comment'>// The representation of `Regex` is exported to support the `regex!`</span> + <span class='comment'>// syntax extension. Do not rely on it.</span> + <span class='comment'>//</span> + <span class='comment'>// See the comments for the `program` module in `lib.rs` for a more</span> + <span class='comment'>// detailed explanation for what `regex!` requires.</span> + <span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> + <span class='ident'>Dynamic</span>(<span class='ident'>Program</span>), + <span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> + <span class='ident'>Native</span>(<span class='ident'>ExNative</span>), +} + +<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ExNative</span> { + <span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> + <span class='kw'>pub</span> <span class='ident'>original</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>, + <span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> + <span class='kw'>pub</span> <span class='ident'>names</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='kw-2'>&</span><span class='lifetime'>'static</span> [<span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span><span class='op'>></span>], + <span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> + <span class='kw'>pub</span> <span class='ident'>prog</span>: <span class='kw'>fn</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>CaptureIdxs</span>, <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>bool</span>, +} + +<span class='kw'>impl</span> <span class='ident'>Copy</span> <span class='kw'>for</span> <span class='ident'>ExNative</span> {} + +<span class='kw'>impl</span> <span class='ident'>Clone</span> <span class='kw'>for</span> <span class='ident'>ExNative</span> { + <span class='kw'>fn</span> <span class='ident'>clone</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>ExNative</span> { + <span class='op'>*</span><span class='self'>self</span> + } +} + +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Display</span> <span class='kw'>for</span> <span class='ident'>Regex</span> { + <span class='doccomment'>/// Shows the original regular expression.</span> + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"{}"</span>, <span class='self'>self</span>.<span class='ident'>as_str</span>()) + } +} + +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Debug</span> <span class='kw'>for</span> <span class='ident'>Regex</span> { + <span class='doccomment'>/// Shows the original regular expression.</span> + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='ident'>fmt</span>::<span class='ident'>Display</span>::<span class='ident'>fmt</span>(<span class='self'>self</span>, <span class='ident'>f</span>) + } +} + +<span class='doccomment'>/// Equality comparison is based on the original string. It is possible that</span> +<span class='doccomment'>/// different regular expressions have the same matching behavior, but are</span> +<span class='doccomment'>/// still compared unequal. For example, `\d+` and `\d\d*` match the same set</span> +<span class='doccomment'>/// of strings, but are not considered equal.</span> +<span class='kw'>impl</span> <span class='ident'>PartialEq</span> <span class='kw'>for</span> <span class='ident'>Regex</span> { + <span class='kw'>fn</span> <span class='ident'>eq</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>Regex</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='self'>self</span>.<span class='ident'>as_str</span>() <span class='op'>==</span> <span class='ident'>other</span>.<span class='ident'>as_str</span>() + } +} + +<span class='kw'>impl</span> <span class='ident'>Eq</span> <span class='kw'>for</span> <span class='ident'>Regex</span> {} + +<span class='kw'>impl</span> <span class='ident'>FromStr</span> <span class='kw'>for</span> <span class='ident'>Regex</span> { + <span class='kw'>type</span> <span class='prelude-val'>Err</span> <span class='op'>=</span> <span class='ident'>Error</span>; + + <span class='doccomment'>/// Attempts to parse a string into a regular expression</span> + <span class='kw'>fn</span> <span class='ident'>from_str</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Regex</span>, <span class='ident'>Error</span><span class='op'>></span> { + <span class='ident'>Regex</span>::<span class='ident'>new</span>(<span class='ident'>s</span>) + } +} + +<span class='kw'>impl</span> <span class='ident'>Regex</span> { + <span class='doccomment'>/// Compiles a dynamic regular expression. Once compiled, it can be</span> + <span class='doccomment'>/// used repeatedly to search, split or replace text in a string.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If an invalid expression is given, then an error is returned.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>re</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Regex</span>, <span class='ident'>Error</span><span class='op'>></span> { + <span class='ident'>Regex</span>::<span class='ident'>with_size_limit</span>(<span class='number'>10</span> <span class='op'>*</span> (<span class='number'>1</span> <span class='op'><<</span> <span class='number'>20</span>), <span class='ident'>re</span>) + } + + <span class='doccomment'>/// Compiles a dynamic regular expression with the given size limit.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The size limit is applied to the size of the *compiled* data structure.</span> + <span class='doccomment'>/// If the data structure exceeds the size given, then an error is</span> + <span class='doccomment'>/// returned.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The default size limit used in `new` is 10MB.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>with_size_limit</span>(<span class='ident'>size</span>: <span class='ident'>usize</span>, <span class='ident'>re</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Regex</span>, <span class='ident'>Error</span><span class='op'>></span> { + <span class='ident'>Regex</span>::<span class='ident'>with_engine</span>(<span class='prelude-val'>None</span>, <span class='ident'>size</span>, <span class='ident'>re</span>) + } + + <span class='doccomment'>/// Compiles a dynamic regular expression and uses given matching engine.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This is exposed for use in testing and shouldn't be used by clients.</span> + <span class='doccomment'>/// Instead, the regex program should choose the correct matching engine</span> + <span class='doccomment'>/// to use automatically. (Based on the regex, the size of the input and</span> + <span class='doccomment'>/// the type of search.)</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// A value of `None` means that the engine is automatically selected,</span> + <span class='doccomment'>/// which is the default behavior.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// **WARNING**: Passing an unsuitable engine for the given regex/input</span> + <span class='doccomment'>/// could lead to bad things. (Not unsafe things, but panics, incorrect</span> + <span class='doccomment'>/// matches and large memory use are all things that could happen.)</span> + <span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>with_engine</span>( + <span class='ident'>engine</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>MatchEngine</span><span class='op'>></span>, + <span class='ident'>size</span>: <span class='ident'>usize</span>, + <span class='ident'>re</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, + ) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Regex</span>, <span class='ident'>Error</span><span class='op'>></span> { + <span class='ident'>Program</span>::<span class='ident'>new</span>(<span class='ident'>engine</span>, <span class='ident'>size</span>, <span class='ident'>re</span>).<span class='ident'>map</span>(<span class='ident'>Regex</span>::<span class='ident'>Dynamic</span>) + } + + + <span class='doccomment'>/// Returns true if and only if the regex matches the string given.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// # Example</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Test if some text contains at least one word with exactly 13</span> + <span class='doccomment'>/// characters:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```rust</span> + <span class='doccomment'>/// # extern crate regex; use regex::Regex;</span> + <span class='doccomment'>/// # fn main() {</span> + <span class='doccomment'>/// let text = "I categorically deny having triskaidekaphobia.";</span> + <span class='doccomment'>/// assert!(Regex::new(r"\b\w{13}\b").unwrap().is_match(text));</span> + <span class='doccomment'>/// # }</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_match</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='ident'>exec</span>(<span class='self'>self</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> [], <span class='ident'>text</span>, <span class='number'>0</span>) + } + + <span class='doccomment'>/// Returns the start and end byte range of the leftmost-first match in</span> + <span class='doccomment'>/// `text`. If no match exists, then `None` is returned.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Note that this should only be used if you want to discover the position</span> + <span class='doccomment'>/// of the match. Testing the existence of a match is faster if you use</span> + <span class='doccomment'>/// `is_match`.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// # Example</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Find the start and end location of the first word with exactly 13</span> + <span class='doccomment'>/// characters:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```rust</span> + <span class='doccomment'>/// # extern crate regex; use regex::Regex;</span> + <span class='doccomment'>/// # fn main() {</span> + <span class='doccomment'>/// let text = "I categorically deny having triskaidekaphobia.";</span> + <span class='doccomment'>/// let pos = Regex::new(r"\b\w{13}\b").unwrap().find(text);</span> + <span class='doccomment'>/// assert_eq!(pos, Some((2, 15)));</span> + <span class='doccomment'>/// # }</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>find</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span>(<span class='ident'>usize</span>, <span class='ident'>usize</span>)<span class='op'>></span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>caps</span> <span class='op'>=</span> [<span class='prelude-val'>None</span>, <span class='prelude-val'>None</span>]; + <span class='kw'>if</span> <span class='ident'>exec</span>(<span class='self'>self</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>caps</span>, <span class='ident'>text</span>, <span class='number'>0</span>) { + <span class='prelude-val'>Some</span>((<span class='ident'>caps</span>[<span class='number'>0</span>].<span class='ident'>unwrap</span>(), <span class='ident'>caps</span>[<span class='number'>1</span>].<span class='ident'>unwrap</span>())) + } <span class='kw'>else</span> { + <span class='prelude-val'>None</span> + } + } + + <span class='doccomment'>/// Returns an iterator for each successive non-overlapping match in</span> + <span class='doccomment'>/// `text`, returning the start and end byte indices with respect to</span> + <span class='doccomment'>/// `text`.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// # Example</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Find the start and end location of every word with exactly 13</span> + <span class='doccomment'>/// characters:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```rust</span> + <span class='doccomment'>/// # extern crate regex; use regex::Regex;</span> + <span class='doccomment'>/// # fn main() {</span> + <span class='doccomment'>/// let text = "Retroactively relinquishing remunerations is reprehensible.";</span> + <span class='doccomment'>/// for pos in Regex::new(r"\b\w{13}\b").unwrap().find_iter(text) {</span> + <span class='doccomment'>/// println!("{:?}", pos);</span> + <span class='doccomment'>/// }</span> + <span class='doccomment'>/// // Output:</span> + <span class='doccomment'>/// // (0, 13)</span> + <span class='doccomment'>/// // (14, 27)</span> + <span class='doccomment'>/// // (28, 41)</span> + <span class='doccomment'>/// // (45, 58)</span> + <span class='doccomment'>/// # }</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>find_iter</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'r</span> <span class='self'>self</span>, <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>FindMatches</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>FindMatches</span> { + <span class='ident'>re</span>: <span class='self'>self</span>, + <span class='ident'>search</span>: <span class='ident'>text</span>, + <span class='ident'>last_end</span>: <span class='number'>0</span>, + <span class='ident'>last_match</span>: <span class='prelude-val'>None</span>, + } + } + + <span class='doccomment'>/// Returns the capture groups corresponding to the leftmost-first</span> + <span class='doccomment'>/// match in `text`. Capture group `0` always corresponds to the entire</span> + <span class='doccomment'>/// match. If no match is found, then `None` is returned.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// You should only use `captures` if you need access to submatches.</span> + <span class='doccomment'>/// Otherwise, `find` is faster for discovering the location of the overall</span> + <span class='doccomment'>/// match.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// # Examples</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Say you have some text with movie names and their release years,</span> + <span class='doccomment'>/// like "'Citizen Kane' (1941)". It'd be nice if we could search for text</span> + <span class='doccomment'>/// looking like that, while also extracting the movie name and its release</span> + <span class='doccomment'>/// year separately.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```rust</span> + <span class='doccomment'>/// # extern crate regex; use regex::Regex;</span> + <span class='doccomment'>/// # fn main() {</span> + <span class='doccomment'>/// let re = Regex::new(r"'([^']+)'\s+\((\d{4})\)").unwrap();</span> + <span class='doccomment'>/// let text = "Not my favorite movie: 'Citizen Kane' (1941).";</span> + <span class='doccomment'>/// let caps = re.captures(text).unwrap();</span> + <span class='doccomment'>/// assert_eq!(caps.at(1), Some("Citizen Kane"));</span> + <span class='doccomment'>/// assert_eq!(caps.at(2), Some("1941"));</span> + <span class='doccomment'>/// assert_eq!(caps.at(0), Some("'Citizen Kane' (1941)"));</span> + <span class='doccomment'>/// # }</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Note that the full match is at capture group `0`. Each subsequent</span> + <span class='doccomment'>/// capture group is indexed by the order of its opening `(`.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// We can make this example a bit clearer by using *named* capture groups:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```rust</span> + <span class='doccomment'>/// # extern crate regex; use regex::Regex;</span> + <span class='doccomment'>/// # fn main() {</span> + <span class='doccomment'>/// let re = Regex::new(r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)")</span> + <span class='doccomment'>/// .unwrap();</span> + <span class='doccomment'>/// let text = "Not my favorite movie: 'Citizen Kane' (1941).";</span> + <span class='doccomment'>/// let caps = re.captures(text).unwrap();</span> + <span class='doccomment'>/// assert_eq!(caps.name("title"), Some("Citizen Kane"));</span> + <span class='doccomment'>/// assert_eq!(caps.name("year"), Some("1941"));</span> + <span class='doccomment'>/// assert_eq!(caps.at(0), Some("'Citizen Kane' (1941)"));</span> + <span class='doccomment'>/// # }</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Here we name the capture groups, which we can access with the `name`</span> + <span class='doccomment'>/// method. Note that the named capture groups are still accessible with</span> + <span class='doccomment'>/// `at`.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The `0`th capture group is always unnamed, so it must always be</span> + <span class='doccomment'>/// accessed with `at(0)`.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>captures</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Captures</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>>></span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>caps</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>alloc_captures</span>(); + <span class='kw'>if</span> <span class='ident'>exec</span>(<span class='self'>self</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>caps</span>, <span class='ident'>text</span>, <span class='number'>0</span>) { + <span class='prelude-val'>Some</span>(<span class='ident'>Captures</span>::<span class='ident'>new</span>(<span class='self'>self</span>, <span class='ident'>text</span>, <span class='ident'>caps</span>)) + } <span class='kw'>else</span> { + <span class='prelude-val'>None</span> + } + } + + <span class='doccomment'>/// Returns an iterator over all the non-overlapping capture groups matched</span> + <span class='doccomment'>/// in `text`. This is operationally the same as `find_iter` (except it</span> + <span class='doccomment'>/// yields information about submatches).</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// # Example</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// We can use this to find all movie titles and their release years in</span> + <span class='doccomment'>/// some text, where the movie is formatted like "'Title' (xxxx)":</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```rust</span> + <span class='doccomment'>/// # extern crate regex; use regex::Regex;</span> + <span class='doccomment'>/// # fn main() {</span> + <span class='doccomment'>/// let re = Regex::new(r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)")</span> + <span class='doccomment'>/// .unwrap();</span> + <span class='doccomment'>/// let text = "'Citizen Kane' (1941), 'The Wizard of Oz' (1939), 'M' (1931).";</span> + <span class='doccomment'>/// for caps in re.captures_iter(text) {</span> + <span class='doccomment'>/// println!("Movie: {:?}, Released: {:?}", caps.name("title"), caps.name("year"));</span> + <span class='doccomment'>/// }</span> + <span class='doccomment'>/// // Output:</span> + <span class='doccomment'>/// // Movie: Citizen Kane, Released: 1941</span> + <span class='doccomment'>/// // Movie: The Wizard of Oz, Released: 1939</span> + <span class='doccomment'>/// // Movie: M, Released: 1931</span> + <span class='doccomment'>/// # }</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>captures_iter</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'r</span> <span class='self'>self</span>, <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>) + <span class='op'>-></span> <span class='ident'>FindCaptures</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>FindCaptures</span> { + <span class='ident'>re</span>: <span class='self'>self</span>, + <span class='ident'>search</span>: <span class='ident'>text</span>, + <span class='ident'>last_match</span>: <span class='prelude-val'>None</span>, + <span class='ident'>last_end</span>: <span class='number'>0</span>, + } + } + + <span class='doccomment'>/// Returns an iterator of substrings of `text` delimited by a match</span> + <span class='doccomment'>/// of the regular expression.</span> + <span class='doccomment'>/// Namely, each element of the iterator corresponds to text that *isn't*</span> + <span class='doccomment'>/// matched by the regular expression.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This method will *not* copy the text given.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// # Example</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// To split a string delimited by arbitrary amounts of spaces or tabs:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```rust</span> + <span class='doccomment'>/// # extern crate regex; use regex::Regex;</span> + <span class='doccomment'>/// # fn main() {</span> + <span class='doccomment'>/// let re = Regex::new(r"[ \t]+").unwrap();</span> + <span class='doccomment'>/// let fields: Vec<&str> = re.split("a b \t c\td e").collect();</span> + <span class='doccomment'>/// assert_eq!(fields, vec!("a", "b", "c", "d", "e"));</span> + <span class='doccomment'>/// # }</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>split</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'r</span> <span class='self'>self</span>, <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>RegexSplits</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>RegexSplits</span> { + <span class='ident'>finder</span>: <span class='self'>self</span>.<span class='ident'>find_iter</span>(<span class='ident'>text</span>), + <span class='ident'>last</span>: <span class='number'>0</span>, + } + } + + <span class='doccomment'>/// Returns an iterator of at most `limit` substrings of `text` delimited</span> + <span class='doccomment'>/// by a match of the regular expression. (A `limit` of `0` will return no</span> + <span class='doccomment'>/// substrings.)</span> + <span class='doccomment'>/// Namely, each element of the iterator corresponds to text that *isn't*</span> + <span class='doccomment'>/// matched by the regular expression.</span> + <span class='doccomment'>/// The remainder of the string that is not split will be the last element</span> + <span class='doccomment'>/// in the iterator.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This method will *not* copy the text given.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// # Example</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Get the first two words in some text:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```rust</span> + <span class='doccomment'>/// # extern crate regex; use regex::Regex;</span> + <span class='doccomment'>/// # fn main() {</span> + <span class='doccomment'>/// let re = Regex::new(r"\W+").unwrap();</span> + <span class='doccomment'>/// let fields: Vec<&str> = re.splitn("Hey! How are you?", 3).collect();</span> + <span class='doccomment'>/// assert_eq!(fields, vec!("Hey", "How", "are you?"));</span> + <span class='doccomment'>/// # }</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>splitn</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'r</span> <span class='self'>self</span>, <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>, <span class='ident'>limit</span>: <span class='ident'>usize</span>) + <span class='op'>-></span> <span class='ident'>RegexSplitsN</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>RegexSplitsN</span> { + <span class='ident'>splits</span>: <span class='self'>self</span>.<span class='ident'>split</span>(<span class='ident'>text</span>), + <span class='ident'>cur</span>: <span class='number'>0</span>, + <span class='ident'>limit</span>: <span class='ident'>limit</span>, + } + } + + <span class='doccomment'>/// Replaces the leftmost-first match with the replacement provided.</span> + <span class='doccomment'>/// The replacement can be a regular string (where `$N` and `$name` are</span> + <span class='doccomment'>/// expanded to match capture groups) or a function that takes the matches'</span> + <span class='doccomment'>/// `Captures` and returns the replaced string.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If no match is found, then a copy of the string is returned unchanged.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// # Examples</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Note that this function is polymorphic with respect to the replacement.</span> + <span class='doccomment'>/// In typical usage, this can just be a normal string:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```rust</span> + <span class='doccomment'>/// # extern crate regex; use regex::Regex;</span> + <span class='doccomment'>/// # fn main() {</span> + <span class='doccomment'>/// let re = Regex::new("[^01]+").unwrap();</span> + <span class='doccomment'>/// assert_eq!(re.replace("1078910", ""), "1010");</span> + <span class='doccomment'>/// # }</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// But anything satisfying the `Replacer` trait will work. For example,</span> + <span class='doccomment'>/// a closure of type `|&Captures| -> String` provides direct access to the</span> + <span class='doccomment'>/// captures corresponding to a match. This allows one to access</span> + <span class='doccomment'>/// submatches easily:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```rust</span> + <span class='doccomment'>/// # extern crate regex; use regex::Regex;</span> + <span class='doccomment'>/// # use regex::Captures; fn main() {</span> + <span class='doccomment'>/// let re = Regex::new(r"([^,\s]+),\s+(\S+)").unwrap();</span> + <span class='doccomment'>/// let result = re.replace("Springsteen, Bruce", |caps: &Captures| {</span> + <span class='doccomment'>/// format!("{} {}", caps.at(2).unwrap_or(""), caps.at(1).unwrap_or(""))</span> + <span class='doccomment'>/// });</span> + <span class='doccomment'>/// assert_eq!(result, "Bruce Springsteen");</span> + <span class='doccomment'>/// # }</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// But this is a bit cumbersome to use all the time. Instead, a simple</span> + <span class='doccomment'>/// syntax is supported that expands `$name` into the corresponding capture</span> + <span class='doccomment'>/// group. Here's the last example, but using this expansion technique</span> + <span class='doccomment'>/// with named capture groups:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```rust</span> + <span class='doccomment'>/// # extern crate regex; use regex::Regex;</span> + <span class='doccomment'>/// # fn main() {</span> + <span class='doccomment'>/// let re = Regex::new(r"(?P<last>[^,\s]+),\s+(?P<first>\S+)").unwrap();</span> + <span class='doccomment'>/// let result = re.replace("Springsteen, Bruce", "$first $last");</span> + <span class='doccomment'>/// assert_eq!(result, "Bruce Springsteen");</span> + <span class='doccomment'>/// # }</span> + <span class='doccomment'>/// ```</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Note that using `$2` instead of `$first` or `$1` instead of `$last`</span> + <span class='doccomment'>/// would produce the same result. To write a literal `$` use `$$`.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Finally, sometimes you just want to replace a literal string with no</span> + <span class='doccomment'>/// submatch expansion. This can be done by wrapping a string with</span> + <span class='doccomment'>/// `NoExpand`:</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// ```rust</span> + <span class='doccomment'>/// # extern crate regex; use regex::Regex;</span> + <span class='doccomment'>/// # fn main() {</span> + <span class='doccomment'>/// use regex::NoExpand;</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// let re = Regex::new(r"(?P<last>[^,\s]+),\s+(\S+)").unwrap();</span> + <span class='doccomment'>/// let result = re.replace("Springsteen, Bruce", NoExpand("$2 $last"));</span> + <span class='doccomment'>/// assert_eq!(result, "$2 $last");</span> + <span class='doccomment'>/// # }</span> + <span class='doccomment'>/// ```</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>replace</span><span class='op'><</span><span class='ident'>R</span>: <span class='ident'>Replacer</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>rep</span>: <span class='ident'>R</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='self'>self</span>.<span class='ident'>replacen</span>(<span class='ident'>text</span>, <span class='number'>1</span>, <span class='ident'>rep</span>) + } + + <span class='doccomment'>/// Replaces all non-overlapping matches in `text` with the</span> + <span class='doccomment'>/// replacement provided. This is the same as calling `replacen` with</span> + <span class='doccomment'>/// `limit` set to `0`.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// See the documentation for `replace` for details on how to access</span> + <span class='doccomment'>/// submatches in the replacement string.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>replace_all</span><span class='op'><</span><span class='ident'>R</span>: <span class='ident'>Replacer</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>rep</span>: <span class='ident'>R</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='self'>self</span>.<span class='ident'>replacen</span>(<span class='ident'>text</span>, <span class='number'>0</span>, <span class='ident'>rep</span>) + } + + <span class='doccomment'>/// Replaces at most `limit` non-overlapping matches in `text` with the</span> + <span class='doccomment'>/// replacement provided. If `limit` is 0, then all non-overlapping matches</span> + <span class='doccomment'>/// are replaced.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// See the documentation for `replace` for details on how to access</span> + <span class='doccomment'>/// submatches in the replacement string.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>replacen</span><span class='op'><</span><span class='ident'>R</span>: <span class='ident'>Replacer</span><span class='op'>></span> + (<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>limit</span>: <span class='ident'>usize</span>, <span class='kw-2'>mut</span> <span class='ident'>rep</span>: <span class='ident'>R</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>new</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='ident'>text</span>.<span class='ident'>len</span>()); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>last_match</span> <span class='op'>=</span> <span class='number'>0</span>; + + <span class='kw'>if</span> <span class='ident'>rep</span>.<span class='ident'>no_expand</span>().<span class='ident'>is_some</span>() { + <span class='comment'>// borrow checker pains. `rep` is borrowed mutably in the `else`</span> + <span class='comment'>// branch below.</span> + <span class='kw'>let</span> <span class='ident'>rep</span> <span class='op'>=</span> <span class='ident'>rep</span>.<span class='ident'>no_expand</span>().<span class='ident'>unwrap</span>(); + <span class='kw'>for</span> (<span class='ident'>i</span>, (<span class='ident'>s</span>, <span class='ident'>e</span>)) <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>find_iter</span>(<span class='ident'>text</span>).<span class='ident'>enumerate</span>() { + <span class='kw'>if</span> <span class='ident'>limit</span> <span class='op'>></span> <span class='number'>0</span> <span class='op'>&&</span> <span class='ident'>i</span> <span class='op'>>=</span> <span class='ident'>limit</span> { + <span class='kw'>break</span> + } + <span class='ident'>new</span>.<span class='ident'>push_str</span>(<span class='kw-2'>&</span><span class='ident'>text</span>[<span class='ident'>last_match</span>..<span class='ident'>s</span>]); + <span class='ident'>new</span>.<span class='ident'>push_str</span>(<span class='kw-2'>&</span><span class='ident'>rep</span>); + <span class='ident'>last_match</span> <span class='op'>=</span> <span class='ident'>e</span>; + } + } <span class='kw'>else</span> { + <span class='kw'>for</span> (<span class='ident'>i</span>, <span class='ident'>cap</span>) <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>captures_iter</span>(<span class='ident'>text</span>).<span class='ident'>enumerate</span>() { + <span class='kw'>if</span> <span class='ident'>limit</span> <span class='op'>></span> <span class='number'>0</span> <span class='op'>&&</span> <span class='ident'>i</span> <span class='op'>>=</span> <span class='ident'>limit</span> { + <span class='kw'>break</span> + } + <span class='comment'>// unwrap on 0 is OK because captures only reports matches</span> + <span class='kw'>let</span> (<span class='ident'>s</span>, <span class='ident'>e</span>) <span class='op'>=</span> <span class='ident'>cap</span>.<span class='ident'>pos</span>(<span class='number'>0</span>).<span class='ident'>unwrap</span>(); + <span class='ident'>new</span>.<span class='ident'>push_str</span>(<span class='kw-2'>&</span><span class='ident'>text</span>[<span class='ident'>last_match</span>..<span class='ident'>s</span>]); + <span class='ident'>new</span>.<span class='ident'>push_str</span>(<span class='kw-2'>&</span><span class='ident'>rep</span>.<span class='ident'>reg_replace</span>(<span class='kw-2'>&</span><span class='ident'>cap</span>)); + <span class='ident'>last_match</span> <span class='op'>=</span> <span class='ident'>e</span>; + } + } + <span class='ident'>new</span>.<span class='ident'>push_str</span>(<span class='kw-2'>&</span><span class='ident'>text</span>[<span class='ident'>last_match</span>..]); + <span class='ident'>new</span> + } + + <span class='doccomment'>/// Returns the original string of this regex.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>as_str</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>str</span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>Regex</span>::<span class='ident'>Dynamic</span>(<span class='ident'>Program</span> { <span class='kw-2'>ref</span> <span class='ident'>original</span>, .. }) <span class='op'>=></span> <span class='ident'>original</span>, + <span class='ident'>Regex</span>::<span class='ident'>Native</span>(<span class='ident'>ExNative</span> { <span class='kw-2'>ref</span> <span class='ident'>original</span>, .. }) <span class='op'>=></span> <span class='ident'>original</span>, + } + } + + <span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>names_iter</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>NamesIter</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>Regex</span>::<span class='ident'>Native</span>(<span class='kw-2'>ref</span> <span class='ident'>n</span>) <span class='op'>=></span> <span class='ident'>NamesIter</span>::<span class='ident'>Native</span>(<span class='ident'>n</span>.<span class='ident'>names</span>.<span class='ident'>iter</span>()), + <span class='ident'>Regex</span>::<span class='ident'>Dynamic</span>(<span class='kw-2'>ref</span> <span class='ident'>d</span>) <span class='op'>=></span> <span class='ident'>NamesIter</span>::<span class='ident'>Dynamic</span>(<span class='ident'>d</span>.<span class='ident'>cap_names</span>.<span class='ident'>iter</span>()) + } + } + + <span class='kw'>fn</span> <span class='ident'>names_len</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>Regex</span>::<span class='ident'>Native</span>(<span class='kw-2'>ref</span> <span class='ident'>n</span>) <span class='op'>=></span> <span class='ident'>n</span>.<span class='ident'>names</span>.<span class='ident'>len</span>(), + <span class='ident'>Regex</span>::<span class='ident'>Dynamic</span>(<span class='kw-2'>ref</span> <span class='ident'>d</span>) <span class='op'>=></span> <span class='ident'>d</span>.<span class='ident'>cap_names</span>.<span class='ident'>len</span>() + } + } + + <span class='kw'>fn</span> <span class='ident'>alloc_captures</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>>></span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>Regex</span>::<span class='ident'>Native</span>(<span class='kw-2'>ref</span> <span class='ident'>n</span>) <span class='op'>=></span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='prelude-val'>None</span>; <span class='number'>2</span> <span class='op'>*</span> <span class='ident'>n</span>.<span class='ident'>names</span>.<span class='ident'>len</span>()], + <span class='ident'>Regex</span>::<span class='ident'>Dynamic</span>(<span class='kw-2'>ref</span> <span class='ident'>d</span>) <span class='op'>=></span> <span class='ident'>d</span>.<span class='ident'>alloc_captures</span>(), + } + } +} + +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>NamesIter</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='ident'>Native</span>(::<span class='ident'>std</span>::<span class='ident'>slice</span>::<span class='ident'>Iter</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span><span class='op'>>></span>), + <span class='ident'>Dynamic</span>(::<span class='ident'>std</span>::<span class='ident'>slice</span>::<span class='ident'>Iter</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>String</span><span class='op'>>></span>) +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>Iterator</span> <span class='kw'>for</span> <span class='ident'>NamesIter</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Item</span><span class='op'>=</span><span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span>; + + <span class='kw'>fn</span> <span class='ident'>next</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>String</span><span class='op'>>></span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>NamesIter</span>::<span class='ident'>Native</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>i</span>) <span class='op'>=></span> + <span class='ident'>i</span>.<span class='ident'>next</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> <span class='ident'>x</span>.<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>s</span><span class='op'>|</span> <span class='ident'>s</span>.<span class='ident'>to_owned</span>())), + <span class='ident'>NamesIter</span>::<span class='ident'>Dynamic</span>(<span class='kw-2'>ref</span> <span class='kw-2'>mut</span> <span class='ident'>i</span>) <span class='op'>=></span> + <span class='ident'>i</span>.<span class='ident'>next</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> <span class='ident'>x</span>.<span class='ident'>as_ref</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>s</span><span class='op'>|</span> <span class='ident'>s</span>.<span class='ident'>to_owned</span>())), + } + } +} + +<span class='doccomment'>/// NoExpand indicates literal string replacement.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// It can be used with `replace` and `replace_all` to do a literal</span> +<span class='doccomment'>/// string replacement without expanding `$name` to their corresponding</span> +<span class='doccomment'>/// capture groups.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// `'r` is the lifetime of the literal text.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>NoExpand</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span>(<span class='kw'>pub</span> <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>); + +<span class='doccomment'>/// Replacer describes types that can be used to replace matches in a string.</span> +<span class='kw'>pub</span> <span class='kw'>trait</span> <span class='ident'>Replacer</span> { + <span class='doccomment'>/// Returns a possibly owned string that is used to replace the match</span> + <span class='doccomment'>/// corresponding to the `caps` capture group.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The `'a` lifetime refers to the lifetime of a borrowed string when</span> + <span class='doccomment'>/// a new owned string isn't needed (e.g., for `NoExpand`).</span> + <span class='kw'>fn</span> <span class='ident'>reg_replace</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>caps</span>: <span class='kw-2'>&</span><span class='ident'>Captures</span>) <span class='op'>-></span> <span class='ident'>Cow</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>str</span><span class='op'>></span>; + + <span class='doccomment'>/// Returns a possibly owned string that never needs expansion.</span> + <span class='kw'>fn</span> <span class='ident'>no_expand</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Cow</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>str</span><span class='op'>>></span> { <span class='prelude-val'>None</span> } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> <span class='ident'>Replacer</span> <span class='kw'>for</span> <span class='ident'>NoExpand</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>reg_replace</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='kw-2'>mut</span> <span class='self'>self</span>, _: <span class='kw-2'>&</span><span class='ident'>Captures</span>) <span class='op'>-></span> <span class='ident'>Cow</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>str</span><span class='op'>></span> { + <span class='self'>self</span>.<span class='number'>0</span>.<span class='ident'>into</span>() + } + + <span class='kw'>fn</span> <span class='ident'>no_expand</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Cow</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>str</span><span class='op'>>></span> { + <span class='prelude-val'>Some</span>(<span class='self'>self</span>.<span class='number'>0</span>.<span class='ident'>into</span>()) + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> <span class='ident'>Replacer</span> <span class='kw'>for</span> <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span> { + <span class='kw'>fn</span> <span class='ident'>reg_replace</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>caps</span>: <span class='kw-2'>&</span><span class='ident'>Captures</span>) <span class='op'>-></span> <span class='ident'>Cow</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>str</span><span class='op'>></span> { + <span class='ident'>caps</span>.<span class='ident'>expand</span>(<span class='op'>*</span><span class='self'>self</span>).<span class='ident'>into</span>() + } + + <span class='kw'>fn</span> <span class='ident'>no_expand</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Cow</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>str</span><span class='op'>>></span> { + <span class='kw'>let</span> <span class='ident'>re</span> <span class='op'>=</span> <span class='ident'>Regex</span>::<span class='ident'>new</span>(<span class='ident'>REPLACE_EXPAND</span>).<span class='ident'>unwrap</span>(); + <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>re</span>.<span class='ident'>is_match</span>(<span class='self'>self</span>) { + <span class='prelude-val'>Some</span>((<span class='op'>*</span><span class='self'>self</span>).<span class='ident'>into</span>()) + } <span class='kw'>else</span> { + <span class='prelude-val'>None</span> + } + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>F</span><span class='op'>></span> <span class='ident'>Replacer</span> <span class='kw'>for</span> <span class='ident'>F</span> <span class='kw'>where</span> <span class='ident'>F</span>: <span class='ident'>FnMut</span>(<span class='kw-2'>&</span><span class='ident'>Captures</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>fn</span> <span class='ident'>reg_replace</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>caps</span>: <span class='kw-2'>&</span><span class='ident'>Captures</span>) <span class='op'>-></span> <span class='ident'>Cow</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>str</span><span class='op'>></span> { + (<span class='op'>*</span><span class='self'>self</span>)(<span class='ident'>caps</span>).<span class='ident'>into</span>() + } +} + +<span class='doccomment'>/// Yields all substrings delimited by a regular expression match.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// `'r` is the lifetime of the compiled expression and `'t` is the lifetime</span> +<span class='doccomment'>/// of the string being split.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>RegexSplits</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>finder</span>: <span class='ident'>FindMatches</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span>, + <span class='ident'>last</span>: <span class='ident'>usize</span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> <span class='ident'>Iterator</span> <span class='kw'>for</span> <span class='ident'>RegexSplits</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Item</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>; + + <span class='kw'>fn</span> <span class='ident'>next</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>text</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>finder</span>.<span class='ident'>search</span>; + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>finder</span>.<span class='ident'>next</span>() { + <span class='prelude-val'>None</span> <span class='op'>=></span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>last</span> <span class='op'>>=</span> <span class='ident'>text</span>.<span class='ident'>len</span>() { + <span class='prelude-val'>None</span> + } <span class='kw'>else</span> { + <span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='ident'>text</span>[<span class='self'>self</span>.<span class='ident'>last</span>..]; + <span class='self'>self</span>.<span class='ident'>last</span> <span class='op'>=</span> <span class='ident'>text</span>.<span class='ident'>len</span>(); + <span class='prelude-val'>Some</span>(<span class='ident'>s</span>) + } + } + <span class='prelude-val'>Some</span>((<span class='ident'>s</span>, <span class='ident'>e</span>)) <span class='op'>=></span> { + <span class='kw'>let</span> <span class='ident'>matched</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='ident'>text</span>[<span class='self'>self</span>.<span class='ident'>last</span>..<span class='ident'>s</span>]; + <span class='self'>self</span>.<span class='ident'>last</span> <span class='op'>=</span> <span class='ident'>e</span>; + <span class='prelude-val'>Some</span>(<span class='ident'>matched</span>) + } + } + } +} + +<span class='doccomment'>/// Yields at most `N` substrings delimited by a regular expression match.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The last substring will be whatever remains after splitting.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// `'r` is the lifetime of the compiled expression and `'t` is the lifetime</span> +<span class='doccomment'>/// of the string being split.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>RegexSplitsN</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>splits</span>: <span class='ident'>RegexSplits</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span>, + <span class='ident'>cur</span>: <span class='ident'>usize</span>, + <span class='ident'>limit</span>: <span class='ident'>usize</span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> <span class='ident'>Iterator</span> <span class='kw'>for</span> <span class='ident'>RegexSplitsN</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Item</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>; + + <span class='kw'>fn</span> <span class='ident'>next</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>text</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>splits</span>.<span class='ident'>finder</span>.<span class='ident'>search</span>; + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>cur</span> <span class='op'>>=</span> <span class='self'>self</span>.<span class='ident'>limit</span> { + <span class='prelude-val'>None</span> + } <span class='kw'>else</span> { + <span class='self'>self</span>.<span class='ident'>cur</span> <span class='op'>+=</span> <span class='number'>1</span>; + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>cur</span> <span class='op'>>=</span> <span class='self'>self</span>.<span class='ident'>limit</span> { + <span class='prelude-val'>Some</span>(<span class='kw-2'>&</span><span class='ident'>text</span>[<span class='self'>self</span>.<span class='ident'>splits</span>.<span class='ident'>last</span>..]) + } <span class='kw'>else</span> { + <span class='self'>self</span>.<span class='ident'>splits</span>.<span class='ident'>next</span>() + } + } + } +} + +<span class='doccomment'>/// Captures represents a group of captured strings for a single match.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The 0th capture always corresponds to the entire match. Each subsequent</span> +<span class='doccomment'>/// index corresponds to the next capture group in the regex.</span> +<span class='doccomment'>/// If a capture group is named, then the matched string is *also* available</span> +<span class='doccomment'>/// via the `name` method. (Note that the 0th capture is always unnamed and so</span> +<span class='doccomment'>/// must be accessed with the `at` method.)</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Positions returned from a capture group are always byte indices.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// `'t` is the lifetime of the matched text.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Captures</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>, + <span class='ident'>locs</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>>></span>, + <span class='ident'>named</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>HashMap</span><span class='op'><</span><span class='ident'>String</span>, <span class='ident'>usize</span><span class='op'>>></span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> <span class='ident'>Captures</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>new</span>( + <span class='ident'>re</span>: <span class='kw-2'>&</span><span class='ident'>Regex</span>, + <span class='ident'>search</span>: <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>, + <span class='ident'>locs</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>>></span>, + ) <span class='op'>-></span> <span class='ident'>Captures</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>named</span> <span class='op'>=</span> + <span class='kw'>if</span> <span class='ident'>re</span>.<span class='ident'>names_len</span>() <span class='op'>==</span> <span class='number'>0</span> { + <span class='prelude-val'>None</span> + } <span class='kw'>else</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>named</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>(); + <span class='kw'>for</span> (<span class='ident'>i</span>, <span class='ident'>name</span>) <span class='kw'>in</span> <span class='ident'>re</span>.<span class='ident'>names_iter</span>().<span class='ident'>enumerate</span>() { + <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>name</span>) <span class='op'>=</span> <span class='ident'>name</span> { + <span class='ident'>named</span>.<span class='ident'>insert</span>(<span class='ident'>name</span>, <span class='ident'>i</span>); + } + } + <span class='prelude-val'>Some</span>(<span class='ident'>named</span>) + }; + <span class='ident'>Captures</span> { + <span class='ident'>text</span>: <span class='ident'>search</span>, + <span class='ident'>locs</span>: <span class='ident'>locs</span>, + <span class='ident'>named</span>: <span class='ident'>named</span>, + } + } + + <span class='doccomment'>/// Returns the start and end positions of the Nth capture group.</span> + <span class='doccomment'>/// Returns `None` if `i` is not a valid capture group or if the capture</span> + <span class='doccomment'>/// group did not match anything.</span> + <span class='doccomment'>/// The positions returned are *always* byte indices with respect to the</span> + <span class='doccomment'>/// original string matched.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>pos</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>i</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span>(<span class='ident'>usize</span>, <span class='ident'>usize</span>)<span class='op'>></span> { + <span class='kw'>let</span> (<span class='ident'>s</span>, <span class='ident'>e</span>) <span class='op'>=</span> (<span class='ident'>i</span> <span class='op'>*</span> <span class='number'>2</span>, <span class='ident'>i</span> <span class='op'>*</span> <span class='number'>2</span> <span class='op'>+</span> <span class='number'>1</span>); + <span class='kw'>if</span> <span class='ident'>e</span> <span class='op'>>=</span> <span class='self'>self</span>.<span class='ident'>locs</span>.<span class='ident'>len</span>() <span class='op'>||</span> <span class='self'>self</span>.<span class='ident'>locs</span>[<span class='ident'>s</span>].<span class='ident'>is_none</span>() { + <span class='comment'>// VM guarantees that each pair of locations are both Some or None.</span> + <span class='kw'>return</span> <span class='prelude-val'>None</span> + } + <span class='prelude-val'>Some</span>((<span class='self'>self</span>.<span class='ident'>locs</span>[<span class='ident'>s</span>].<span class='ident'>unwrap</span>(), <span class='self'>self</span>.<span class='ident'>locs</span>[<span class='ident'>e</span>].<span class='ident'>unwrap</span>())) + } + + <span class='doccomment'>/// Returns the matched string for the capture group `i`. If `i` isn't</span> + <span class='doccomment'>/// a valid capture group or didn't match anything, then `None` is</span> + <span class='doccomment'>/// returned.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>at</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>i</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span><span class='op'>></span> { + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>pos</span>(<span class='ident'>i</span>) { + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='prelude-val'>None</span>, + <span class='prelude-val'>Some</span>((<span class='ident'>s</span>, <span class='ident'>e</span>)) <span class='op'>=></span> <span class='prelude-val'>Some</span>(<span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>text</span>[<span class='ident'>s</span>..<span class='ident'>e</span>]) + } + } + + <span class='doccomment'>/// Returns the matched string for the capture group named `name`. If</span> + <span class='doccomment'>/// `name` isn't a valid capture group or didn't match anything, then</span> + <span class='doccomment'>/// `None` is returned.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>name</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>name</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span><span class='op'>></span> { + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>named</span> { + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='prelude-val'>None</span>, + <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>h</span>) <span class='op'>=></span> { + <span class='kw'>match</span> <span class='ident'>h</span>.<span class='ident'>get</span>(<span class='ident'>name</span>) { + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='prelude-val'>None</span>, + <span class='prelude-val'>Some</span>(<span class='ident'>i</span>) <span class='op'>=></span> <span class='self'>self</span>.<span class='ident'>at</span>(<span class='op'>*</span><span class='ident'>i</span>), + } + } + } + } + + <span class='doccomment'>/// Creates an iterator of all the capture groups in order of appearance</span> + <span class='doccomment'>/// in the regular expression.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>iter</span>(<span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>SubCaptures</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>SubCaptures</span> { <span class='ident'>idx</span>: <span class='number'>0</span>, <span class='ident'>caps</span>: <span class='self'>self</span>, } + } + + <span class='doccomment'>/// Creates an iterator of all the capture group positions in order of</span> + <span class='doccomment'>/// appearance in the regular expression. Positions are byte indices</span> + <span class='doccomment'>/// in terms of the original string matched.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>iter_pos</span>(<span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>SubCapturesPos</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>SubCapturesPos</span> { <span class='ident'>idx</span>: <span class='number'>0</span>, <span class='ident'>caps</span>: <span class='self'>self</span>, } + } + + <span class='doccomment'>/// Creates an iterator of all named groups as an tuple with the group</span> + <span class='doccomment'>/// name and the value. The iterator returns these values in arbitrary</span> + <span class='doccomment'>/// order.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>iter_named</span>(<span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>SubCapturesNamed</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>SubCapturesNamed</span> { <span class='ident'>caps</span>: <span class='self'>self</span>, <span class='ident'>inner</span>: <span class='self'>self</span>.<span class='ident'>named</span>.<span class='ident'>as_ref</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>n</span><span class='op'>|</span> <span class='ident'>n</span>.<span class='ident'>iter</span>()) } + } + + <span class='doccomment'>/// Expands all instances of `$name` in `text` to the corresponding capture</span> + <span class='doccomment'>/// group `name`.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// `name` may be an integer corresponding to the index of the</span> + <span class='doccomment'>/// capture group (counted by order of opening parenthesis where `0` is the</span> + <span class='doccomment'>/// entire match) or it can be a name (consisting of letters, digits or</span> + <span class='doccomment'>/// underscores) corresponding to a named capture group.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If `name` isn't a valid capture group (whether the name doesn't exist or</span> + <span class='doccomment'>/// isn't a valid index), then it is replaced with the empty string.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// To write a literal `$` use `$$`.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>expand</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='comment'>// How evil can you get?</span> + <span class='kw'>let</span> <span class='ident'>re</span> <span class='op'>=</span> <span class='ident'>Regex</span>::<span class='ident'>new</span>(<span class='ident'>REPLACE_EXPAND</span>).<span class='ident'>unwrap</span>(); + <span class='kw'>let</span> <span class='ident'>text</span> <span class='op'>=</span> <span class='ident'>re</span>.<span class='ident'>replace_all</span>(<span class='ident'>text</span>, <span class='op'>|</span><span class='ident'>refs</span>: <span class='kw-2'>&</span><span class='ident'>Captures</span><span class='op'>|</span> <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>let</span> <span class='ident'>before</span> <span class='op'>=</span> <span class='ident'>refs</span>.<span class='ident'>name</span>(<span class='string'>"before"</span>).<span class='ident'>unwrap_or</span>(<span class='string'>""</span>); + <span class='kw'>let</span> <span class='ident'>name</span> <span class='op'>=</span> <span class='ident'>refs</span>.<span class='ident'>name</span>(<span class='string'>"name"</span>).<span class='ident'>unwrap_or</span>(<span class='string'>""</span>); + <span class='macro'>format</span><span class='macro'>!</span>(<span class='string'>"{}{}"</span>, <span class='ident'>before</span>, <span class='kw'>match</span> <span class='ident'>name</span>.<span class='ident'>parse</span>::<span class='op'><</span><span class='ident'>usize</span><span class='op'>></span>() { + <span class='prelude-val'>Err</span>(_) <span class='op'>=></span> <span class='self'>self</span>.<span class='ident'>name</span>(<span class='ident'>name</span>).<span class='ident'>unwrap_or</span>(<span class='string'>""</span>).<span class='ident'>to_string</span>(), + <span class='prelude-val'>Ok</span>(<span class='ident'>i</span>) <span class='op'>=></span> <span class='self'>self</span>.<span class='ident'>at</span>(<span class='ident'>i</span>).<span class='ident'>unwrap_or</span>(<span class='string'>""</span>).<span class='ident'>to_string</span>(), + }) + }); + <span class='kw'>let</span> <span class='ident'>re</span> <span class='op'>=</span> <span class='ident'>Regex</span>::<span class='ident'>new</span>(<span class='string'>r"\$\$"</span>).<span class='ident'>unwrap</span>(); + <span class='ident'>re</span>.<span class='ident'>replace_all</span>(<span class='kw-2'>&</span><span class='ident'>text</span>, <span class='ident'>NoExpand</span>(<span class='string'>"$"</span>)) + } + + <span class='doccomment'>/// Returns the number of captured groups.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>len</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>usize</span> { <span class='self'>self</span>.<span class='ident'>locs</span>.<span class='ident'>len</span>() <span class='op'>/</span> <span class='number'>2</span> } + + <span class='doccomment'>/// Returns true if and only if there are no captured groups.</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_empty</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { <span class='self'>self</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>0</span> } +} + +<span class='doccomment'>/// An iterator over capture groups for a particular match of a regular</span> +<span class='doccomment'>/// expression.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// `'t` is the lifetime of the matched text.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>SubCaptures</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>idx</span>: <span class='ident'>usize</span>, + <span class='ident'>caps</span>: <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>Captures</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> <span class='ident'>Iterator</span> <span class='kw'>for</span> <span class='ident'>SubCaptures</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Item</span> <span class='op'>=</span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span><span class='op'>></span>; + + <span class='kw'>fn</span> <span class='ident'>next</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span><span class='op'>>></span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>idx</span> <span class='op'><</span> <span class='self'>self</span>.<span class='ident'>caps</span>.<span class='ident'>len</span>() { + <span class='self'>self</span>.<span class='ident'>idx</span> <span class='op'>+=</span> <span class='number'>1</span>; + <span class='prelude-val'>Some</span>(<span class='self'>self</span>.<span class='ident'>caps</span>.<span class='ident'>at</span>(<span class='self'>self</span>.<span class='ident'>idx</span> <span class='op'>-</span> <span class='number'>1</span>)) + } <span class='kw'>else</span> { + <span class='prelude-val'>None</span> + } + } +} + +<span class='doccomment'>/// An iterator over capture group positions for a particular match of a</span> +<span class='doccomment'>/// regular expression.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Positions are byte indices in terms of the original string matched.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// `'t` is the lifetime of the matched text.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>SubCapturesPos</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>idx</span>: <span class='ident'>usize</span>, + <span class='ident'>caps</span>: <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>Captures</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> <span class='ident'>Iterator</span> <span class='kw'>for</span> <span class='ident'>SubCapturesPos</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Item</span> <span class='op'>=</span> <span class='prelude-ty'>Option</span><span class='op'><</span>(<span class='ident'>usize</span>, <span class='ident'>usize</span>)<span class='op'>></span>; + + <span class='kw'>fn</span> <span class='ident'>next</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='prelude-ty'>Option</span><span class='op'><</span>(<span class='ident'>usize</span>, <span class='ident'>usize</span>)<span class='op'>>></span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>idx</span> <span class='op'><</span> <span class='self'>self</span>.<span class='ident'>caps</span>.<span class='ident'>len</span>() { + <span class='self'>self</span>.<span class='ident'>idx</span> <span class='op'>+=</span> <span class='number'>1</span>; + <span class='prelude-val'>Some</span>(<span class='self'>self</span>.<span class='ident'>caps</span>.<span class='ident'>pos</span>(<span class='self'>self</span>.<span class='ident'>idx</span> <span class='op'>-</span> <span class='number'>1</span>)) + } <span class='kw'>else</span> { + <span class='prelude-val'>None</span> + } + } +} + +<span class='doccomment'>/// An Iterator over named capture groups as a tuple with the group</span> +<span class='doccomment'>/// name and the value.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// `'t` is the lifetime of the matched text.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>SubCapturesNamed</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span>{ + <span class='ident'>caps</span>: <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>Captures</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span>, + <span class='ident'>inner</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Iter</span><span class='op'><</span><span class='lifetime'>'t</span>, <span class='ident'>String</span>, <span class='ident'>usize</span><span class='op'>>></span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> <span class='ident'>Iterator</span> <span class='kw'>for</span> <span class='ident'>SubCapturesNamed</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Item</span> <span class='op'>=</span> (<span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span><span class='op'>></span>); + + <span class='kw'>fn</span> <span class='ident'>next</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span>(<span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>, <span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span><span class='op'>></span>)<span class='op'>></span> { + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>inner</span>.<span class='ident'>as_mut</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>it</span><span class='op'>|</span> <span class='ident'>it</span>.<span class='ident'>next</span>()).<span class='ident'>unwrap_or</span>(<span class='prelude-val'>None</span>) { + <span class='prelude-val'>Some</span>((<span class='ident'>name</span>, <span class='ident'>pos</span>)) <span class='op'>=></span> <span class='prelude-val'>Some</span>((<span class='ident'>name</span>, <span class='self'>self</span>.<span class='ident'>caps</span>.<span class='ident'>at</span>(<span class='op'>*</span><span class='ident'>pos</span>))), + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='prelude-val'>None</span> + } + } +} + +<span class='doccomment'>/// An iterator that yields all non-overlapping capture groups matching a</span> +<span class='doccomment'>/// particular regular expression.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The iterator stops when no more matches can be found.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// `'r` is the lifetime of the compiled expression and `'t` is the lifetime</span> +<span class='doccomment'>/// of the matched string.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>FindCaptures</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>re</span>: <span class='kw-2'>&</span><span class='lifetime'>'r</span> <span class='ident'>Regex</span>, + <span class='ident'>search</span>: <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>, + <span class='ident'>last_match</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span>, + <span class='ident'>last_end</span>: <span class='ident'>usize</span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> <span class='ident'>Iterator</span> <span class='kw'>for</span> <span class='ident'>FindCaptures</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Item</span> <span class='op'>=</span> <span class='ident'>Captures</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span>; + + <span class='kw'>fn</span> <span class='ident'>next</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Captures</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>>></span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>last_end</span> <span class='op'>></span> <span class='self'>self</span>.<span class='ident'>search</span>.<span class='ident'>len</span>() { + <span class='kw'>return</span> <span class='prelude-val'>None</span> + } + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>caps</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>re</span>.<span class='ident'>alloc_captures</span>(); + <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>exec</span>(<span class='self'>self</span>.<span class='ident'>re</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>caps</span>, <span class='self'>self</span>.<span class='ident'>search</span>, <span class='self'>self</span>.<span class='ident'>last_end</span>) { + <span class='kw'>return</span> <span class='prelude-val'>None</span> + } + <span class='kw'>let</span> (<span class='ident'>s</span>, <span class='ident'>e</span>) <span class='op'>=</span> (<span class='ident'>caps</span>[<span class='number'>0</span>].<span class='ident'>unwrap</span>(), <span class='ident'>caps</span>[<span class='number'>1</span>].<span class='ident'>unwrap</span>()); + + <span class='comment'>// Don't accept empty matches immediately following a match.</span> + <span class='comment'>// i.e., no infinite loops please.</span> + <span class='kw'>if</span> <span class='ident'>e</span> <span class='op'>==</span> <span class='ident'>s</span> <span class='op'>&&</span> <span class='prelude-val'>Some</span>(<span class='self'>self</span>.<span class='ident'>last_end</span>) <span class='op'>==</span> <span class='self'>self</span>.<span class='ident'>last_match</span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>last_end</span> <span class='op'>>=</span> <span class='self'>self</span>.<span class='ident'>search</span>.<span class='ident'>len</span>() { + <span class='kw'>return</span> <span class='prelude-val'>None</span>; + } + <span class='self'>self</span>.<span class='ident'>last_end</span> <span class='op'>+=</span> <span class='self'>self</span>.<span class='ident'>search</span>[<span class='self'>self</span>.<span class='ident'>last_end</span>..].<span class='ident'>chars</span>() + .<span class='ident'>next</span>().<span class='ident'>unwrap</span>().<span class='ident'>len_utf8</span>(); + <span class='kw'>return</span> <span class='self'>self</span>.<span class='ident'>next</span>() + } + <span class='self'>self</span>.<span class='ident'>last_end</span> <span class='op'>=</span> <span class='ident'>e</span>; + <span class='self'>self</span>.<span class='ident'>last_match</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='self'>self</span>.<span class='ident'>last_end</span>); + <span class='prelude-val'>Some</span>(<span class='ident'>Captures</span>::<span class='ident'>new</span>(<span class='self'>self</span>.<span class='ident'>re</span>, <span class='self'>self</span>.<span class='ident'>search</span>, <span class='ident'>caps</span>)) + } +} + +<span class='doccomment'>/// An iterator over all non-overlapping matches for a particular string.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The iterator yields a tuple of integers corresponding to the start and end</span> +<span class='doccomment'>/// of the match. The indices are byte offsets. The iterator stops when no more</span> +<span class='doccomment'>/// matches can be found.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// `'r` is the lifetime of the compiled expression and `'t` is the lifetime</span> +<span class='doccomment'>/// of the matched string.</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>FindMatches</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>re</span>: <span class='kw-2'>&</span><span class='lifetime'>'r</span> <span class='ident'>Regex</span>, + <span class='ident'>search</span>: <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>, + <span class='ident'>last_match</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span>, + <span class='ident'>last_end</span>: <span class='ident'>usize</span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> <span class='ident'>Iterator</span> <span class='kw'>for</span> <span class='ident'>FindMatches</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Item</span> <span class='op'>=</span> (<span class='ident'>usize</span>, <span class='ident'>usize</span>); + + <span class='kw'>fn</span> <span class='ident'>next</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span>(<span class='ident'>usize</span>, <span class='ident'>usize</span>)<span class='op'>></span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>last_end</span> <span class='op'>></span> <span class='self'>self</span>.<span class='ident'>search</span>.<span class='ident'>len</span>() { + <span class='kw'>return</span> <span class='prelude-val'>None</span> + } + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>caps</span> <span class='op'>=</span> [<span class='prelude-val'>None</span>, <span class='prelude-val'>None</span>]; + <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>exec</span>(<span class='self'>self</span>.<span class='ident'>re</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>caps</span>, <span class='self'>self</span>.<span class='ident'>search</span>, <span class='self'>self</span>.<span class='ident'>last_end</span>) { + <span class='kw'>return</span> <span class='prelude-val'>None</span>; + } + <span class='kw'>let</span> (<span class='ident'>s</span>, <span class='ident'>e</span>) <span class='op'>=</span> (<span class='ident'>caps</span>[<span class='number'>0</span>].<span class='ident'>unwrap</span>(), <span class='ident'>caps</span>[<span class='number'>1</span>].<span class='ident'>unwrap</span>()); + + <span class='comment'>// Don't accept empty matches immediately following a match.</span> + <span class='comment'>// i.e., no infinite loops please.</span> + <span class='kw'>if</span> <span class='ident'>e</span> <span class='op'>==</span> <span class='ident'>s</span> <span class='op'>&&</span> <span class='prelude-val'>Some</span>(<span class='self'>self</span>.<span class='ident'>last_end</span>) <span class='op'>==</span> <span class='self'>self</span>.<span class='ident'>last_match</span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>last_end</span> <span class='op'>>=</span> <span class='self'>self</span>.<span class='ident'>search</span>.<span class='ident'>len</span>() { + <span class='kw'>return</span> <span class='prelude-val'>None</span>; + } + <span class='self'>self</span>.<span class='ident'>last_end</span> <span class='op'>+=</span> <span class='self'>self</span>.<span class='ident'>search</span>[<span class='self'>self</span>.<span class='ident'>last_end</span>..].<span class='ident'>chars</span>() + .<span class='ident'>next</span>().<span class='ident'>unwrap</span>().<span class='ident'>len_utf8</span>(); + <span class='kw'>return</span> <span class='self'>self</span>.<span class='ident'>next</span>() + } + <span class='self'>self</span>.<span class='ident'>last_end</span> <span class='op'>=</span> <span class='ident'>e</span>; + <span class='self'>self</span>.<span class='ident'>last_match</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='self'>self</span>.<span class='ident'>last_end</span>); + <span class='prelude-val'>Some</span>((<span class='ident'>s</span>, <span class='ident'>e</span>)) + } +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"pattern"</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>RegexSearcher</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>it</span>: <span class='ident'>FindMatches</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span>, + <span class='ident'>last_step_end</span>: <span class='ident'>usize</span>, + <span class='ident'>next_match</span>: <span class='prelude-ty'>Option</span><span class='op'><</span>(<span class='ident'>usize</span>, <span class='ident'>usize</span>)<span class='op'>></span>, +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"pattern"</span>)]</span> +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> <span class='ident'>Pattern</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> <span class='kw'>for</span> <span class='kw-2'>&</span><span class='lifetime'>'r</span> <span class='ident'>Regex</span> { + <span class='kw'>type</span> <span class='ident'>Searcher</span> <span class='op'>=</span> <span class='ident'>RegexSearcher</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span>; + + <span class='kw'>fn</span> <span class='ident'>into_searcher</span>(<span class='self'>self</span>, <span class='ident'>haystack</span>: <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>RegexSearcher</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>RegexSearcher</span> { + <span class='ident'>it</span>: <span class='self'>self</span>.<span class='ident'>find_iter</span>(<span class='ident'>haystack</span>), + <span class='ident'>last_step_end</span>: <span class='number'>0</span>, + <span class='ident'>next_match</span>: <span class='prelude-val'>None</span>, + } + } +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span> <span class='op'>=</span> <span class='string'>"pattern"</span>)]</span> +<span class='kw'>unsafe</span> <span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> <span class='ident'>Searcher</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>RegexSearcher</span><span class='op'><</span><span class='lifetime'>'r</span>, <span class='lifetime'>'t</span><span class='op'>></span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>haystack</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span> { + <span class='self'>self</span>.<span class='ident'>it</span>.<span class='ident'>search</span> + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>next</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>SearchStep</span> { + <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>((<span class='ident'>s</span>, <span class='ident'>e</span>)) <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>next_match</span> { + <span class='self'>self</span>.<span class='ident'>next_match</span> <span class='op'>=</span> <span class='prelude-val'>None</span>; + <span class='self'>self</span>.<span class='ident'>last_step_end</span> <span class='op'>=</span> <span class='ident'>e</span>; + <span class='kw'>return</span> <span class='ident'>SearchStep</span>::<span class='ident'>Match</span>(<span class='ident'>s</span>, <span class='ident'>e</span>); + } + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>it</span>.<span class='ident'>next</span>() { + <span class='prelude-val'>None</span> <span class='op'>=></span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>last_step_end</span> <span class='op'><</span> <span class='self'>self</span>.<span class='ident'>haystack</span>().<span class='ident'>len</span>() { + <span class='kw'>let</span> <span class='ident'>last</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>last_step_end</span>; + <span class='self'>self</span>.<span class='ident'>last_step_end</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>haystack</span>().<span class='ident'>len</span>(); + <span class='ident'>SearchStep</span>::<span class='ident'>Reject</span>(<span class='ident'>last</span>, <span class='self'>self</span>.<span class='ident'>haystack</span>().<span class='ident'>len</span>()) + } <span class='kw'>else</span> { + <span class='ident'>SearchStep</span>::<span class='ident'>Done</span> + } + } + <span class='prelude-val'>Some</span>((<span class='ident'>s</span>, <span class='ident'>e</span>)) <span class='op'>=></span> { + <span class='kw'>if</span> <span class='ident'>s</span> <span class='op'>==</span> <span class='self'>self</span>.<span class='ident'>last_step_end</span> { + <span class='self'>self</span>.<span class='ident'>last_step_end</span> <span class='op'>=</span> <span class='ident'>e</span>; + <span class='ident'>SearchStep</span>::<span class='ident'>Match</span>(<span class='ident'>s</span>, <span class='ident'>e</span>) + } <span class='kw'>else</span> { + <span class='self'>self</span>.<span class='ident'>next_match</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>((<span class='ident'>s</span>, <span class='ident'>e</span>)); + <span class='kw'>let</span> <span class='ident'>last</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>last_step_end</span>; + <span class='self'>self</span>.<span class='ident'>last_step_end</span> <span class='op'>=</span> <span class='ident'>s</span>; + <span class='ident'>SearchStep</span>::<span class='ident'>Reject</span>(<span class='ident'>last</span>, <span class='ident'>s</span>) + } + } + } + } +} + +<span class='kw'>fn</span> <span class='ident'>exec</span>(<span class='ident'>re</span>: <span class='kw-2'>&</span><span class='ident'>Regex</span>, <span class='ident'>caps</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>CaptureIdxs</span>, <span class='ident'>text</span>: <span class='kw-2'>&</span><span class='ident'>str</span>, <span class='ident'>start</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='ident'>re</span> { + <span class='ident'>Regex</span>::<span class='ident'>Native</span>(<span class='ident'>ExNative</span> { <span class='kw-2'>ref</span> <span class='ident'>prog</span>, .. }) <span class='op'>=></span> (<span class='op'>*</span><span class='ident'>prog</span>)(<span class='ident'>caps</span>, <span class='ident'>text</span>, <span class='ident'>start</span>), + <span class='ident'>Regex</span>::<span class='ident'>Dynamic</span>(<span class='kw-2'>ref</span> <span class='ident'>prog</span>) <span class='op'>=></span> <span class='ident'>prog</span>.<span class='ident'>exec</span>(<span class='ident'>caps</span>, <span class='ident'>text</span>, <span class='ident'>start</span>), + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "regex"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/regex_macros/lib.rs.html b/src/regex_macros/lib.rs.html new file mode 100644 index 0000000..6a743da --- /dev/null +++ b/src/regex_macros/lib.rs.html @@ -0,0 +1,1215 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/regex_macros-0.1.20/src/lib.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>lib.rs.html -- source</title> + + <link rel="stylesheet" type="text/css" href="../../main.css"> + + <link rel="shortcut icon" href="http://www.rust-lang.org/favicon.ico"> + +</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"> + <a href='../../regex_macros/index.html'><img src='http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png' alt='' width='100'></a> + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100">100</span> +<span id="101">101</span> +<span id="102">102</span> +<span id="103">103</span> +<span id="104">104</span> +<span id="105">105</span> +<span id="106">106</span> +<span id="107">107</span> +<span id="108">108</span> +<span id="109">109</span> +<span id="110">110</span> +<span id="111">111</span> +<span id="112">112</span> +<span id="113">113</span> +<span id="114">114</span> +<span id="115">115</span> +<span id="116">116</span> +<span id="117">117</span> +<span id="118">118</span> +<span id="119">119</span> +<span id="120">120</span> +<span id="121">121</span> +<span id="122">122</span> +<span id="123">123</span> +<span id="124">124</span> +<span id="125">125</span> +<span id="126">126</span> +<span id="127">127</span> +<span id="128">128</span> +<span id="129">129</span> +<span id="130">130</span> +<span id="131">131</span> +<span id="132">132</span> +<span id="133">133</span> +<span id="134">134</span> +<span id="135">135</span> +<span id="136">136</span> +<span id="137">137</span> +<span id="138">138</span> +<span id="139">139</span> +<span id="140">140</span> +<span id="141">141</span> +<span id="142">142</span> +<span id="143">143</span> +<span id="144">144</span> +<span id="145">145</span> +<span id="146">146</span> +<span id="147">147</span> +<span id="148">148</span> +<span id="149">149</span> +<span id="150">150</span> +<span id="151">151</span> +<span id="152">152</span> +<span id="153">153</span> +<span id="154">154</span> +<span id="155">155</span> +<span id="156">156</span> +<span id="157">157</span> +<span id="158">158</span> +<span id="159">159</span> +<span id="160">160</span> +<span id="161">161</span> +<span id="162">162</span> +<span id="163">163</span> +<span id="164">164</span> +<span id="165">165</span> +<span id="166">166</span> +<span id="167">167</span> +<span id="168">168</span> +<span id="169">169</span> +<span id="170">170</span> +<span id="171">171</span> +<span id="172">172</span> +<span id="173">173</span> +<span id="174">174</span> +<span id="175">175</span> +<span id="176">176</span> +<span id="177">177</span> +<span id="178">178</span> +<span id="179">179</span> +<span id="180">180</span> +<span id="181">181</span> +<span id="182">182</span> +<span id="183">183</span> +<span id="184">184</span> +<span id="185">185</span> +<span id="186">186</span> +<span id="187">187</span> +<span id="188">188</span> +<span id="189">189</span> +<span id="190">190</span> +<span id="191">191</span> +<span id="192">192</span> +<span id="193">193</span> +<span id="194">194</span> +<span id="195">195</span> +<span id="196">196</span> +<span id="197">197</span> +<span id="198">198</span> +<span id="199">199</span> +<span id="200">200</span> +<span id="201">201</span> +<span id="202">202</span> +<span id="203">203</span> +<span id="204">204</span> +<span id="205">205</span> +<span id="206">206</span> +<span id="207">207</span> +<span id="208">208</span> +<span id="209">209</span> +<span id="210">210</span> +<span id="211">211</span> +<span id="212">212</span> +<span id="213">213</span> +<span id="214">214</span> +<span id="215">215</span> +<span id="216">216</span> +<span id="217">217</span> +<span id="218">218</span> +<span id="219">219</span> +<span id="220">220</span> +<span id="221">221</span> +<span id="222">222</span> +<span id="223">223</span> +<span id="224">224</span> +<span id="225">225</span> +<span id="226">226</span> +<span id="227">227</span> +<span id="228">228</span> +<span id="229">229</span> +<span id="230">230</span> +<span id="231">231</span> +<span id="232">232</span> +<span id="233">233</span> +<span id="234">234</span> +<span id="235">235</span> +<span id="236">236</span> +<span id="237">237</span> +<span id="238">238</span> +<span id="239">239</span> +<span id="240">240</span> +<span id="241">241</span> +<span id="242">242</span> +<span id="243">243</span> +<span id="244">244</span> +<span id="245">245</span> +<span id="246">246</span> +<span id="247">247</span> +<span id="248">248</span> +<span id="249">249</span> +<span id="250">250</span> +<span id="251">251</span> +<span id="252">252</span> +<span id="253">253</span> +<span id="254">254</span> +<span id="255">255</span> +<span id="256">256</span> +<span id="257">257</span> +<span id="258">258</span> +<span id="259">259</span> +<span id="260">260</span> +<span id="261">261</span> +<span id="262">262</span> +<span id="263">263</span> +<span id="264">264</span> +<span id="265">265</span> +<span id="266">266</span> +<span id="267">267</span> +<span id="268">268</span> +<span id="269">269</span> +<span id="270">270</span> +<span id="271">271</span> +<span id="272">272</span> +<span id="273">273</span> +<span id="274">274</span> +<span id="275">275</span> +<span id="276">276</span> +<span id="277">277</span> +<span id="278">278</span> +<span id="279">279</span> +<span id="280">280</span> +<span id="281">281</span> +<span id="282">282</span> +<span id="283">283</span> +<span id="284">284</span> +<span id="285">285</span> +<span id="286">286</span> +<span id="287">287</span> +<span id="288">288</span> +<span id="289">289</span> +<span id="290">290</span> +<span id="291">291</span> +<span id="292">292</span> +<span id="293">293</span> +<span id="294">294</span> +<span id="295">295</span> +<span id="296">296</span> +<span id="297">297</span> +<span id="298">298</span> +<span id="299">299</span> +<span id="300">300</span> +<span id="301">301</span> +<span id="302">302</span> +<span id="303">303</span> +<span id="304">304</span> +<span id="305">305</span> +<span id="306">306</span> +<span id="307">307</span> +<span id="308">308</span> +<span id="309">309</span> +<span id="310">310</span> +<span id="311">311</span> +<span id="312">312</span> +<span id="313">313</span> +<span id="314">314</span> +<span id="315">315</span> +<span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +<span id="326">326</span> +<span id="327">327</span> +<span id="328">328</span> +<span id="329">329</span> +<span id="330">330</span> +<span id="331">331</span> +<span id="332">332</span> +<span id="333">333</span> +<span id="334">334</span> +<span id="335">335</span> +<span id="336">336</span> +<span id="337">337</span> +<span id="338">338</span> +<span id="339">339</span> +<span id="340">340</span> +<span id="341">341</span> +<span id="342">342</span> +<span id="343">343</span> +<span id="344">344</span> +<span id="345">345</span> +<span id="346">346</span> +<span id="347">347</span> +<span id="348">348</span> +<span id="349">349</span> +<span id="350">350</span> +<span id="351">351</span> +<span id="352">352</span> +<span id="353">353</span> +<span id="354">354</span> +<span id="355">355</span> +<span id="356">356</span> +<span id="357">357</span> +<span id="358">358</span> +<span id="359">359</span> +<span id="360">360</span> +<span id="361">361</span> +<span id="362">362</span> +<span id="363">363</span> +<span id="364">364</span> +<span id="365">365</span> +<span id="366">366</span> +<span id="367">367</span> +<span id="368">368</span> +<span id="369">369</span> +<span id="370">370</span> +<span id="371">371</span> +<span id="372">372</span> +<span id="373">373</span> +<span id="374">374</span> +<span id="375">375</span> +<span id="376">376</span> +<span id="377">377</span> +<span id="378">378</span> +<span id="379">379</span> +<span id="380">380</span> +<span id="381">381</span> +<span id="382">382</span> +<span id="383">383</span> +<span id="384">384</span> +<span id="385">385</span> +<span id="386">386</span> +<span id="387">387</span> +<span id="388">388</span> +<span id="389">389</span> +<span id="390">390</span> +<span id="391">391</span> +<span id="392">392</span> +<span id="393">393</span> +<span id="394">394</span> +<span id="395">395</span> +<span id="396">396</span> +<span id="397">397</span> +<span id="398">398</span> +<span id="399">399</span> +<span id="400">400</span> +<span id="401">401</span> +<span id="402">402</span> +<span id="403">403</span> +<span id="404">404</span> +<span id="405">405</span> +<span id="406">406</span> +<span id="407">407</span> +<span id="408">408</span> +<span id="409">409</span> +<span id="410">410</span> +<span id="411">411</span> +<span id="412">412</span> +<span id="413">413</span> +<span id="414">414</span> +<span id="415">415</span> +<span id="416">416</span> +<span id="417">417</span> +<span id="418">418</span> +<span id="419">419</span> +<span id="420">420</span> +<span id="421">421</span> +<span id="422">422</span> +<span id="423">423</span> +<span id="424">424</span> +<span id="425">425</span> +<span id="426">426</span> +<span id="427">427</span> +<span id="428">428</span> +<span id="429">429</span> +<span id="430">430</span> +<span id="431">431</span> +<span id="432">432</span> +<span id="433">433</span> +<span id="434">434</span> +<span id="435">435</span> +<span id="436">436</span> +<span id="437">437</span> +<span id="438">438</span> +<span id="439">439</span> +<span id="440">440</span> +<span id="441">441</span> +<span id="442">442</span> +<span id="443">443</span> +<span id="444">444</span> +<span id="445">445</span> +<span id="446">446</span> +<span id="447">447</span> +<span id="448">448</span> +<span id="449">449</span> +<span id="450">450</span> +<span id="451">451</span> +<span id="452">452</span> +<span id="453">453</span> +<span id="454">454</span> +<span id="455">455</span> +<span id="456">456</span> +<span id="457">457</span> +<span id="458">458</span> +<span id="459">459</span> +<span id="460">460</span> +<span id="461">461</span> +<span id="462">462</span> +<span id="463">463</span> +<span id="464">464</span> +<span id="465">465</span> +<span id="466">466</span> +<span id="467">467</span> +<span id="468">468</span> +<span id="469">469</span> +<span id="470">470</span> +<span id="471">471</span> +<span id="472">472</span> +<span id="473">473</span> +<span id="474">474</span> +<span id="475">475</span> +<span id="476">476</span> +<span id="477">477</span> +<span id="478">478</span> +<span id="479">479</span> +<span id="480">480</span> +<span id="481">481</span> +<span id="482">482</span> +<span id="483">483</span> +<span id="484">484</span> +<span id="485">485</span> +<span id="486">486</span> +<span id="487">487</span> +<span id="488">488</span> +<span id="489">489</span> +<span id="490">490</span> +<span id="491">491</span> +<span id="492">492</span> +<span id="493">493</span> +<span id="494">494</span> +<span id="495">495</span> +<span id="496">496</span> +<span id="497">497</span> +<span id="498">498</span> +<span id="499">499</span> +<span id="500">500</span> +<span id="501">501</span> +<span id="502">502</span> +<span id="503">503</span> +<span id="504">504</span> +<span id="505">505</span> +<span id="506">506</span> +<span id="507">507</span> +<span id="508">508</span> +<span id="509">509</span> +<span id="510">510</span> +<span id="511">511</span> +<span id="512">512</span> +<span id="513">513</span> +<span id="514">514</span> +<span id="515">515</span> +<span id="516">516</span> +<span id="517">517</span> +<span id="518">518</span> +<span id="519">519</span> +<span id="520">520</span> +<span id="521">521</span> +<span id="522">522</span> +<span id="523">523</span> +<span id="524">524</span> +<span id="525">525</span> +<span id="526">526</span> +<span id="527">527</span> +<span id="528">528</span> +<span id="529">529</span> +<span id="530">530</span> +<span id="531">531</span> +<span id="532">532</span> +<span id="533">533</span> +<span id="534">534</span> +<span id="535">535</span> +<span id="536">536</span> +<span id="537">537</span> +<span id="538">538</span> +<span id="539">539</span> +<span id="540">540</span> +<span id="541">541</span> +<span id="542">542</span> +<span id="543">543</span> +<span id="544">544</span> +<span id="545">545</span> +<span id="546">546</span> +<span id="547">547</span> +<span id="548">548</span> +<span id="549">549</span> +<span id="550">550</span> +<span id="551">551</span> +<span id="552">552</span> +<span id="553">553</span> +<span id="554">554</span> +<span id="555">555</span> +<span id="556">556</span> +<span id="557">557</span> +<span id="558">558</span> +<span id="559">559</span> +</pre><pre class='rust '> +<span class='comment'>// Copyright 2014 The Rust Project Developers. See the COPYRIGHT</span> +<span class='comment'>// file at the top-level directory of this distribution and at</span> +<span class='comment'>// http://rust-lang.org/COPYRIGHT.</span> +<span class='comment'>//</span> +<span class='comment'>// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or</span> +<span class='comment'>// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license</span> +<span class='comment'>// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your</span> +<span class='comment'>// option. This file may not be copied, modified, or distributed</span> +<span class='comment'>// except according to those terms.</span> + +<span class='doccomment'>//! This crate provides the `regex!` macro. Its use is documented in the</span> +<span class='doccomment'>//! `regex` crate.</span> + +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>doc</span>(<span class='ident'>html_logo_url</span> <span class='op'>=</span> <span class='string'>"http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png"</span>, + <span class='ident'>html_favicon_url</span> <span class='op'>=</span> <span class='string'>"http://www.rust-lang.org/favicon.ico"</span>, + <span class='ident'>html_root_url</span> <span class='op'>=</span> <span class='string'>"http://doc.rust-lang.org/nightly/"</span>)]</span> + +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>feature</span>(<span class='ident'>plugin_registrar</span>, <span class='ident'>quote</span>, <span class='ident'>rustc_private</span>)]</span> + +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>regex</span>; +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>syntax</span>; +<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>rustc</span>; + +<span class='kw'>use</span> <span class='ident'>syntax</span>::<span class='ident'>ast</span>; +<span class='kw'>use</span> <span class='ident'>syntax</span>::<span class='ident'>codemap</span>; +<span class='kw'>use</span> <span class='ident'>syntax</span>::<span class='ident'>ext</span>::<span class='ident'>build</span>::<span class='ident'>AstBuilder</span>; +<span class='kw'>use</span> <span class='ident'>syntax</span>::<span class='ident'>ext</span>::<span class='ident'>base</span>::{<span class='ident'>ExtCtxt</span>, <span class='ident'>MacResult</span>, <span class='ident'>MacEager</span>, <span class='ident'>DummyResult</span>}; +<span class='kw'>use</span> <span class='ident'>syntax</span>::<span class='ident'>parse</span>::<span class='ident'>token</span>; +<span class='kw'>use</span> <span class='ident'>syntax</span>::<span class='ident'>print</span>::<span class='ident'>pprust</span>; +<span class='kw'>use</span> <span class='ident'>syntax</span>::<span class='ident'>fold</span>::<span class='ident'>Folder</span>; +<span class='kw'>use</span> <span class='ident'>syntax</span>::<span class='ident'>ptr</span>::<span class='ident'>P</span>; + +<span class='kw'>use</span> <span class='ident'>rustc</span>::<span class='ident'>plugin</span>::<span class='ident'>Registry</span>; + +<span class='kw'>use</span> <span class='ident'>regex</span>::<span class='ident'>Regex</span>; +<span class='kw'>use</span> <span class='ident'>regex</span>::<span class='ident'>internal</span>::{ + <span class='ident'>Inst</span>, <span class='ident'>LookInst</span>, <span class='ident'>OneChar</span>, <span class='ident'>CharRanges</span>, <span class='ident'>Program</span>, <span class='ident'>Dynamic</span>, <span class='ident'>Native</span>, +}; + +<span class='doccomment'>/// For the `regex!` syntax extension. Do not use.</span> +<span class='attribute'>#[<span class='ident'>plugin_registrar</span>]</span> +<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>plugin_registrar</span>(<span class='ident'>reg</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Registry</span>) { + <span class='ident'>reg</span>.<span class='ident'>register_macro</span>(<span class='string'>"regex"</span>, <span class='ident'>native</span>); +} + +<span class='doccomment'>/// Generates specialized code for the Pike VM for a particular regular</span> +<span class='doccomment'>/// expression.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// There are two primary differences between the code generated here and the</span> +<span class='doccomment'>/// general code in vm.rs.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// 1. All heap allocation is removed. Sized vector types are used instead.</span> +<span class='doccomment'>/// Care must be taken to make sure that these vectors are not copied</span> +<span class='doccomment'>/// gratuitously. (If you're not sure, run the benchmarks. They will yell</span> +<span class='doccomment'>/// at you if you do.)</span> +<span class='doccomment'>/// 2. The main `match instruction { ... }` expressions are replaced with more</span> +<span class='doccomment'>/// direct `match pc { ... }`. The generators can be found in</span> +<span class='doccomment'>/// `step_insts` and `add_insts`.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// It is strongly recommended to read the dynamic implementation in vm.rs</span> +<span class='doccomment'>/// first before trying to understand the code generator. The implementation</span> +<span class='doccomment'>/// strategy is identical and vm.rs has comments and will be easier to follow.</span> +<span class='kw'>fn</span> <span class='ident'>native</span>(<span class='ident'>cx</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>ExtCtxt</span>, <span class='ident'>sp</span>: <span class='ident'>codemap</span>::<span class='ident'>Span</span>, <span class='ident'>tts</span>: <span class='kw-2'>&</span>[<span class='ident'>ast</span>::<span class='ident'>TokenTree</span>]) + <span class='op'>-></span> <span class='ident'>Box</span><span class='op'><</span><span class='ident'>MacResult</span><span class='op'>+</span><span class='lifetime'>'static</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>regex</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>parse</span>(<span class='ident'>cx</span>, <span class='ident'>tts</span>) { + <span class='prelude-val'>Some</span>(<span class='ident'>r</span>) <span class='op'>=></span> <span class='ident'>r</span>, + <span class='comment'>// error is logged in 'parse' with cx.span_err</span> + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='kw'>return</span> <span class='ident'>DummyResult</span>::<span class='ident'>any</span>(<span class='ident'>sp</span>), + }; + <span class='comment'>// We use the largest possible size limit because this is happening at</span> + <span class='comment'>// compile time. We trust the programmer.</span> + <span class='kw'>let</span> <span class='ident'>re</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>Regex</span>::<span class='ident'>with_size_limit</span>(::<span class='ident'>std</span>::<span class='ident'>usize</span>::<span class='ident'>MAX</span>, <span class='kw-2'>&</span><span class='ident'>regex</span>) { + <span class='prelude-val'>Ok</span>(<span class='ident'>re</span>) <span class='op'>=></span> <span class='ident'>re</span>, + <span class='prelude-val'>Err</span>(<span class='ident'>err</span>) <span class='op'>=></span> { + <span class='ident'>cx</span>.<span class='ident'>span_err</span>(<span class='ident'>sp</span>, <span class='kw-2'>&</span><span class='ident'>err</span>.<span class='ident'>to_string</span>()); + <span class='kw'>return</span> <span class='ident'>DummyResult</span>::<span class='ident'>any</span>(<span class='ident'>sp</span>) + } + }; + <span class='kw'>let</span> <span class='ident'>prog</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>re</span> { + <span class='ident'>Dynamic</span>(<span class='kw-2'>ref</span> <span class='ident'>prog</span>) <span class='op'>=></span> <span class='ident'>prog</span>.<span class='ident'>clone</span>(), + <span class='ident'>Native</span>(_) <span class='op'>=></span> <span class='macro'>unreachable</span><span class='macro'>!</span>(), + }; + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>gen</span> <span class='op'>=</span> <span class='ident'>NfaGen</span> { + <span class='ident'>cx</span>: <span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>cx</span>, <span class='ident'>sp</span>: <span class='ident'>sp</span>, <span class='ident'>prog</span>: <span class='ident'>prog</span>, + <span class='ident'>names</span>: <span class='ident'>re</span>.<span class='ident'>names_iter</span>().<span class='ident'>collect</span>(), <span class='ident'>original</span>: <span class='ident'>re</span>.<span class='ident'>as_str</span>().<span class='ident'>to_string</span>(), + }; + <span class='ident'>MacEager</span>::<span class='ident'>expr</span>(<span class='ident'>gen</span>.<span class='ident'>code</span>()) +} + +<span class='kw'>struct</span> <span class='ident'>NfaGen</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='ident'>cx</span>: <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>ExtCtxt</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span>, + <span class='ident'>sp</span>: <span class='ident'>codemap</span>::<span class='ident'>Span</span>, + <span class='ident'>prog</span>: <span class='ident'>Program</span>, + <span class='ident'>names</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>String</span><span class='op'>>></span>, + <span class='ident'>original</span>: <span class='ident'>String</span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>NfaGen</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>code</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>P</span><span class='op'><</span><span class='ident'>ast</span>::<span class='ident'>Expr</span><span class='op'>></span> { + <span class='comment'>// Most or all of the following things are used in the quasiquoted</span> + <span class='comment'>// expression returned.</span> + <span class='kw'>let</span> <span class='ident'>num_cap_locs</span> <span class='op'>=</span> <span class='number'>2</span> <span class='op'>*</span> <span class='self'>self</span>.<span class='ident'>prog</span>.<span class='ident'>num_captures</span>(); + <span class='kw'>let</span> <span class='ident'>num_insts</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>prog</span>.<span class='ident'>insts</span>.<span class='ident'>len</span>(); + <span class='kw'>let</span> <span class='ident'>cap_names</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>vec_expr</span>(<span class='self'>self</span>.<span class='ident'>names</span>.<span class='ident'>iter</span>(), + <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='op'>|</span><span class='ident'>cx</span>, <span class='ident'>name</span><span class='op'>|</span> <span class='kw'>match</span> <span class='op'>*</span><span class='ident'>name</span> { + <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>name</span>) <span class='op'>=></span> { + <span class='kw'>let</span> <span class='ident'>name</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='op'>*</span><span class='op'>*</span><span class='ident'>name</span>; + <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='ident'>cx</span>, <span class='prelude-val'>Some</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>name</span>)) + } + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='ident'>cx</span>.<span class='ident'>expr_none</span>(<span class='self'>self</span>.<span class='ident'>sp</span>), + } + ); + <span class='kw'>let</span> <span class='ident'>prefix_anchor</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>prog</span>.<span class='ident'>anchored_begin</span>; + + <span class='comment'>// let prefix_lit = Rc::new(self.prog.prefix.as_bytes().to_vec());</span> + <span class='comment'>// let prefix_bytes = self.cx.expr_lit(self.sp, ast::LitBinary(prefix_lit));</span> + + <span class='comment'>// let check_prefix = self.check_prefix();</span> + <span class='kw'>let</span> <span class='ident'>step_insts</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>step_insts</span>(); + <span class='kw'>let</span> <span class='ident'>add_insts</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>add_insts</span>(); + <span class='kw'>let</span> <span class='ident'>regex</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='op'>*</span><span class='self'>self</span>.<span class='ident'>original</span>; + + <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, { +<span class='comment'>// When `regex!` is bound to a name that is not used, we have to make sure</span> +<span class='comment'>// that dead_code warnings don't bubble up to the user from the generated</span> +<span class='comment'>// code. Therefore, we suppress them by allowing dead_code. The effect is that</span> +<span class='comment'>// the user is only warned about *their* unused variable/code, and not the</span> +<span class='comment'>// unused code generated by regex!. See #14185 for an example.</span> +<span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>dead_code</span>)]</span> +<span class='kw'>static</span> <span class='ident'>CAP_NAMES</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> [<span class='prelude-ty'>Option</span><span class='op'><</span><span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span><span class='op'>></span>] <span class='op'>=</span> <span class='kw-2'>&</span><span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>cap_names</span>; + +<span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>dead_code</span>)]</span> +<span class='kw'>fn</span> <span class='ident'>exec</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span>( + <span class='kw-2'>mut</span> <span class='ident'>caps</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> [<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span>], + <span class='ident'>input</span>: <span class='kw-2'>&</span><span class='lifetime'>'t</span> <span class='ident'>str</span>, + <span class='ident'>start</span>: <span class='ident'>usize</span>, +) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='attribute'>#<span class='op'>!</span>[<span class='ident'>allow</span>(<span class='ident'>unused_imports</span>)]</span> + <span class='attribute'>#<span class='op'>!</span>[<span class='ident'>allow</span>(<span class='ident'>unused_mut</span>)]</span> + + <span class='kw'>use</span> <span class='ident'>regex</span>::<span class='ident'>internal</span>::{<span class='ident'>Char</span>, <span class='ident'>CharInput</span>, <span class='ident'>InputAt</span>, <span class='ident'>Input</span>, <span class='ident'>Inst</span>}; + + <span class='kw'>let</span> <span class='ident'>input</span> <span class='op'>=</span> <span class='ident'>CharInput</span>::<span class='ident'>new</span>(<span class='ident'>input</span>); + <span class='kw'>let</span> <span class='ident'>at</span> <span class='op'>=</span> <span class='ident'>input</span>.<span class='ident'>at</span>(<span class='ident'>start</span>); + <span class='kw'>return</span> <span class='ident'>Nfa</span> { + <span class='ident'>input</span>: <span class='ident'>input</span>, + <span class='ident'>ncaps</span>: <span class='ident'>caps</span>.<span class='ident'>len</span>(), + }.<span class='ident'>exec</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>NfaThreads</span>::<span class='ident'>new</span>(), <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>caps</span>, <span class='ident'>at</span>); + + <span class='kw'>struct</span> <span class='ident'>Nfa</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='ident'>input</span>: <span class='ident'>CharInput</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span>, + <span class='ident'>ncaps</span>: <span class='ident'>usize</span>, + } + + <span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> <span class='ident'>Nfa</span><span class='op'><</span><span class='lifetime'>'t</span><span class='op'>></span> { + <span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>unused_variables</span>)]</span> + <span class='kw'>fn</span> <span class='ident'>exec</span>( + <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, + <span class='kw-2'>mut</span> <span class='ident'>q</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>NfaThreads</span>, + <span class='kw-2'>mut</span> <span class='ident'>caps</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> [<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span>], + <span class='kw-2'>mut</span> <span class='ident'>at</span>: <span class='ident'>InputAt</span>, + ) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>matched</span> <span class='op'>=</span> <span class='boolval'>false</span>; + <span class='kw'>let</span> (<span class='kw-2'>mut</span> <span class='ident'>clist</span>, <span class='kw-2'>mut</span> <span class='ident'>nlist</span>) <span class='op'>=</span> (<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>q</span>.<span class='ident'>clist</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>q</span>.<span class='ident'>nlist</span>); + <span class='ident'>clist</span>.<span class='ident'>empty</span>(); <span class='ident'>nlist</span>.<span class='ident'>empty</span>(); +<span class='lifetime'>'LOOP</span>: <span class='kw'>loop</span> { + <span class='kw'>if</span> <span class='ident'>clist</span>.<span class='ident'>size</span> <span class='op'>==</span> <span class='number'>0</span> { + <span class='kw'>if</span> <span class='ident'>matched</span> <span class='op'>||</span> (<span class='op'>!</span><span class='ident'>at</span>.<span class='ident'>is_beginning</span>() <span class='op'>&&</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>prefix_anchor</span>) { + <span class='kw'>break</span>; + } + <span class='comment'>// TODO: Prefix matching... Hmm.</span> + <span class='comment'>// Prefix matching now uses a DFA, so I think this is</span> + <span class='comment'>// going to require encoding that DFA statically.</span> + } + <span class='kw'>if</span> <span class='ident'>clist</span>.<span class='ident'>size</span> <span class='op'>==</span> <span class='number'>0</span> <span class='op'>||</span> (<span class='op'>!</span><span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>prefix_anchor</span> <span class='op'>&&</span> <span class='op'>!</span><span class='ident'>matched</span>) { + <span class='self'>self</span>.<span class='ident'>add</span>(<span class='ident'>clist</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>caps</span>, <span class='number'>0</span>, <span class='ident'>at</span>); + } + <span class='kw'>let</span> <span class='ident'>at_next</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>input</span>.<span class='ident'>at</span>(<span class='ident'>at</span>.<span class='ident'>next_pos</span>()); + <span class='kw'>for</span> <span class='ident'>i</span> <span class='kw'>in</span> <span class='number'>0</span>..<span class='ident'>clist</span>.<span class='ident'>size</span> { + <span class='kw'>let</span> <span class='ident'>pc</span> <span class='op'>=</span> <span class='ident'>clist</span>.<span class='ident'>pc</span>(<span class='ident'>i</span>); + <span class='kw'>let</span> <span class='ident'>tcaps</span> <span class='op'>=</span> <span class='ident'>clist</span>.<span class='ident'>caps</span>(<span class='ident'>i</span>); + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>step</span>(<span class='ident'>nlist</span>, <span class='ident'>caps</span>, <span class='ident'>tcaps</span>, <span class='ident'>pc</span>, <span class='ident'>at</span>, <span class='ident'>at_next</span>) { + <span class='ident'>matched</span> <span class='op'>=</span> <span class='boolval'>true</span>; + <span class='kw'>if</span> <span class='ident'>caps</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>0</span> { + <span class='kw'>break</span> <span class='lifetime'>'LOOP</span>; + } + <span class='kw'>break</span>; + } + } + <span class='kw'>if</span> <span class='ident'>at</span>.<span class='ident'>char</span>().<span class='ident'>is_none</span>() { + <span class='kw'>break</span>; + } + <span class='ident'>at</span> <span class='op'>=</span> <span class='ident'>at_next</span>; + ::<span class='ident'>std</span>::<span class='ident'>mem</span>::<span class='ident'>swap</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>clist</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>nlist</span>); + <span class='ident'>nlist</span>.<span class='ident'>empty</span>(); + } + <span class='ident'>matched</span> + } + + <span class='comment'>// Sometimes `nlist` is never used (for empty regexes).</span> + <span class='attribute'>#[<span class='ident'>allow</span>(<span class='ident'>unused_variables</span>)]</span> + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>step</span>( + <span class='kw-2'>&</span><span class='self'>self</span>, + <span class='ident'>nlist</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Threads</span>, + <span class='ident'>caps</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> [<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span>], + <span class='ident'>thread_caps</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> [<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span>], + <span class='ident'>pc</span>: <span class='ident'>usize</span>, + <span class='ident'>at</span>: <span class='ident'>InputAt</span>, + <span class='ident'>at_next</span>: <span class='ident'>InputAt</span>, + ) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>step_insts</span>; + <span class='boolval'>false</span> + } + + <span class='kw'>fn</span> <span class='ident'>add</span>( + <span class='kw-2'>&</span><span class='self'>self</span>, + <span class='ident'>nlist</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Threads</span>, + <span class='ident'>thread_caps</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> [<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span>], + <span class='ident'>pc</span>: <span class='ident'>usize</span>, + <span class='ident'>at</span>: <span class='ident'>InputAt</span>, + ) { + <span class='kw'>if</span> <span class='ident'>nlist</span>.<span class='ident'>contains</span>(<span class='ident'>pc</span>) { + <span class='kw'>return</span>; + } + <span class='kw'>let</span> <span class='ident'>ti</span> <span class='op'>=</span> <span class='ident'>nlist</span>.<span class='ident'>add</span>(<span class='ident'>pc</span>); + <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>add_insts</span> + } + } + + <span class='kw'>struct</span> <span class='ident'>NfaThreads</span> { + <span class='ident'>clist</span>: <span class='ident'>Threads</span>, + <span class='ident'>nlist</span>: <span class='ident'>Threads</span>, + } + + <span class='kw'>struct</span> <span class='ident'>Threads</span> { + <span class='ident'>dense</span>: [<span class='ident'>Thread</span>; <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>num_insts</span>], + <span class='ident'>sparse</span>: [<span class='ident'>usize</span>; <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>num_insts</span>], + <span class='ident'>size</span>: <span class='ident'>usize</span>, + } + + <span class='kw'>struct</span> <span class='ident'>Thread</span> { + <span class='ident'>pc</span>: <span class='ident'>usize</span>, + <span class='ident'>caps</span>: [<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span>; <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>num_cap_locs</span>], + } + + <span class='kw'>impl</span> <span class='ident'>NfaThreads</span> { + <span class='kw'>fn</span> <span class='ident'>new</span>() <span class='op'>-></span> <span class='ident'>NfaThreads</span> { + <span class='ident'>NfaThreads</span> { + <span class='ident'>clist</span>: <span class='ident'>Threads</span>::<span class='ident'>new</span>(), + <span class='ident'>nlist</span>: <span class='ident'>Threads</span>::<span class='ident'>new</span>(), + } + } + + <span class='kw'>fn</span> <span class='ident'>swap</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + ::<span class='ident'>std</span>::<span class='ident'>mem</span>::<span class='ident'>swap</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>clist</span>, <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>nlist</span>); + } + } + + <span class='kw'>impl</span> <span class='ident'>Threads</span> { + <span class='kw'>fn</span> <span class='ident'>new</span>() <span class='op'>-></span> <span class='ident'>Threads</span> { + <span class='ident'>Threads</span> { + <span class='comment'>// These unsafe blocks are used for performance reasons, as it</span> + <span class='comment'>// gives us a zero-cost initialization of a sparse set. The</span> + <span class='comment'>// trick is described in more detail here:</span> + <span class='comment'>// http://research.swtch.com/sparse</span> + <span class='comment'>// The idea here is to avoid initializing threads that never</span> + <span class='comment'>// need to be initialized, particularly for larger regexs with</span> + <span class='comment'>// a lot of instructions.</span> + <span class='ident'>dense</span>: <span class='kw'>unsafe</span> { ::<span class='ident'>std</span>::<span class='ident'>mem</span>::<span class='ident'>uninitialized</span>() }, + <span class='ident'>sparse</span>: <span class='kw'>unsafe</span> { ::<span class='ident'>std</span>::<span class='ident'>mem</span>::<span class='ident'>uninitialized</span>() }, + <span class='ident'>size</span>: <span class='number'>0</span>, + } + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>add</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>pc</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='kw'>let</span> <span class='ident'>i</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>size</span>; + <span class='self'>self</span>.<span class='ident'>dense</span>[<span class='ident'>i</span>].<span class='ident'>pc</span> <span class='op'>=</span> <span class='ident'>pc</span>; + <span class='self'>self</span>.<span class='ident'>sparse</span>[<span class='ident'>pc</span>] <span class='op'>=</span> <span class='ident'>i</span>; + <span class='self'>self</span>.<span class='ident'>size</span> <span class='op'>+=</span> <span class='number'>1</span>; + <span class='ident'>i</span> + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>thread</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>i</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Thread</span> { + <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>dense</span>[<span class='ident'>i</span>] + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>contains</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>pc</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>sparse</span>[<span class='ident'>pc</span>]; + <span class='ident'>s</span> <span class='op'><</span> <span class='self'>self</span>.<span class='ident'>size</span> <span class='op'>&&</span> <span class='self'>self</span>.<span class='ident'>dense</span>[<span class='ident'>s</span>].<span class='ident'>pc</span> <span class='op'>==</span> <span class='ident'>pc</span> + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>empty</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='self'>self</span>.<span class='ident'>size</span> <span class='op'>=</span> <span class='number'>0</span>; + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>pc</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>i</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='self'>self</span>.<span class='ident'>dense</span>[<span class='ident'>i</span>].<span class='ident'>pc</span> + } + + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>caps</span><span class='op'><</span><span class='lifetime'>'r</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='lifetime'>'r</span> <span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>i</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='lifetime'>'r</span> <span class='kw-2'>mut</span> [<span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span>] { + <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>.<span class='ident'>dense</span>[<span class='ident'>i</span>].<span class='ident'>caps</span> + } + } +} + +::<span class='ident'>regex</span>::<span class='ident'>internal</span>::<span class='ident'>Native</span>(::<span class='ident'>regex</span>::<span class='ident'>internal</span>::<span class='ident'>ExNative</span> { + <span class='ident'>original</span>: <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>regex</span>, + <span class='ident'>names</span>: <span class='kw-2'>&</span><span class='ident'>CAP_NAMES</span>, + <span class='ident'>prog</span>: <span class='ident'>exec</span>, +}) + }) + } + + <span class='comment'>// Generates code for the `add` method, which is responsible for adding</span> + <span class='comment'>// zero-width states to the next queue of states to visit.</span> + <span class='kw'>fn</span> <span class='ident'>add_insts</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>P</span><span class='op'><</span><span class='ident'>ast</span>::<span class='ident'>Expr</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>arms</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>prog</span>.<span class='ident'>insts</span>.<span class='ident'>iter</span>().<span class='ident'>enumerate</span>().<span class='ident'>map</span>(<span class='op'>|</span>(<span class='ident'>pc</span>, <span class='ident'>inst</span>)<span class='op'>|</span> { + <span class='kw'>let</span> <span class='ident'>nextpc</span> <span class='op'>=</span> <span class='ident'>pc</span> <span class='op'>+</span> <span class='number'>1</span>; + <span class='kw'>let</span> <span class='ident'>body</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='op'>*</span><span class='ident'>inst</span> { + <span class='ident'>Inst</span>::<span class='ident'>EmptyLook</span>(<span class='ident'>LookInst</span>::<span class='ident'>StartLine</span>) <span class='op'>=></span> { + <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, { + <span class='kw'>let</span> <span class='ident'>prev</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>input</span>.<span class='ident'>previous_at</span>(<span class='ident'>at</span>.<span class='ident'>pos</span>()); + <span class='kw'>if</span> <span class='ident'>prev</span>.<span class='ident'>char</span>().<span class='ident'>is_none</span>() <span class='op'>||</span> <span class='ident'>prev</span>.<span class='ident'>char</span>() <span class='op'>==</span> <span class='string'>'\n'</span> { + <span class='self'>self</span>.<span class='ident'>add</span>(<span class='ident'>nlist</span>, <span class='ident'>thread_caps</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>nextpc</span>, <span class='ident'>at</span>); + } + }) + } + <span class='ident'>Inst</span>::<span class='ident'>EmptyLook</span>(<span class='ident'>LookInst</span>::<span class='ident'>EndLine</span>) <span class='op'>=></span> { + <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, { + <span class='kw'>if</span> <span class='ident'>at</span>.<span class='ident'>char</span>().<span class='ident'>is_none</span>() <span class='op'>||</span> <span class='ident'>at</span>.<span class='ident'>char</span>() <span class='op'>==</span> <span class='string'>'\n'</span> { + <span class='self'>self</span>.<span class='ident'>add</span>(<span class='ident'>nlist</span>, <span class='ident'>thread_caps</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>nextpc</span>, <span class='ident'>at</span>); + } + }) + } + <span class='ident'>Inst</span>::<span class='ident'>EmptyLook</span>(<span class='ident'>LookInst</span>::<span class='ident'>StartText</span>) <span class='op'>=></span> { + <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, { + <span class='kw'>let</span> <span class='ident'>prev</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>input</span>.<span class='ident'>previous_at</span>(<span class='ident'>at</span>.<span class='ident'>pos</span>()); + <span class='kw'>if</span> <span class='ident'>prev</span>.<span class='ident'>char</span>().<span class='ident'>is_none</span>() { + <span class='self'>self</span>.<span class='ident'>add</span>(<span class='ident'>nlist</span>, <span class='ident'>thread_caps</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>nextpc</span>, <span class='ident'>at</span>); + } + }) + } + <span class='ident'>Inst</span>::<span class='ident'>EmptyLook</span>(<span class='ident'>LookInst</span>::<span class='ident'>EndText</span>) <span class='op'>=></span> { + <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, { + <span class='kw'>if</span> <span class='ident'>at</span>.<span class='ident'>char</span>().<span class='ident'>is_none</span>() { + <span class='self'>self</span>.<span class='ident'>add</span>(<span class='ident'>nlist</span>, <span class='ident'>thread_caps</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>nextpc</span>, <span class='ident'>at</span>); + } + }) + } + <span class='ident'>Inst</span>::<span class='ident'>EmptyLook</span>(<span class='kw-2'>ref</span> <span class='ident'>wbty</span>) <span class='op'>=></span> { + <span class='kw'>let</span> <span class='ident'>m</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='op'>*</span><span class='ident'>wbty</span> <span class='op'>==</span> <span class='ident'>LookInst</span>::<span class='ident'>WordBoundary</span> { + <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, { <span class='ident'>w1</span> <span class='op'>^</span> <span class='ident'>w2</span> }) + } <span class='kw'>else</span> { + <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, { <span class='op'>!</span>(<span class='ident'>w1</span> <span class='op'>^</span> <span class='ident'>w2</span>) }) + }; + <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, { + <span class='kw'>let</span> <span class='ident'>prev</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>input</span>.<span class='ident'>previous_at</span>(<span class='ident'>at</span>.<span class='ident'>pos</span>()); + <span class='kw'>let</span> <span class='ident'>w1</span> <span class='op'>=</span> <span class='ident'>prev</span>.<span class='ident'>char</span>().<span class='ident'>is_word_char</span>(); + <span class='kw'>let</span> <span class='ident'>w2</span> <span class='op'>=</span> <span class='ident'>at</span>.<span class='ident'>char</span>().<span class='ident'>is_word_char</span>(); + <span class='kw'>if</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>m</span> { + <span class='self'>self</span>.<span class='ident'>add</span>(<span class='ident'>nlist</span>, <span class='ident'>thread_caps</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>nextpc</span>, <span class='ident'>at</span>); + } + }) + } + <span class='ident'>Inst</span>::<span class='ident'>Save</span>(<span class='ident'>slot</span>) <span class='op'>=></span> <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, { + <span class='kw'>if</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>slot</span> <span class='op'>>=</span> <span class='self'>self</span>.<span class='ident'>ncaps</span> { + <span class='self'>self</span>.<span class='ident'>add</span>(<span class='ident'>nlist</span>, <span class='ident'>thread_caps</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>nextpc</span>, <span class='ident'>at</span>); + } <span class='kw'>else</span> { + <span class='kw'>let</span> <span class='ident'>old</span> <span class='op'>=</span> <span class='ident'>thread_caps</span>[<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>slot</span>]; + <span class='ident'>thread_caps</span>[<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>slot</span>] <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>at</span>.<span class='ident'>pos</span>()); + <span class='self'>self</span>.<span class='ident'>add</span>(<span class='ident'>nlist</span>, <span class='ident'>thread_caps</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>nextpc</span>, <span class='ident'>at</span>); + <span class='ident'>thread_caps</span>[<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>slot</span>] <span class='op'>=</span> <span class='ident'>old</span>; + } + }), + <span class='ident'>Inst</span>::<span class='ident'>Jump</span>(<span class='ident'>to</span>) <span class='op'>=></span> <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, { + <span class='self'>self</span>.<span class='ident'>add</span>(<span class='ident'>nlist</span>, <span class='ident'>thread_caps</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>to</span>, <span class='ident'>at</span>); + }), + <span class='ident'>Inst</span>::<span class='ident'>Split</span>(<span class='ident'>x</span>, <span class='ident'>y</span>) <span class='op'>=></span> <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, { + <span class='self'>self</span>.<span class='ident'>add</span>(<span class='ident'>nlist</span>, <span class='ident'>thread_caps</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>x</span>, <span class='ident'>at</span>); + <span class='self'>self</span>.<span class='ident'>add</span>(<span class='ident'>nlist</span>, <span class='ident'>thread_caps</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>y</span>, <span class='ident'>at</span>); + }), + <span class='comment'>// For Match, OneChar, CharClass, Any, AnyNoNL</span> + _ <span class='op'>=></span> <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>t</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>nlist</span>.<span class='ident'>thread</span>(<span class='ident'>ti</span>); + <span class='kw'>for</span> (<span class='ident'>slot</span>, <span class='ident'>val</span>) <span class='kw'>in</span> <span class='ident'>t</span>.<span class='ident'>caps</span>.<span class='ident'>iter_mut</span>().<span class='ident'>zip</span>(<span class='ident'>thread_caps</span>.<span class='ident'>iter</span>()) { + <span class='op'>*</span><span class='ident'>slot</span> <span class='op'>=</span> <span class='op'>*</span><span class='ident'>val</span>; + } + }), + }; + <span class='self'>self</span>.<span class='ident'>arm_inst</span>(<span class='ident'>pc</span>, <span class='ident'>body</span>) + }).<span class='ident'>collect</span>::<span class='op'><</span><span class='ident'>Vec</span><span class='op'><</span><span class='ident'>ast</span>::<span class='ident'>Arm</span><span class='op'>>></span>(); + <span class='self'>self</span>.<span class='ident'>match_insts</span>(<span class='ident'>arms</span>) + } + + <span class='comment'>// Generates the code for the `step` method, which processes all states</span> + <span class='comment'>// in the current queue that consume a single character.</span> + <span class='kw'>fn</span> <span class='ident'>step_insts</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>P</span><span class='op'><</span><span class='ident'>ast</span>::<span class='ident'>Expr</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>arms</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>prog</span>.<span class='ident'>insts</span>.<span class='ident'>iter</span>().<span class='ident'>enumerate</span>().<span class='ident'>map</span>(<span class='op'>|</span>(<span class='ident'>pc</span>, <span class='ident'>inst</span>)<span class='op'>|</span> { + <span class='kw'>let</span> <span class='ident'>nextpc</span> <span class='op'>=</span> <span class='ident'>pc</span> <span class='op'>+</span> <span class='number'>1</span>; + <span class='kw'>let</span> <span class='ident'>body</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='op'>*</span><span class='ident'>inst</span> { + <span class='ident'>Inst</span>::<span class='ident'>Match</span> <span class='op'>=></span> <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, { + <span class='kw'>for</span> (<span class='ident'>slot</span>, <span class='ident'>val</span>) <span class='kw'>in</span> <span class='ident'>caps</span>.<span class='ident'>iter_mut</span>().<span class='ident'>zip</span>(<span class='ident'>thread_caps</span>.<span class='ident'>iter</span>()) { + <span class='op'>*</span><span class='ident'>slot</span> <span class='op'>=</span> <span class='op'>*</span><span class='ident'>val</span>; + } + <span class='kw'>return</span> <span class='boolval'>true</span>; + }), + <span class='ident'>Inst</span>::<span class='ident'>Char</span>(<span class='ident'>OneChar</span> { <span class='ident'>c</span>, <span class='ident'>casei</span> }) <span class='op'>=></span> <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, { + <span class='kw'>if</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>c</span> <span class='op'>==</span> <span class='ident'>at</span>.<span class='ident'>char</span>() <span class='op'>||</span> (<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>casei</span> <span class='op'>&&</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>c</span> <span class='op'>==</span> <span class='ident'>at</span>.<span class='ident'>char</span>().<span class='ident'>case_fold</span>()) { + <span class='self'>self</span>.<span class='ident'>add</span>(<span class='ident'>nlist</span>, <span class='ident'>thread_caps</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>nextpc</span>, <span class='ident'>at_next</span>); + } + <span class='kw'>return</span> <span class='boolval'>false</span>; + }), + <span class='ident'>Inst</span>::<span class='ident'>Ranges</span>(<span class='ident'>CharRanges</span> { <span class='kw-2'>ref</span> <span class='ident'>ranges</span>, <span class='ident'>casei</span> }) <span class='op'>=></span> { + <span class='kw'>let</span> <span class='ident'>match_class</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>match_class</span>(<span class='ident'>ranges</span>); + <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>c</span> <span class='op'>=</span> <span class='ident'>at</span>.<span class='ident'>char</span>(); + <span class='kw'>if</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>casei</span> { + <span class='ident'>c</span> <span class='op'>=</span> <span class='ident'>c</span>.<span class='ident'>case_fold</span>(); + } + <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>c</span>) <span class='op'>=</span> <span class='ident'>c</span>.<span class='ident'>as_char</span>() { + <span class='kw'>if</span> <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>match_class</span> { + <span class='self'>self</span>.<span class='ident'>add</span>(<span class='ident'>nlist</span>, <span class='ident'>thread_caps</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>nextpc</span>, <span class='ident'>at_next</span>); + } + } + <span class='kw'>return</span> <span class='boolval'>false</span>; + }) + } + <span class='comment'>// EmptyLook, Save, Jump, Split</span> + _ <span class='op'>=></span> <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, { <span class='kw'>return</span> <span class='boolval'>false</span>; }), + }; + <span class='self'>self</span>.<span class='ident'>arm_inst</span>(<span class='ident'>pc</span>, <span class='ident'>body</span>) + }).<span class='ident'>collect</span>::<span class='op'><</span><span class='ident'>Vec</span><span class='op'><</span><span class='ident'>ast</span>::<span class='ident'>Arm</span><span class='op'>>></span>(); + + <span class='self'>self</span>.<span class='ident'>match_insts</span>(<span class='ident'>arms</span>) + } + + <span class='comment'>// Translates a character class into a match expression.</span> + <span class='comment'>// This avoids a binary search (and is hopefully replaced by a jump</span> + <span class='comment'>// table).</span> + <span class='kw'>fn</span> <span class='ident'>match_class</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>ranges</span>: <span class='kw-2'>&</span>[(<span class='ident'>char</span>, <span class='ident'>char</span>)]) <span class='op'>-></span> <span class='ident'>P</span><span class='op'><</span><span class='ident'>ast</span>::<span class='ident'>Expr</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>arms</span> <span class='op'>=</span> <span class='ident'>ranges</span>.<span class='ident'>iter</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='kw-2'>&</span>(<span class='ident'>start</span>, <span class='ident'>end</span>)<span class='op'>|</span> { + <span class='kw'>let</span> <span class='ident'>pat</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>cx</span>.<span class='ident'>pat</span>( + <span class='self'>self</span>.<span class='ident'>sp</span>, <span class='ident'>ast</span>::<span class='ident'>PatRange</span>( + <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>start</span>), <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>end</span>))); + <span class='self'>self</span>.<span class='ident'>cx</span>.<span class='ident'>arm</span>(<span class='self'>self</span>.<span class='ident'>sp</span>, <span class='macro'>vec</span><span class='macro'>!</span>(<span class='ident'>pat</span>), <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, <span class='boolval'>true</span>)) + }).<span class='ident'>collect</span>::<span class='op'><</span><span class='ident'>Vec</span><span class='op'><</span><span class='ident'>ast</span>::<span class='ident'>Arm</span><span class='op'>>></span>(); + + <span class='ident'>arms</span>.<span class='ident'>push</span>(<span class='self'>self</span>.<span class='ident'>wild_arm_expr</span>(<span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, <span class='boolval'>false</span>))); + <span class='kw'>let</span> <span class='ident'>match_on</span> <span class='op'>=</span> <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, <span class='ident'>c</span>); + <span class='self'>self</span>.<span class='ident'>cx</span>.<span class='ident'>expr_match</span>(<span class='self'>self</span>.<span class='ident'>sp</span>, <span class='ident'>match_on</span>, <span class='ident'>arms</span>) + } + + <span class='comment'>// Generates code for checking a literal prefix of the search string.</span> + <span class='comment'>// The code is only generated if the regex *has* a literal prefix.</span> + <span class='comment'>// Otherwise, a no-op is returned.</span> + <span class='comment'>// fn check_prefix(&self) -> P<ast::Expr> {</span> + <span class='comment'>// if self.prog.prefixes.len() == 0 {</span> + <span class='comment'>// self.empty_block()</span> + <span class='comment'>// } else {</span> + <span class='comment'>// quote_expr!(self.cx,</span> + <span class='comment'>// if clist.size == 0 {</span> + <span class='comment'>// let haystack = &self.input.as_bytes()[self.ic..];</span> + <span class='comment'>// match find_prefix(prefix_bytes, haystack) {</span> + <span class='comment'>// None => break,</span> + <span class='comment'>// Some(i) => {</span> + <span class='comment'>// self.ic += i;</span> + <span class='comment'>// next_ic = self.chars.set(self.ic);</span> + <span class='comment'>// }</span> + <span class='comment'>// }</span> + <span class='comment'>// }</span> + <span class='comment'>// )</span> + <span class='comment'>// }</span> + <span class='comment'>// }</span> + + <span class='comment'>// Builds a `match pc { ... }` expression from a list of arms, specifically</span> + <span class='comment'>// for matching the current program counter with an instruction.</span> + <span class='comment'>// A wild-card arm is automatically added that executes a no-op. It will</span> + <span class='comment'>// never be used, but is added to satisfy the compiler complaining about</span> + <span class='comment'>// non-exhaustive patterns.</span> + <span class='kw'>fn</span> <span class='ident'>match_insts</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='kw-2'>mut</span> <span class='ident'>arms</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>ast</span>::<span class='ident'>Arm</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>P</span><span class='op'><</span><span class='ident'>ast</span>::<span class='ident'>Expr</span><span class='op'>></span> { + <span class='ident'>arms</span>.<span class='ident'>push</span>(<span class='self'>self</span>.<span class='ident'>wild_arm_expr</span>(<span class='self'>self</span>.<span class='ident'>empty_block</span>())); + <span class='self'>self</span>.<span class='ident'>cx</span>.<span class='ident'>expr_match</span>(<span class='self'>self</span>.<span class='ident'>sp</span>, <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, <span class='ident'>pc</span>), <span class='ident'>arms</span>) + } + + <span class='kw'>fn</span> <span class='ident'>empty_block</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>P</span><span class='op'><</span><span class='ident'>ast</span>::<span class='ident'>Expr</span><span class='op'>></span> { + <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, {}) + } + + <span class='comment'>// Creates a match arm for the instruction at `pc` with the expression</span> + <span class='comment'>// `body`.</span> + <span class='kw'>fn</span> <span class='ident'>arm_inst</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>pc</span>: <span class='ident'>usize</span>, <span class='ident'>body</span>: <span class='ident'>P</span><span class='op'><</span><span class='ident'>ast</span>::<span class='ident'>Expr</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>ast</span>::<span class='ident'>Arm</span> { + <span class='kw'>let</span> <span class='ident'>pc_pat</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>cx</span>.<span class='ident'>pat_lit</span>(<span class='self'>self</span>.<span class='ident'>sp</span>, <span class='macro'>quote_expr</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>pc</span>)); + + <span class='self'>self</span>.<span class='ident'>cx</span>.<span class='ident'>arm</span>(<span class='self'>self</span>.<span class='ident'>sp</span>, <span class='macro'>vec</span><span class='macro'>!</span>(<span class='ident'>pc_pat</span>), <span class='ident'>body</span>) + } + + <span class='comment'>// Creates a wild-card match arm with the expression `body`.</span> + <span class='kw'>fn</span> <span class='ident'>wild_arm_expr</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>body</span>: <span class='ident'>P</span><span class='op'><</span><span class='ident'>ast</span>::<span class='ident'>Expr</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>ast</span>::<span class='ident'>Arm</span> { + <span class='ident'>ast</span>::<span class='ident'>Arm</span> { + <span class='ident'>attrs</span>: <span class='macro'>vec</span><span class='macro'>!</span>(), + <span class='ident'>pats</span>: <span class='macro'>vec</span><span class='macro'>!</span>(<span class='ident'>P</span>(<span class='ident'>ast</span>::<span class='ident'>Pat</span>{ + <span class='ident'>id</span>: <span class='ident'>ast</span>::<span class='ident'>DUMMY_NODE_ID</span>, + <span class='ident'>span</span>: <span class='self'>self</span>.<span class='ident'>sp</span>, + <span class='ident'>node</span>: <span class='ident'>ast</span>::<span class='ident'>PatWild</span>(<span class='ident'>ast</span>::<span class='ident'>PatWildSingle</span>), + })), + <span class='ident'>guard</span>: <span class='prelude-val'>None</span>, + <span class='ident'>body</span>: <span class='ident'>body</span>, + } + } + + <span class='comment'>// Converts `xs` to a `[x1, x2, .., xN]` expression by calling `to_expr`</span> + <span class='comment'>// on each element in `xs`.</span> + <span class='kw'>fn</span> <span class='ident'>vec_expr</span><span class='op'><</span><span class='ident'>T</span>, <span class='ident'>It</span>: <span class='ident'>Iterator</span><span class='op'><</span><span class='ident'>Item</span><span class='op'>=</span><span class='ident'>T</span><span class='op'>>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>xs</span>: <span class='ident'>It</span>, + <span class='ident'>to_expr</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>FnMut</span>(<span class='kw-2'>&</span><span class='ident'>ExtCtxt</span>, <span class='ident'>T</span>) <span class='op'>-></span> <span class='ident'>P</span><span class='op'><</span><span class='ident'>ast</span>::<span class='ident'>Expr</span><span class='op'>></span>) + <span class='op'>-></span> <span class='ident'>P</span><span class='op'><</span><span class='ident'>ast</span>::<span class='ident'>Expr</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>exprs</span> <span class='op'>=</span> <span class='ident'>xs</span>.<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> <span class='ident'>to_expr</span>(<span class='self'>self</span>.<span class='ident'>cx</span>, <span class='ident'>x</span>)).<span class='ident'>collect</span>(); + <span class='self'>self</span>.<span class='ident'>cx</span>.<span class='ident'>expr_vec</span>(<span class='self'>self</span>.<span class='ident'>sp</span>, <span class='ident'>exprs</span>) + } +} + +<span class='doccomment'>/// Looks for a single string literal and returns it.</span> +<span class='doccomment'>/// Otherwise, logs an error with cx.span_err and returns None.</span> +<span class='kw'>fn</span> <span class='ident'>parse</span>(<span class='ident'>cx</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>ExtCtxt</span>, <span class='ident'>tts</span>: <span class='kw-2'>&</span>[<span class='ident'>ast</span>::<span class='ident'>TokenTree</span>]) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>parser</span> <span class='op'>=</span> <span class='ident'>cx</span>.<span class='ident'>new_parser_from_tts</span>(<span class='ident'>tts</span>); + <span class='kw'>let</span> <span class='ident'>entry</span> <span class='op'>=</span> <span class='ident'>cx</span>.<span class='ident'>expander</span>().<span class='ident'>fold_expr</span>(<span class='ident'>parser</span>.<span class='ident'>parse_expr</span>()); + <span class='kw'>let</span> <span class='ident'>regex</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>entry</span>.<span class='ident'>node</span> { + <span class='ident'>ast</span>::<span class='ident'>ExprLit</span>(<span class='kw-2'>ref</span> <span class='ident'>lit</span>) <span class='op'>=></span> { + <span class='kw'>match</span> <span class='ident'>lit</span>.<span class='ident'>node</span> { + <span class='ident'>ast</span>::<span class='ident'>LitStr</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>, _) <span class='op'>=></span> <span class='ident'>s</span>.<span class='ident'>to_string</span>(), + _ <span class='op'>=></span> { + <span class='ident'>cx</span>.<span class='ident'>span_err</span>(<span class='ident'>entry</span>.<span class='ident'>span</span>, <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>( + <span class='string'>"expected string literal but got `{}`"</span>, + <span class='ident'>pprust</span>::<span class='ident'>lit_to_string</span>(<span class='kw-2'>&</span><span class='op'>*</span><span class='op'>*</span><span class='ident'>lit</span>))); + <span class='kw'>return</span> <span class='prelude-val'>None</span> + } + } + } + _ <span class='op'>=></span> { + <span class='ident'>cx</span>.<span class='ident'>span_err</span>(<span class='ident'>entry</span>.<span class='ident'>span</span>, <span class='kw-2'>&</span><span class='macro'>format</span><span class='macro'>!</span>( + <span class='string'>"expected string literal but got `{}`"</span>, + <span class='ident'>pprust</span>::<span class='ident'>expr_to_string</span>(<span class='kw-2'>&</span><span class='op'>*</span><span class='ident'>entry</span>))); + <span class='kw'>return</span> <span class='prelude-val'>None</span> + } + }; + <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>parser</span>.<span class='ident'>eat</span>(<span class='kw-2'>&</span><span class='ident'>token</span>::<span class='ident'>Eof</span>).<span class='ident'>ok</span>().<span class='ident'>unwrap</span>() { + <span class='ident'>cx</span>.<span class='ident'>span_err</span>(<span class='ident'>parser</span>.<span class='ident'>span</span>, <span class='string'>"only one string literal allowed"</span>); + <span class='kw'>return</span> <span class='prelude-val'>None</span>; + } + <span class='prelude-val'>Some</span>(<span class='ident'>regex</span>) +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "regex_macros"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/regex_syntax/lib.rs.html b/src/regex_syntax/lib.rs.html new file mode 100644 index 0000000..7c8b82b --- /dev/null +++ b/src/regex_syntax/lib.rs.html @@ -0,0 +1,2465 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/regex-syntax-0.1.2/src/lib.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>lib.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100"> 100</span> +<span id="101"> 101</span> +<span id="102"> 102</span> +<span id="103"> 103</span> +<span id="104"> 104</span> +<span id="105"> 105</span> +<span id="106"> 106</span> +<span id="107"> 107</span> +<span id="108"> 108</span> +<span id="109"> 109</span> +<span id="110"> 110</span> +<span id="111"> 111</span> +<span id="112"> 112</span> +<span id="113"> 113</span> +<span id="114"> 114</span> +<span id="115"> 115</span> +<span id="116"> 116</span> +<span id="117"> 117</span> +<span id="118"> 118</span> +<span id="119"> 119</span> +<span id="120"> 120</span> +<span id="121"> 121</span> +<span id="122"> 122</span> +<span id="123"> 123</span> +<span id="124"> 124</span> +<span id="125"> 125</span> +<span id="126"> 126</span> +<span id="127"> 127</span> +<span id="128"> 128</span> +<span id="129"> 129</span> +<span id="130"> 130</span> +<span id="131"> 131</span> +<span id="132"> 132</span> +<span id="133"> 133</span> +<span id="134"> 134</span> +<span id="135"> 135</span> +<span id="136"> 136</span> +<span id="137"> 137</span> +<span id="138"> 138</span> +<span id="139"> 139</span> +<span id="140"> 140</span> +<span id="141"> 141</span> +<span id="142"> 142</span> +<span id="143"> 143</span> +<span id="144"> 144</span> +<span id="145"> 145</span> +<span id="146"> 146</span> +<span id="147"> 147</span> +<span id="148"> 148</span> +<span id="149"> 149</span> +<span id="150"> 150</span> +<span id="151"> 151</span> +<span id="152"> 152</span> +<span id="153"> 153</span> +<span id="154"> 154</span> +<span id="155"> 155</span> +<span id="156"> 156</span> +<span id="157"> 157</span> +<span id="158"> 158</span> +<span id="159"> 159</span> +<span id="160"> 160</span> +<span id="161"> 161</span> +<span id="162"> 162</span> +<span id="163"> 163</span> +<span id="164"> 164</span> +<span id="165"> 165</span> +<span id="166"> 166</span> +<span id="167"> 167</span> +<span id="168"> 168</span> +<span id="169"> 169</span> +<span id="170"> 170</span> +<span id="171"> 171</span> +<span id="172"> 172</span> +<span id="173"> 173</span> +<span id="174"> 174</span> +<span id="175"> 175</span> +<span id="176"> 176</span> +<span id="177"> 177</span> +<span id="178"> 178</span> +<span id="179"> 179</span> +<span id="180"> 180</span> +<span id="181"> 181</span> +<span id="182"> 182</span> +<span id="183"> 183</span> +<span id="184"> 184</span> +<span id="185"> 185</span> +<span id="186"> 186</span> +<span id="187"> 187</span> +<span id="188"> 188</span> +<span id="189"> 189</span> +<span id="190"> 190</span> +<span id="191"> 191</span> +<span id="192"> 192</span> +<span id="193"> 193</span> +<span id="194"> 194</span> +<span id="195"> 195</span> +<span id="196"> 196</span> +<span id="197"> 197</span> +<span id="198"> 198</span> +<span id="199"> 199</span> +<span id="200"> 200</span> +<span id="201"> 201</span> +<span id="202"> 202</span> +<span id="203"> 203</span> +<span id="204"> 204</span> +<span id="205"> 205</span> +<span id="206"> 206</span> +<span id="207"> 207</span> +<span id="208"> 208</span> +<span id="209"> 209</span> +<span id="210"> 210</span> +<span id="211"> 211</span> +<span id="212"> 212</span> +<span id="213"> 213</span> +<span id="214"> 214</span> +<span id="215"> 215</span> +<span id="216"> 216</span> +<span id="217"> 217</span> +<span id="218"> 218</span> +<span id="219"> 219</span> +<span id="220"> 220</span> +<span id="221"> 221</span> +<span id="222"> 222</span> +<span id="223"> 223</span> +<span id="224"> 224</span> +<span id="225"> 225</span> +<span id="226"> 226</span> +<span id="227"> 227</span> +<span id="228"> 228</span> +<span id="229"> 229</span> +<span id="230"> 230</span> +<span id="231"> 231</span> +<span id="232"> 232</span> +<span id="233"> 233</span> +<span id="234"> 234</span> +<span id="235"> 235</span> +<span id="236"> 236</span> +<span id="237"> 237</span> +<span id="238"> 238</span> +<span id="239"> 239</span> +<span id="240"> 240</span> +<span id="241"> 241</span> +<span id="242"> 242</span> +<span id="243"> 243</span> +<span id="244"> 244</span> +<span id="245"> 245</span> +<span id="246"> 246</span> +<span id="247"> 247</span> +<span id="248"> 248</span> +<span id="249"> 249</span> +<span id="250"> 250</span> +<span id="251"> 251</span> +<span id="252"> 252</span> +<span id="253"> 253</span> +<span id="254"> 254</span> +<span id="255"> 255</span> +<span id="256"> 256</span> +<span id="257"> 257</span> +<span id="258"> 258</span> +<span id="259"> 259</span> +<span id="260"> 260</span> +<span id="261"> 261</span> +<span id="262"> 262</span> +<span id="263"> 263</span> +<span id="264"> 264</span> +<span id="265"> 265</span> +<span id="266"> 266</span> +<span id="267"> 267</span> +<span id="268"> 268</span> +<span id="269"> 269</span> +<span id="270"> 270</span> +<span id="271"> 271</span> +<span id="272"> 272</span> +<span id="273"> 273</span> +<span id="274"> 274</span> +<span id="275"> 275</span> +<span id="276"> 276</span> +<span id="277"> 277</span> +<span id="278"> 278</span> +<span id="279"> 279</span> +<span id="280"> 280</span> +<span id="281"> 281</span> +<span id="282"> 282</span> +<span id="283"> 283</span> +<span id="284"> 284</span> +<span id="285"> 285</span> +<span id="286"> 286</span> +<span id="287"> 287</span> +<span id="288"> 288</span> +<span id="289"> 289</span> +<span id="290"> 290</span> +<span id="291"> 291</span> +<span id="292"> 292</span> +<span id="293"> 293</span> +<span id="294"> 294</span> +<span id="295"> 295</span> +<span id="296"> 296</span> +<span id="297"> 297</span> +<span id="298"> 298</span> +<span id="299"> 299</span> +<span id="300"> 300</span> +<span id="301"> 301</span> +<span id="302"> 302</span> +<span id="303"> 303</span> +<span id="304"> 304</span> +<span id="305"> 305</span> +<span id="306"> 306</span> +<span id="307"> 307</span> +<span id="308"> 308</span> +<span id="309"> 309</span> +<span id="310"> 310</span> +<span id="311"> 311</span> +<span id="312"> 312</span> +<span id="313"> 313</span> +<span id="314"> 314</span> +<span id="315"> 315</span> +<span id="316"> 316</span> +<span id="317"> 317</span> +<span id="318"> 318</span> +<span id="319"> 319</span> +<span id="320"> 320</span> +<span id="321"> 321</span> +<span id="322"> 322</span> +<span id="323"> 323</span> +<span id="324"> 324</span> +<span id="325"> 325</span> +<span id="326"> 326</span> +<span id="327"> 327</span> +<span id="328"> 328</span> +<span id="329"> 329</span> +<span id="330"> 330</span> +<span id="331"> 331</span> +<span id="332"> 332</span> +<span id="333"> 333</span> +<span id="334"> 334</span> +<span id="335"> 335</span> +<span id="336"> 336</span> +<span id="337"> 337</span> +<span id="338"> 338</span> +<span id="339"> 339</span> +<span id="340"> 340</span> +<span id="341"> 341</span> +<span id="342"> 342</span> +<span id="343"> 343</span> +<span id="344"> 344</span> +<span id="345"> 345</span> +<span id="346"> 346</span> +<span id="347"> 347</span> +<span id="348"> 348</span> +<span id="349"> 349</span> +<span id="350"> 350</span> +<span id="351"> 351</span> +<span id="352"> 352</span> +<span id="353"> 353</span> +<span id="354"> 354</span> +<span id="355"> 355</span> +<span id="356"> 356</span> +<span id="357"> 357</span> +<span id="358"> 358</span> +<span id="359"> 359</span> +<span id="360"> 360</span> +<span id="361"> 361</span> +<span id="362"> 362</span> +<span id="363"> 363</span> +<span id="364"> 364</span> +<span id="365"> 365</span> +<span id="366"> 366</span> +<span id="367"> 367</span> +<span id="368"> 368</span> +<span id="369"> 369</span> +<span id="370"> 370</span> +<span id="371"> 371</span> +<span id="372"> 372</span> +<span id="373"> 373</span> +<span id="374"> 374</span> +<span id="375"> 375</span> +<span id="376"> 376</span> +<span id="377"> 377</span> +<span id="378"> 378</span> +<span id="379"> 379</span> +<span id="380"> 380</span> +<span id="381"> 381</span> +<span id="382"> 382</span> +<span id="383"> 383</span> +<span id="384"> 384</span> +<span id="385"> 385</span> +<span id="386"> 386</span> +<span id="387"> 387</span> +<span id="388"> 388</span> +<span id="389"> 389</span> +<span id="390"> 390</span> +<span id="391"> 391</span> +<span id="392"> 392</span> +<span id="393"> 393</span> +<span id="394"> 394</span> +<span id="395"> 395</span> +<span id="396"> 396</span> +<span id="397"> 397</span> +<span id="398"> 398</span> +<span id="399"> 399</span> +<span id="400"> 400</span> +<span id="401"> 401</span> +<span id="402"> 402</span> +<span id="403"> 403</span> +<span id="404"> 404</span> +<span id="405"> 405</span> +<span id="406"> 406</span> +<span id="407"> 407</span> +<span id="408"> 408</span> +<span id="409"> 409</span> +<span id="410"> 410</span> +<span id="411"> 411</span> +<span id="412"> 412</span> +<span id="413"> 413</span> +<span id="414"> 414</span> +<span id="415"> 415</span> +<span id="416"> 416</span> +<span id="417"> 417</span> +<span id="418"> 418</span> +<span id="419"> 419</span> +<span id="420"> 420</span> +<span id="421"> 421</span> +<span id="422"> 422</span> +<span id="423"> 423</span> +<span id="424"> 424</span> +<span id="425"> 425</span> +<span id="426"> 426</span> +<span id="427"> 427</span> +<span id="428"> 428</span> +<span id="429"> 429</span> +<span id="430"> 430</span> +<span id="431"> 431</span> +<span id="432"> 432</span> +<span id="433"> 433</span> +<span id="434"> 434</span> +<span id="435"> 435</span> +<span id="436"> 436</span> +<span id="437"> 437</span> +<span id="438"> 438</span> +<span id="439"> 439</span> +<span id="440"> 440</span> +<span id="441"> 441</span> +<span id="442"> 442</span> +<span id="443"> 443</span> +<span id="444"> 444</span> +<span id="445"> 445</span> +<span id="446"> 446</span> +<span id="447"> 447</span> +<span id="448"> 448</span> +<span id="449"> 449</span> +<span id="450"> 450</span> +<span id="451"> 451</span> +<span id="452"> 452</span> +<span id="453"> 453</span> +<span id="454"> 454</span> +<span id="455"> 455</span> +<span id="456"> 456</span> +<span id="457"> 457</span> +<span id="458"> 458</span> +<span id="459"> 459</span> +<span id="460"> 460</span> +<span id="461"> 461</span> +<span id="462"> 462</span> +<span id="463"> 463</span> +<span id="464"> 464</span> +<span id="465"> 465</span> +<span id="466"> 466</span> +<span id="467"> 467</span> +<span id="468"> 468</span> +<span id="469"> 469</span> +<span id="470"> 470</span> +<span id="471"> 471</span> +<span id="472"> 472</span> +<span id="473"> 473</span> +<span id="474"> 474</span> +<span id="475"> 475</span> +<span id="476"> 476</span> +<span id="477"> 477</span> +<span id="478"> 478</span> +<span id="479"> 479</span> +<span id="480"> 480</span> +<span id="481"> 481</span> +<span id="482"> 482</span> +<span id="483"> 483</span> +<span id="484"> 484</span> +<span id="485"> 485</span> +<span id="486"> 486</span> +<span id="487"> 487</span> +<span id="488"> 488</span> +<span id="489"> 489</span> +<span id="490"> 490</span> +<span id="491"> 491</span> +<span id="492"> 492</span> +<span id="493"> 493</span> +<span id="494"> 494</span> +<span id="495"> 495</span> +<span id="496"> 496</span> +<span id="497"> 497</span> +<span id="498"> 498</span> +<span id="499"> 499</span> +<span id="500"> 500</span> +<span id="501"> 501</span> +<span id="502"> 502</span> +<span id="503"> 503</span> +<span id="504"> 504</span> +<span id="505"> 505</span> +<span id="506"> 506</span> +<span id="507"> 507</span> +<span id="508"> 508</span> +<span id="509"> 509</span> +<span id="510"> 510</span> +<span id="511"> 511</span> +<span id="512"> 512</span> +<span id="513"> 513</span> +<span id="514"> 514</span> +<span id="515"> 515</span> +<span id="516"> 516</span> +<span id="517"> 517</span> +<span id="518"> 518</span> +<span id="519"> 519</span> +<span id="520"> 520</span> +<span id="521"> 521</span> +<span id="522"> 522</span> +<span id="523"> 523</span> +<span id="524"> 524</span> +<span id="525"> 525</span> +<span id="526"> 526</span> +<span id="527"> 527</span> +<span id="528"> 528</span> +<span id="529"> 529</span> +<span id="530"> 530</span> +<span id="531"> 531</span> +<span id="532"> 532</span> +<span id="533"> 533</span> +<span id="534"> 534</span> +<span id="535"> 535</span> +<span id="536"> 536</span> +<span id="537"> 537</span> +<span id="538"> 538</span> +<span id="539"> 539</span> +<span id="540"> 540</span> +<span id="541"> 541</span> +<span id="542"> 542</span> +<span id="543"> 543</span> +<span id="544"> 544</span> +<span id="545"> 545</span> +<span id="546"> 546</span> +<span id="547"> 547</span> +<span id="548"> 548</span> +<span id="549"> 549</span> +<span id="550"> 550</span> +<span id="551"> 551</span> +<span id="552"> 552</span> +<span id="553"> 553</span> +<span id="554"> 554</span> +<span id="555"> 555</span> +<span id="556"> 556</span> +<span id="557"> 557</span> +<span id="558"> 558</span> +<span id="559"> 559</span> +<span id="560"> 560</span> +<span id="561"> 561</span> +<span id="562"> 562</span> +<span id="563"> 563</span> +<span id="564"> 564</span> +<span id="565"> 565</span> +<span id="566"> 566</span> +<span id="567"> 567</span> +<span id="568"> 568</span> +<span id="569"> 569</span> +<span id="570"> 570</span> +<span id="571"> 571</span> +<span id="572"> 572</span> +<span id="573"> 573</span> +<span id="574"> 574</span> +<span id="575"> 575</span> +<span id="576"> 576</span> +<span id="577"> 577</span> +<span id="578"> 578</span> +<span id="579"> 579</span> +<span id="580"> 580</span> +<span id="581"> 581</span> +<span id="582"> 582</span> +<span id="583"> 583</span> +<span id="584"> 584</span> +<span id="585"> 585</span> +<span id="586"> 586</span> +<span id="587"> 587</span> +<span id="588"> 588</span> +<span id="589"> 589</span> +<span id="590"> 590</span> +<span id="591"> 591</span> +<span id="592"> 592</span> +<span id="593"> 593</span> +<span id="594"> 594</span> +<span id="595"> 595</span> +<span id="596"> 596</span> +<span id="597"> 597</span> +<span id="598"> 598</span> +<span id="599"> 599</span> +<span id="600"> 600</span> +<span id="601"> 601</span> +<span id="602"> 602</span> +<span id="603"> 603</span> +<span id="604"> 604</span> +<span id="605"> 605</span> +<span id="606"> 606</span> +<span id="607"> 607</span> +<span id="608"> 608</span> +<span id="609"> 609</span> +<span id="610"> 610</span> +<span id="611"> 611</span> +<span id="612"> 612</span> +<span id="613"> 613</span> +<span id="614"> 614</span> +<span id="615"> 615</span> +<span id="616"> 616</span> +<span id="617"> 617</span> +<span id="618"> 618</span> +<span id="619"> 619</span> +<span id="620"> 620</span> +<span id="621"> 621</span> +<span id="622"> 622</span> +<span id="623"> 623</span> +<span id="624"> 624</span> +<span id="625"> 625</span> +<span id="626"> 626</span> +<span id="627"> 627</span> +<span id="628"> 628</span> +<span id="629"> 629</span> +<span id="630"> 630</span> +<span id="631"> 631</span> +<span id="632"> 632</span> +<span id="633"> 633</span> +<span id="634"> 634</span> +<span id="635"> 635</span> +<span id="636"> 636</span> +<span id="637"> 637</span> +<span id="638"> 638</span> +<span id="639"> 639</span> +<span id="640"> 640</span> +<span id="641"> 641</span> +<span id="642"> 642</span> +<span id="643"> 643</span> +<span id="644"> 644</span> +<span id="645"> 645</span> +<span id="646"> 646</span> +<span id="647"> 647</span> +<span id="648"> 648</span> +<span id="649"> 649</span> +<span id="650"> 650</span> +<span id="651"> 651</span> +<span id="652"> 652</span> +<span id="653"> 653</span> +<span id="654"> 654</span> +<span id="655"> 655</span> +<span id="656"> 656</span> +<span id="657"> 657</span> +<span id="658"> 658</span> +<span id="659"> 659</span> +<span id="660"> 660</span> +<span id="661"> 661</span> +<span id="662"> 662</span> +<span id="663"> 663</span> +<span id="664"> 664</span> +<span id="665"> 665</span> +<span id="666"> 666</span> +<span id="667"> 667</span> +<span id="668"> 668</span> +<span id="669"> 669</span> +<span id="670"> 670</span> +<span id="671"> 671</span> +<span id="672"> 672</span> +<span id="673"> 673</span> +<span id="674"> 674</span> +<span id="675"> 675</span> +<span id="676"> 676</span> +<span id="677"> 677</span> +<span id="678"> 678</span> +<span id="679"> 679</span> +<span id="680"> 680</span> +<span id="681"> 681</span> +<span id="682"> 682</span> +<span id="683"> 683</span> +<span id="684"> 684</span> +<span id="685"> 685</span> +<span id="686"> 686</span> +<span id="687"> 687</span> +<span id="688"> 688</span> +<span id="689"> 689</span> +<span id="690"> 690</span> +<span id="691"> 691</span> +<span id="692"> 692</span> +<span id="693"> 693</span> +<span id="694"> 694</span> +<span id="695"> 695</span> +<span id="696"> 696</span> +<span id="697"> 697</span> +<span id="698"> 698</span> +<span id="699"> 699</span> +<span id="700"> 700</span> +<span id="701"> 701</span> +<span id="702"> 702</span> +<span id="703"> 703</span> +<span id="704"> 704</span> +<span id="705"> 705</span> +<span id="706"> 706</span> +<span id="707"> 707</span> +<span id="708"> 708</span> +<span id="709"> 709</span> +<span id="710"> 710</span> +<span id="711"> 711</span> +<span id="712"> 712</span> +<span id="713"> 713</span> +<span id="714"> 714</span> +<span id="715"> 715</span> +<span id="716"> 716</span> +<span id="717"> 717</span> +<span id="718"> 718</span> +<span id="719"> 719</span> +<span id="720"> 720</span> +<span id="721"> 721</span> +<span id="722"> 722</span> +<span id="723"> 723</span> +<span id="724"> 724</span> +<span id="725"> 725</span> +<span id="726"> 726</span> +<span id="727"> 727</span> +<span id="728"> 728</span> +<span id="729"> 729</span> +<span id="730"> 730</span> +<span id="731"> 731</span> +<span id="732"> 732</span> +<span id="733"> 733</span> +<span id="734"> 734</span> +<span id="735"> 735</span> +<span id="736"> 736</span> +<span id="737"> 737</span> +<span id="738"> 738</span> +<span id="739"> 739</span> +<span id="740"> 740</span> +<span id="741"> 741</span> +<span id="742"> 742</span> +<span id="743"> 743</span> +<span id="744"> 744</span> +<span id="745"> 745</span> +<span id="746"> 746</span> +<span id="747"> 747</span> +<span id="748"> 748</span> +<span id="749"> 749</span> +<span id="750"> 750</span> +<span id="751"> 751</span> +<span id="752"> 752</span> +<span id="753"> 753</span> +<span id="754"> 754</span> +<span id="755"> 755</span> +<span id="756"> 756</span> +<span id="757"> 757</span> +<span id="758"> 758</span> +<span id="759"> 759</span> +<span id="760"> 760</span> +<span id="761"> 761</span> +<span id="762"> 762</span> +<span id="763"> 763</span> +<span id="764"> 764</span> +<span id="765"> 765</span> +<span id="766"> 766</span> +<span id="767"> 767</span> +<span id="768"> 768</span> +<span id="769"> 769</span> +<span id="770"> 770</span> +<span id="771"> 771</span> +<span id="772"> 772</span> +<span id="773"> 773</span> +<span id="774"> 774</span> +<span id="775"> 775</span> +<span id="776"> 776</span> +<span id="777"> 777</span> +<span id="778"> 778</span> +<span id="779"> 779</span> +<span id="780"> 780</span> +<span id="781"> 781</span> +<span id="782"> 782</span> +<span id="783"> 783</span> +<span id="784"> 784</span> +<span id="785"> 785</span> +<span id="786"> 786</span> +<span id="787"> 787</span> +<span id="788"> 788</span> +<span id="789"> 789</span> +<span id="790"> 790</span> +<span id="791"> 791</span> +<span id="792"> 792</span> +<span id="793"> 793</span> +<span id="794"> 794</span> +<span id="795"> 795</span> +<span id="796"> 796</span> +<span id="797"> 797</span> +<span id="798"> 798</span> +<span id="799"> 799</span> +<span id="800"> 800</span> +<span id="801"> 801</span> +<span id="802"> 802</span> +<span id="803"> 803</span> +<span id="804"> 804</span> +<span id="805"> 805</span> +<span id="806"> 806</span> +<span id="807"> 807</span> +<span id="808"> 808</span> +<span id="809"> 809</span> +<span id="810"> 810</span> +<span id="811"> 811</span> +<span id="812"> 812</span> +<span id="813"> 813</span> +<span id="814"> 814</span> +<span id="815"> 815</span> +<span id="816"> 816</span> +<span id="817"> 817</span> +<span id="818"> 818</span> +<span id="819"> 819</span> +<span id="820"> 820</span> +<span id="821"> 821</span> +<span id="822"> 822</span> +<span id="823"> 823</span> +<span id="824"> 824</span> +<span id="825"> 825</span> +<span id="826"> 826</span> +<span id="827"> 827</span> +<span id="828"> 828</span> +<span id="829"> 829</span> +<span id="830"> 830</span> +<span id="831"> 831</span> +<span id="832"> 832</span> +<span id="833"> 833</span> +<span id="834"> 834</span> +<span id="835"> 835</span> +<span id="836"> 836</span> +<span id="837"> 837</span> +<span id="838"> 838</span> +<span id="839"> 839</span> +<span id="840"> 840</span> +<span id="841"> 841</span> +<span id="842"> 842</span> +<span id="843"> 843</span> +<span id="844"> 844</span> +<span id="845"> 845</span> +<span id="846"> 846</span> +<span id="847"> 847</span> +<span id="848"> 848</span> +<span id="849"> 849</span> +<span id="850"> 850</span> +<span id="851"> 851</span> +<span id="852"> 852</span> +<span id="853"> 853</span> +<span id="854"> 854</span> +<span id="855"> 855</span> +<span id="856"> 856</span> +<span id="857"> 857</span> +<span id="858"> 858</span> +<span id="859"> 859</span> +<span id="860"> 860</span> +<span id="861"> 861</span> +<span id="862"> 862</span> +<span id="863"> 863</span> +<span id="864"> 864</span> +<span id="865"> 865</span> +<span id="866"> 866</span> +<span id="867"> 867</span> +<span id="868"> 868</span> +<span id="869"> 869</span> +<span id="870"> 870</span> +<span id="871"> 871</span> +<span id="872"> 872</span> +<span id="873"> 873</span> +<span id="874"> 874</span> +<span id="875"> 875</span> +<span id="876"> 876</span> +<span id="877"> 877</span> +<span id="878"> 878</span> +<span id="879"> 879</span> +<span id="880"> 880</span> +<span id="881"> 881</span> +<span id="882"> 882</span> +<span id="883"> 883</span> +<span id="884"> 884</span> +<span id="885"> 885</span> +<span id="886"> 886</span> +<span id="887"> 887</span> +<span id="888"> 888</span> +<span id="889"> 889</span> +<span id="890"> 890</span> +<span id="891"> 891</span> +<span id="892"> 892</span> +<span id="893"> 893</span> +<span id="894"> 894</span> +<span id="895"> 895</span> +<span id="896"> 896</span> +<span id="897"> 897</span> +<span id="898"> 898</span> +<span id="899"> 899</span> +<span id="900"> 900</span> +<span id="901"> 901</span> +<span id="902"> 902</span> +<span id="903"> 903</span> +<span id="904"> 904</span> +<span id="905"> 905</span> +<span id="906"> 906</span> +<span id="907"> 907</span> +<span id="908"> 908</span> +<span id="909"> 909</span> +<span id="910"> 910</span> +<span id="911"> 911</span> +<span id="912"> 912</span> +<span id="913"> 913</span> +<span id="914"> 914</span> +<span id="915"> 915</span> +<span id="916"> 916</span> +<span id="917"> 917</span> +<span id="918"> 918</span> +<span id="919"> 919</span> +<span id="920"> 920</span> +<span id="921"> 921</span> +<span id="922"> 922</span> +<span id="923"> 923</span> +<span id="924"> 924</span> +<span id="925"> 925</span> +<span id="926"> 926</span> +<span id="927"> 927</span> +<span id="928"> 928</span> +<span id="929"> 929</span> +<span id="930"> 930</span> +<span id="931"> 931</span> +<span id="932"> 932</span> +<span id="933"> 933</span> +<span id="934"> 934</span> +<span id="935"> 935</span> +<span id="936"> 936</span> +<span id="937"> 937</span> +<span id="938"> 938</span> +<span id="939"> 939</span> +<span id="940"> 940</span> +<span id="941"> 941</span> +<span id="942"> 942</span> +<span id="943"> 943</span> +<span id="944"> 944</span> +<span id="945"> 945</span> +<span id="946"> 946</span> +<span id="947"> 947</span> +<span id="948"> 948</span> +<span id="949"> 949</span> +<span id="950"> 950</span> +<span id="951"> 951</span> +<span id="952"> 952</span> +<span id="953"> 953</span> +<span id="954"> 954</span> +<span id="955"> 955</span> +<span id="956"> 956</span> +<span id="957"> 957</span> +<span id="958"> 958</span> +<span id="959"> 959</span> +<span id="960"> 960</span> +<span id="961"> 961</span> +<span id="962"> 962</span> +<span id="963"> 963</span> +<span id="964"> 964</span> +<span id="965"> 965</span> +<span id="966"> 966</span> +<span id="967"> 967</span> +<span id="968"> 968</span> +<span id="969"> 969</span> +<span id="970"> 970</span> +<span id="971"> 971</span> +<span id="972"> 972</span> +<span id="973"> 973</span> +<span id="974"> 974</span> +<span id="975"> 975</span> +<span id="976"> 976</span> +<span id="977"> 977</span> +<span id="978"> 978</span> +<span id="979"> 979</span> +<span id="980"> 980</span> +<span id="981"> 981</span> +<span id="982"> 982</span> +<span id="983"> 983</span> +<span id="984"> 984</span> +<span id="985"> 985</span> +<span id="986"> 986</span> +<span id="987"> 987</span> +<span id="988"> 988</span> +<span id="989"> 989</span> +<span id="990"> 990</span> +<span id="991"> 991</span> +<span id="992"> 992</span> +<span id="993"> 993</span> +<span id="994"> 994</span> +<span id="995"> 995</span> +<span id="996"> 996</span> +<span id="997"> 997</span> +<span id="998"> 998</span> +<span id="999"> 999</span> +<span id="1000">1000</span> +<span id="1001">1001</span> +<span id="1002">1002</span> +<span id="1003">1003</span> +<span id="1004">1004</span> +<span id="1005">1005</span> +<span id="1006">1006</span> +<span id="1007">1007</span> +<span id="1008">1008</span> +<span id="1009">1009</span> +<span id="1010">1010</span> +<span id="1011">1011</span> +<span id="1012">1012</span> +<span id="1013">1013</span> +<span id="1014">1014</span> +<span id="1015">1015</span> +<span id="1016">1016</span> +<span id="1017">1017</span> +<span id="1018">1018</span> +<span id="1019">1019</span> +<span id="1020">1020</span> +<span id="1021">1021</span> +<span id="1022">1022</span> +<span id="1023">1023</span> +<span id="1024">1024</span> +<span id="1025">1025</span> +<span id="1026">1026</span> +<span id="1027">1027</span> +<span id="1028">1028</span> +<span id="1029">1029</span> +<span id="1030">1030</span> +<span id="1031">1031</span> +<span id="1032">1032</span> +<span id="1033">1033</span> +<span id="1034">1034</span> +<span id="1035">1035</span> +<span id="1036">1036</span> +<span id="1037">1037</span> +<span id="1038">1038</span> +<span id="1039">1039</span> +<span id="1040">1040</span> +<span id="1041">1041</span> +<span id="1042">1042</span> +<span id="1043">1043</span> +<span id="1044">1044</span> +<span id="1045">1045</span> +<span id="1046">1046</span> +<span id="1047">1047</span> +<span id="1048">1048</span> +<span id="1049">1049</span> +<span id="1050">1050</span> +<span id="1051">1051</span> +<span id="1052">1052</span> +<span id="1053">1053</span> +<span id="1054">1054</span> +<span id="1055">1055</span> +<span id="1056">1056</span> +<span id="1057">1057</span> +<span id="1058">1058</span> +<span id="1059">1059</span> +<span id="1060">1060</span> +<span id="1061">1061</span> +<span id="1062">1062</span> +<span id="1063">1063</span> +<span id="1064">1064</span> +<span id="1065">1065</span> +<span id="1066">1066</span> +<span id="1067">1067</span> +<span id="1068">1068</span> +<span id="1069">1069</span> +<span id="1070">1070</span> +<span id="1071">1071</span> +<span id="1072">1072</span> +<span id="1073">1073</span> +<span id="1074">1074</span> +<span id="1075">1075</span> +<span id="1076">1076</span> +<span id="1077">1077</span> +<span id="1078">1078</span> +<span id="1079">1079</span> +<span id="1080">1080</span> +<span id="1081">1081</span> +<span id="1082">1082</span> +<span id="1083">1083</span> +<span id="1084">1084</span> +<span id="1085">1085</span> +<span id="1086">1086</span> +<span id="1087">1087</span> +<span id="1088">1088</span> +<span id="1089">1089</span> +<span id="1090">1090</span> +<span id="1091">1091</span> +<span id="1092">1092</span> +<span id="1093">1093</span> +<span id="1094">1094</span> +<span id="1095">1095</span> +<span id="1096">1096</span> +<span id="1097">1097</span> +<span id="1098">1098</span> +<span id="1099">1099</span> +<span id="1100">1100</span> +<span id="1101">1101</span> +<span id="1102">1102</span> +<span id="1103">1103</span> +<span id="1104">1104</span> +<span id="1105">1105</span> +<span id="1106">1106</span> +<span id="1107">1107</span> +<span id="1108">1108</span> +<span id="1109">1109</span> +<span id="1110">1110</span> +<span id="1111">1111</span> +<span id="1112">1112</span> +<span id="1113">1113</span> +<span id="1114">1114</span> +<span id="1115">1115</span> +<span id="1116">1116</span> +<span id="1117">1117</span> +<span id="1118">1118</span> +<span id="1119">1119</span> +<span id="1120">1120</span> +<span id="1121">1121</span> +<span id="1122">1122</span> +<span id="1123">1123</span> +<span id="1124">1124</span> +<span id="1125">1125</span> +<span id="1126">1126</span> +<span id="1127">1127</span> +<span id="1128">1128</span> +<span id="1129">1129</span> +<span id="1130">1130</span> +<span id="1131">1131</span> +<span id="1132">1132</span> +<span id="1133">1133</span> +<span id="1134">1134</span> +<span id="1135">1135</span> +<span id="1136">1136</span> +<span id="1137">1137</span> +<span id="1138">1138</span> +<span id="1139">1139</span> +<span id="1140">1140</span> +<span id="1141">1141</span> +<span id="1142">1142</span> +<span id="1143">1143</span> +<span id="1144">1144</span> +<span id="1145">1145</span> +<span id="1146">1146</span> +<span id="1147">1147</span> +<span id="1148">1148</span> +<span id="1149">1149</span> +<span id="1150">1150</span> +<span id="1151">1151</span> +<span id="1152">1152</span> +<span id="1153">1153</span> +<span id="1154">1154</span> +<span id="1155">1155</span> +<span id="1156">1156</span> +<span id="1157">1157</span> +<span id="1158">1158</span> +<span id="1159">1159</span> +<span id="1160">1160</span> +<span id="1161">1161</span> +<span id="1162">1162</span> +<span id="1163">1163</span> +<span id="1164">1164</span> +<span id="1165">1165</span> +<span id="1166">1166</span> +<span id="1167">1167</span> +<span id="1168">1168</span> +<span id="1169">1169</span> +<span id="1170">1170</span> +<span id="1171">1171</span> +<span id="1172">1172</span> +<span id="1173">1173</span> +<span id="1174">1174</span> +<span id="1175">1175</span> +<span id="1176">1176</span> +<span id="1177">1177</span> +<span id="1178">1178</span> +<span id="1179">1179</span> +<span id="1180">1180</span> +<span id="1181">1181</span> +<span id="1182">1182</span> +<span id="1183">1183</span> +<span id="1184">1184</span> +</pre><pre class='rust '> +<span class='comment'>// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT</span> +<span class='comment'>// file at the top-level directory of this distribution and at</span> +<span class='comment'>// http://rust-lang.org/COPYRIGHT.</span> +<span class='comment'>//</span> +<span class='comment'>// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or</span> +<span class='comment'>// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license</span> +<span class='comment'>// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your</span> +<span class='comment'>// option. This file may not be copied, modified, or distributed</span> +<span class='comment'>// except according to those terms.</span> + +<span class='doccomment'>/*! +This crate provides a regular expression parser and an abstract syntax for +regular expressions. The abstract syntax is defined by the `Expr` type. The +concrete syntax is enumerated in the +[`regex`](../regex/index.html#syntax) +crate documentation. + +Note that since this crate is first and foremost an implementation detail for +the `regex` crate, it may experience more frequent breaking changes. It is +exposed as a separate crate so that others may use it to do analysis on regular +expressions or even build their own matching engine. + +# Example: parsing an expression + +Parsing a regular expression can be done with the `Expr::parse` function. + +```rust +use regex_syntax::Expr; + +assert_eq!(Expr::parse(r"ab|yz").unwrap(), Expr::Alternate(vec![ + Expr::Literal { chars: vec!['a', 'b'], casei: false }, + Expr::Literal { chars: vec!['y', 'z'], casei: false }, +])); +``` + +# Example: inspecting an error + +The parser in this crate provides very detailed error values. For example, +if an invalid character class range is given: + +```rust +use regex_syntax::{Expr, ErrorKind}; + +let err = Expr::parse(r"[z-a]").unwrap_err(); +assert_eq!(err.position(), 4); +assert_eq!(err.kind(), &ErrorKind::InvalidClassRange { + start: 'z', + end: 'a', +}); +``` + +Or unbalanced parentheses: + +```rust +use regex_syntax::{Expr, ErrorKind}; + +let err = Expr::parse(r"ab(cd").unwrap_err(); +assert_eq!(err.position(), 2); +assert_eq!(err.kind(), &ErrorKind::UnclosedParen); +``` +*/</span> + +<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>deny</span>(<span class='ident'>missing_docs</span>)]</span> + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> <span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>quickcheck</span>; +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> <span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>rand</span>; + +<span class='kw'>mod</span> <span class='ident'>parser</span>; +<span class='kw'>mod</span> <span class='ident'>unicode</span>; + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>char</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>cmp</span>::{<span class='ident'>Ordering</span>, <span class='ident'>max</span>, <span class='ident'>min</span>}; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>fmt</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>iter</span>::<span class='ident'>IntoIterator</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ops</span>::<span class='ident'>Deref</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>slice</span>; +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>vec</span>; + +<span class='kw'>use</span> <span class='ident'>unicode</span>::<span class='ident'>case_folding</span>; + +<span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>Expr</span>::<span class='op'>*</span>; +<span class='kw'>use</span> <span class='self'>self</span>::<span class='ident'>Repeater</span>::<span class='op'>*</span>; + +<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>parser</span>::<span class='ident'>is_punct</span>; + +<span class='doccomment'>/// A regular expression abstract syntax tree.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// An `Expr` represents the abstract syntax of a regular expression.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Debug</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Expr</span> { + <span class='doccomment'>/// An empty regex (which never matches any text).</span> + <span class='ident'>Empty</span>, + <span class='doccomment'>/// A sequence of one or more literal characters to be matched.</span> + <span class='ident'>Literal</span> { + <span class='doccomment'>/// The characters.</span> + <span class='ident'>chars</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>char</span><span class='op'>></span>, + <span class='doccomment'>/// Whether to match case insensitively.</span> + <span class='ident'>casei</span>: <span class='ident'>bool</span>, + }, + <span class='doccomment'>/// Match any character, excluding new line.</span> + <span class='ident'>AnyChar</span>, + <span class='doccomment'>/// Match any character.</span> + <span class='ident'>AnyCharNoNL</span>, + <span class='doccomment'>/// A character class.</span> + <span class='ident'>Class</span>(<span class='ident'>CharClass</span>), + <span class='doccomment'>/// Match the start of a line or beginning of input.</span> + <span class='ident'>StartLine</span>, + <span class='doccomment'>/// Match the end of a line or end of input.</span> + <span class='ident'>EndLine</span>, + <span class='doccomment'>/// Match the beginning of input.</span> + <span class='ident'>StartText</span>, + <span class='doccomment'>/// Match the end of input.</span> + <span class='ident'>EndText</span>, + <span class='doccomment'>/// Match a word boundary (word character on one side and a non-word</span> + <span class='doccomment'>/// character on the other).</span> + <span class='ident'>WordBoundary</span>, + <span class='doccomment'>/// Match a position that is not a word boundary (word or non-word</span> + <span class='doccomment'>/// characters on both sides).</span> + <span class='ident'>NotWordBoundary</span>, + <span class='doccomment'>/// A group, possibly non-capturing.</span> + <span class='ident'>Group</span> { + <span class='doccomment'>/// The expression inside the group.</span> + <span class='ident'>e</span>: <span class='ident'>Box</span><span class='op'><</span><span class='ident'>Expr</span><span class='op'>></span>, + <span class='doccomment'>/// The capture index (starting at `1`) only for capturing groups.</span> + <span class='ident'>i</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span>, + <span class='doccomment'>/// The capture name, only for capturing named groups.</span> + <span class='ident'>name</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span>, + }, + <span class='doccomment'>/// A repeat operator (`?`, `*`, `+` or `{m,n}`).</span> + <span class='ident'>Repeat</span> { + <span class='doccomment'>/// The expression to be repeated. Limited to literals, `.`, classes</span> + <span class='doccomment'>/// or grouped expressions.</span> + <span class='ident'>e</span>: <span class='ident'>Box</span><span class='op'><</span><span class='ident'>Expr</span><span class='op'>></span>, + <span class='doccomment'>/// The type of repeat operator used.</span> + <span class='ident'>r</span>: <span class='ident'>Repeater</span>, + <span class='doccomment'>/// Whether the repeat is greedy (match the most) or not (match the</span> + <span class='doccomment'>/// least).</span> + <span class='ident'>greedy</span>: <span class='ident'>bool</span>, + }, + <span class='doccomment'>/// A concatenation of expressions. Must be matched one after the other.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// N.B. A concat expression can only appear at the top-level or</span> + <span class='doccomment'>/// immediately inside a group expression.</span> + <span class='ident'>Concat</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Expr</span><span class='op'>></span>), + <span class='doccomment'>/// An alternation of expressions. Only one must match.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// N.B. An alternate expression can only appear at the top-level or</span> + <span class='doccomment'>/// immediately inside a group expression.</span> + <span class='ident'>Alternate</span>(<span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Expr</span><span class='op'>></span>), +} + +<span class='kw'>type</span> <span class='ident'>CaptureIndex</span> <span class='op'>=</span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>usize</span><span class='op'>></span>; + +<span class='kw'>type</span> <span class='ident'>CaptureName</span> <span class='op'>=</span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span>; + +<span class='doccomment'>/// The type of a repeat operator expression.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Copy</span>, <span class='ident'>Debug</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Repeater</span> { + <span class='doccomment'>/// Match zero or one (`?`).</span> + <span class='ident'>ZeroOrOne</span>, + <span class='doccomment'>/// Match zero or more (`*`).</span> + <span class='ident'>ZeroOrMore</span>, + <span class='doccomment'>/// Match one or more (`+`).</span> + <span class='ident'>OneOrMore</span>, + <span class='doccomment'>/// Match for at least `min` and at most `max` (`{m,n}`).</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// When `max` is `None`, there is no upper bound on the number of matches.</span> + <span class='ident'>Range</span> { + <span class='doccomment'>/// Lower bound on the number of matches.</span> + <span class='ident'>min</span>: <span class='ident'>u32</span>, + <span class='doccomment'>/// Optional upper bound on the number of matches.</span> + <span class='ident'>max</span>: <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>u32</span><span class='op'>></span>, + }, +} + +<span class='doccomment'>/// A character class.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// A character class has a canonical format that the parser guarantees. Its</span> +<span class='doccomment'>/// canonical format is defined by the following invariants:</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// 1. Given any Unicode scalar value, it is matched by *at most* one character</span> +<span class='doccomment'>/// range in a canonical character class.</span> +<span class='doccomment'>/// 2. Every adjacent character range is separated by at least one Unicode</span> +<span class='doccomment'>/// scalar value.</span> +<span class='doccomment'>/// 3. Given any pair of character ranges `r1` and `r2`, if</span> +<span class='doccomment'>/// `r1.end < r2.start`, then `r1` comes before `r2` in a canonical</span> +<span class='doccomment'>/// character class.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// In sum, any `CharClass` produced by this crate's parser is a sorted</span> +<span class='doccomment'>/// sequence of non-overlapping ranges. This makes it possible to test whether</span> +<span class='doccomment'>/// a character is matched by a class with a binary search.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Additionally, a character class may be marked *case insensitive*. If it's</span> +<span class='doccomment'>/// case insensitive, then:</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// 1. Simple case folding has been applied to all ranges.</span> +<span class='doccomment'>/// 2. Simple case folding must be applied to a character before testing</span> +<span class='doccomment'>/// whether it matches the character class.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Debug</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>CharClass</span> { + <span class='ident'>ranges</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>ClassRange</span><span class='op'>></span>, + <span class='ident'>casei</span>: <span class='ident'>bool</span>, +} + +<span class='doccomment'>/// A single inclusive range in a character class.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Since range boundaries are defined by Unicode scalar values, the boundaries</span> +<span class='doccomment'>/// can never be in the open interval `(0xD7FF, 0xE000)`. However, a range may</span> +<span class='doccomment'>/// *cover* codepoints that are not scalar values.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Note that this has a few convenient impls on `PartialEq` and `PartialOrd`</span> +<span class='doccomment'>/// for testing whether a character is contained inside a given range.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Copy</span>, <span class='ident'>Debug</span>, <span class='ident'>PartialEq</span>, <span class='ident'>PartialOrd</span>, <span class='ident'>Eq</span>, <span class='ident'>Ord</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>ClassRange</span> { + <span class='doccomment'>/// The start character of the range.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This must be less than or equal to `end`.</span> + <span class='kw'>pub</span> <span class='ident'>start</span>: <span class='ident'>char</span>, + + <span class='doccomment'>/// The end character of the range.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This must be greater than or equal to `end`.</span> + <span class='kw'>pub</span> <span class='ident'>end</span>: <span class='ident'>char</span>, +} + +<span class='kw'>impl</span> <span class='ident'>Expr</span> { + <span class='doccomment'>/// Parses a string in a regular expression syntax tree.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>parse</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Expr</span><span class='op'>></span> { + <span class='ident'>parser</span>::<span class='ident'>Parser</span>::<span class='ident'>parse</span>(<span class='ident'>s</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>e</span>.<span class='ident'>simplify</span>()) + } + + <span class='doccomment'>/// Returns true iff the expression can be repeated by a quantifier.</span> + <span class='kw'>fn</span> <span class='ident'>can_repeat</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>Literal</span>{..} + <span class='op'>|</span> <span class='ident'>AnyChar</span> + <span class='op'>|</span> <span class='ident'>AnyCharNoNL</span> + <span class='op'>|</span> <span class='ident'>Class</span>(_) + <span class='op'>|</span> <span class='ident'>StartLine</span> <span class='op'>|</span> <span class='ident'>EndLine</span> <span class='op'>|</span> <span class='ident'>StartText</span> <span class='op'>|</span> <span class='ident'>EndText</span> + <span class='op'>|</span> <span class='ident'>WordBoundary</span> <span class='op'>|</span> <span class='ident'>NotWordBoundary</span> + <span class='op'>|</span> <span class='ident'>Group</span>{..} + <span class='op'>=></span> <span class='boolval'>true</span>, + _ <span class='op'>=></span> <span class='boolval'>false</span>, + } + } + + <span class='kw'>fn</span> <span class='ident'>simplify</span>(<span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Expr</span> { + <span class='kw'>fn</span> <span class='ident'>combine_literals</span>(<span class='ident'>es</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Expr</span><span class='op'>></span>, <span class='ident'>e</span>: <span class='ident'>Expr</span>) { + <span class='kw'>match</span> (<span class='ident'>es</span>.<span class='ident'>pop</span>(), <span class='ident'>e</span>) { + (<span class='prelude-val'>None</span>, <span class='ident'>e</span>) <span class='op'>=></span> <span class='ident'>es</span>.<span class='ident'>push</span>(<span class='ident'>e</span>), + (<span class='prelude-val'>Some</span>(<span class='ident'>Literal</span> { <span class='ident'>chars</span>: <span class='kw-2'>mut</span> <span class='ident'>chars1</span>, <span class='ident'>casei</span>: <span class='ident'>casei1</span> }), + <span class='ident'>Literal</span> { <span class='ident'>chars</span>: <span class='ident'>chars2</span>, <span class='ident'>casei</span>: <span class='ident'>casei2</span> }) <span class='op'>=></span> { + <span class='kw'>if</span> <span class='ident'>casei1</span> <span class='op'>==</span> <span class='ident'>casei2</span> { + <span class='ident'>chars1</span>.<span class='ident'>extend</span>(<span class='ident'>chars2</span>); + <span class='ident'>es</span>.<span class='ident'>push</span>(<span class='ident'>Literal</span> { <span class='ident'>chars</span>: <span class='ident'>chars1</span>, <span class='ident'>casei</span>: <span class='ident'>casei1</span> }); + } <span class='kw'>else</span> { + <span class='ident'>es</span>.<span class='ident'>push</span>(<span class='ident'>Literal</span> { <span class='ident'>chars</span>: <span class='ident'>chars1</span>, <span class='ident'>casei</span>: <span class='ident'>casei1</span> }); + <span class='ident'>es</span>.<span class='ident'>push</span>(<span class='ident'>Literal</span> { <span class='ident'>chars</span>: <span class='ident'>chars2</span>, <span class='ident'>casei</span>: <span class='ident'>casei2</span> }); + } + } + (<span class='prelude-val'>Some</span>(<span class='ident'>e1</span>), <span class='ident'>e2</span>) <span class='op'>=></span> { + <span class='ident'>es</span>.<span class='ident'>push</span>(<span class='ident'>e1</span>); + <span class='ident'>es</span>.<span class='ident'>push</span>(<span class='ident'>e2</span>); + } + } + } + <span class='kw'>match</span> <span class='self'>self</span> { + <span class='ident'>Repeat</span> { <span class='ident'>e</span>, <span class='ident'>r</span>, <span class='ident'>greedy</span> } <span class='op'>=></span> <span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>e</span>.<span class='ident'>simplify</span>()), + <span class='ident'>r</span>: <span class='ident'>r</span>, + <span class='ident'>greedy</span>: <span class='ident'>greedy</span>, + }, + <span class='ident'>Group</span> { <span class='ident'>e</span>, <span class='ident'>i</span>, <span class='ident'>name</span> } <span class='op'>=></span> { + <span class='kw'>let</span> <span class='ident'>e</span> <span class='op'>=</span> <span class='ident'>e</span>.<span class='ident'>simplify</span>(); + <span class='kw'>if</span> <span class='ident'>i</span>.<span class='ident'>is_none</span>() <span class='op'>&&</span> <span class='ident'>name</span>.<span class='ident'>is_none</span>() <span class='op'>&&</span> <span class='ident'>e</span>.<span class='ident'>can_repeat</span>() { + <span class='ident'>e</span> + } <span class='kw'>else</span> { + <span class='ident'>Group</span> { <span class='ident'>e</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>e</span>), <span class='ident'>i</span>: <span class='ident'>i</span>, <span class='ident'>name</span>: <span class='ident'>name</span> } + } + } + <span class='ident'>Concat</span>(<span class='ident'>es</span>) <span class='op'>=></span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>new_es</span> <span class='op'>=</span> <span class='ident'>Vec</span>::<span class='ident'>with_capacity</span>(<span class='ident'>es</span>.<span class='ident'>len</span>()); + <span class='kw'>for</span> <span class='ident'>e</span> <span class='kw'>in</span> <span class='ident'>es</span> { + <span class='ident'>combine_literals</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>new_es</span>, <span class='ident'>e</span>.<span class='ident'>simplify</span>()); + } + <span class='kw'>if</span> <span class='ident'>new_es</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>1</span> { + <span class='ident'>new_es</span>.<span class='ident'>pop</span>().<span class='ident'>unwrap</span>() + } <span class='kw'>else</span> { + <span class='ident'>Concat</span>(<span class='ident'>new_es</span>) + } + } + <span class='ident'>Alternate</span>(<span class='ident'>es</span>) <span class='op'>=></span> <span class='ident'>Alternate</span>(<span class='ident'>es</span>.<span class='ident'>into_iter</span>() + .<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>e</span><span class='op'>|</span> <span class='ident'>e</span>.<span class='ident'>simplify</span>()) + .<span class='ident'>collect</span>()), + <span class='ident'>e</span> <span class='op'>=></span> <span class='ident'>e</span>, + } + } +} + +<span class='kw'>impl</span> <span class='ident'>Deref</span> <span class='kw'>for</span> <span class='ident'>CharClass</span> { + <span class='kw'>type</span> <span class='ident'>Target</span> <span class='op'>=</span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>ClassRange</span><span class='op'>></span>; + <span class='kw'>fn</span> <span class='ident'>deref</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>Vec</span><span class='op'><</span><span class='ident'>ClassRange</span><span class='op'>></span> { <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>ranges</span> } +} + +<span class='kw'>impl</span> <span class='ident'>IntoIterator</span> <span class='kw'>for</span> <span class='ident'>CharClass</span> { + <span class='kw'>type</span> <span class='ident'>Item</span> <span class='op'>=</span> <span class='ident'>ClassRange</span>; + <span class='kw'>type</span> <span class='ident'>IntoIter</span> <span class='op'>=</span> <span class='ident'>vec</span>::<span class='ident'>IntoIter</span><span class='op'><</span><span class='ident'>ClassRange</span><span class='op'>></span>; + <span class='kw'>fn</span> <span class='ident'>into_iter</span>(<span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>vec</span>::<span class='ident'>IntoIter</span><span class='op'><</span><span class='ident'>ClassRange</span><span class='op'>></span> { <span class='self'>self</span>.<span class='ident'>ranges</span>.<span class='ident'>into_iter</span>() } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>IntoIterator</span> <span class='kw'>for</span> <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>CharClass</span> { + <span class='kw'>type</span> <span class='ident'>Item</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>ClassRange</span>; + <span class='kw'>type</span> <span class='ident'>IntoIter</span> <span class='op'>=</span> <span class='ident'>slice</span>::<span class='ident'>Iter</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>ClassRange</span><span class='op'>></span>; + <span class='kw'>fn</span> <span class='ident'>into_iter</span>(<span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>slice</span>::<span class='ident'>Iter</span><span class='op'><</span><span class='lifetime'>'a</span>, <span class='ident'>ClassRange</span><span class='op'>></span> { <span class='self'>self</span>.<span class='ident'>iter</span>() } +} + +<span class='kw'>impl</span> <span class='ident'>CharClass</span> { + <span class='doccomment'>/// Create a new class from an existing set of ranges.</span> + <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>ranges</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>ClassRange</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>CharClass</span> { + <span class='ident'>CharClass</span> { <span class='ident'>ranges</span>: <span class='ident'>ranges</span>, <span class='ident'>casei</span>: <span class='boolval'>false</span> } + } + + <span class='doccomment'>/// Create an empty class.</span> + <span class='kw'>fn</span> <span class='ident'>empty</span>() <span class='op'>-></span> <span class='ident'>CharClass</span> { + <span class='ident'>CharClass</span>::<span class='ident'>new</span>(<span class='ident'>Vec</span>::<span class='ident'>new</span>()) + } + + <span class='doccomment'>/// Returns true if `c` is matched by this character class.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If this character class is case insensitive, then simple case folding</span> + <span class='doccomment'>/// is applied to `c` before checking for a match.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>matches</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='kw-2'>mut</span> <span class='ident'>c</span>: <span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>is_case_insensitive</span>() { + <span class='ident'>c</span> <span class='op'>=</span> <span class='ident'>simple_case_fold</span>(<span class='ident'>c</span>) + } + <span class='self'>self</span>.<span class='ident'>binary_search_by</span>(<span class='op'>|</span><span class='ident'>range</span><span class='op'>|</span> <span class='ident'>c</span>.<span class='ident'>partial_cmp</span>(<span class='ident'>range</span>).<span class='ident'>unwrap</span>()).<span class='ident'>is_ok</span>() + } + + <span class='doccomment'>/// Returns true if this character class should be matched case</span> + <span class='doccomment'>/// insensitively.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// When `true`, simple case folding has already been applied to the</span> + <span class='doccomment'>/// class.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_case_insensitive</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='self'>self</span>.<span class='ident'>casei</span> + } + + <span class='doccomment'>/// Create a new empty class from this one.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Namely, its capacity and case insensitive setting will be the same.</span> + <span class='kw'>fn</span> <span class='ident'>to_empty</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>CharClass</span> { + <span class='ident'>CharClass</span> { <span class='ident'>ranges</span>: <span class='ident'>Vec</span>::<span class='ident'>with_capacity</span>(<span class='self'>self</span>.<span class='ident'>len</span>()), <span class='ident'>casei</span>: <span class='self'>self</span>.<span class='ident'>casei</span> } + } + + <span class='doccomment'>/// Merge two classes and canonicalize them.</span> + <span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> + <span class='kw'>fn</span> <span class='ident'>merge</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>other</span>: <span class='ident'>CharClass</span>) <span class='op'>-></span> <span class='ident'>CharClass</span> { + <span class='self'>self</span>.<span class='ident'>ranges</span>.<span class='ident'>extend</span>(<span class='ident'>other</span>); + <span class='self'>self</span>.<span class='ident'>canonicalize</span>() + } + + <span class='doccomment'>/// Canonicalze any sequence of ranges.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This is responsible for enforcing the canonical format invariants</span> + <span class='doccomment'>/// as described on the docs for the `CharClass` type.</span> + <span class='kw'>fn</span> <span class='ident'>canonicalize</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>CharClass</span> { + <span class='comment'>// TODO: Save some cycles here by checking if already canonicalized.</span> + <span class='self'>self</span>.<span class='ident'>ranges</span>.<span class='ident'>sort</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>ordered</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>to_empty</span>(); <span class='comment'>// TODO: Do this in place?</span> + <span class='kw'>for</span> <span class='ident'>candidate</span> <span class='kw'>in</span> <span class='self'>self</span> { + <span class='comment'>// If the candidate overlaps with an existing range, then it must</span> + <span class='comment'>// be the most recent range added because we process the candidates</span> + <span class='comment'>// in order.</span> + <span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>or</span>) <span class='op'>=</span> <span class='ident'>ordered</span>.<span class='ident'>ranges</span>.<span class='ident'>last_mut</span>() { + <span class='kw'>if</span> <span class='ident'>or</span>.<span class='ident'>overlapping</span>(<span class='ident'>candidate</span>) { + <span class='op'>*</span><span class='ident'>or</span> <span class='op'>=</span> <span class='ident'>or</span>.<span class='ident'>merge</span>(<span class='ident'>candidate</span>); + <span class='kw'>continue</span>; + } + } + <span class='ident'>ordered</span>.<span class='ident'>ranges</span>.<span class='ident'>push</span>(<span class='ident'>candidate</span>); + } + <span class='ident'>ordered</span> + } + + <span class='doccomment'>/// Negates the character class.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// For all `c` where `c` is a Unicode scalar value, `c` matches `self`</span> + <span class='doccomment'>/// if and only if `c` does not match `self.negate()`.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Note that this cannot be called on a character class that has had</span> + <span class='doccomment'>/// case folding applied to it. (Because case folding turns on a flag</span> + <span class='doccomment'>/// and doesn't store every possible matching character. Therefore,</span> + <span class='doccomment'>/// its negation is tricky to get right. Turns out, we don't need it</span> + <span class='doccomment'>/// anyway!)</span> + <span class='kw'>fn</span> <span class='ident'>negate</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>CharClass</span> { + <span class='kw'>fn</span> <span class='ident'>range</span>(<span class='ident'>s</span>: <span class='ident'>char</span>, <span class='ident'>e</span>: <span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>ClassRange</span> { <span class='ident'>ClassRange</span>::<span class='ident'>new</span>(<span class='ident'>s</span>, <span class='ident'>e</span>) } + + <span class='comment'>// Never allow negating of a class that has been case folded!</span> + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='self'>self</span>.<span class='ident'>casei</span>); + + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>is_empty</span>() { <span class='kw'>return</span> <span class='self'>self</span>; } + <span class='self'>self</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>canonicalize</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>inv</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>to_empty</span>(); + <span class='kw'>if</span> <span class='self'>self</span>[<span class='number'>0</span>].<span class='ident'>start</span> <span class='op'>></span> <span class='string'>'\x00'</span> { + <span class='ident'>inv</span>.<span class='ident'>ranges</span>.<span class='ident'>push</span>(<span class='ident'>range</span>(<span class='string'>'\x00'</span>, <span class='ident'>dec_char</span>(<span class='self'>self</span>[<span class='number'>0</span>].<span class='ident'>start</span>))); + } + <span class='kw'>for</span> <span class='ident'>win</span> <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>windows</span>(<span class='number'>2</span>) { + <span class='ident'>inv</span>.<span class='ident'>ranges</span>.<span class='ident'>push</span>(<span class='ident'>range</span>(<span class='ident'>inc_char</span>(<span class='ident'>win</span>[<span class='number'>0</span>].<span class='ident'>end</span>), + <span class='ident'>dec_char</span>(<span class='ident'>win</span>[<span class='number'>1</span>].<span class='ident'>start</span>))); + } + <span class='kw'>if</span> <span class='self'>self</span>[<span class='self'>self</span>.<span class='ident'>len</span>() <span class='op'>-</span> <span class='number'>1</span>].<span class='ident'>end</span> <span class='op'><</span> <span class='ident'>char</span>::<span class='ident'>MAX</span> { + <span class='ident'>inv</span>.<span class='ident'>ranges</span>.<span class='ident'>push</span>(<span class='ident'>range</span>(<span class='ident'>inc_char</span>(<span class='self'>self</span>[<span class='self'>self</span>.<span class='ident'>len</span>() <span class='op'>-</span> <span class='number'>1</span>].<span class='ident'>end</span>), + <span class='ident'>char</span>::<span class='ident'>MAX</span>)); + } + <span class='ident'>inv</span> + } + + <span class='doccomment'>/// Apply case folding to this character class.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// One a class had been case folded, it cannot be negated.</span> + <span class='kw'>fn</span> <span class='ident'>case_fold</span>(<span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>CharClass</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>folded</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>to_empty</span>(); + <span class='ident'>folded</span>.<span class='ident'>casei</span> <span class='op'>=</span> <span class='boolval'>true</span>; + <span class='kw'>for</span> <span class='ident'>r</span> <span class='kw'>in</span> <span class='self'>self</span> { + <span class='comment'>// Applying case folding to a range is expensive because *every*</span> + <span class='comment'>// character needed to be examined. Thus, we avoid that drudgery</span> + <span class='comment'>// if no character in the current range is in our case folding</span> + <span class='comment'>// table.</span> + <span class='kw'>if</span> <span class='ident'>r</span>.<span class='ident'>needs_case_folding</span>() { + <span class='ident'>folded</span>.<span class='ident'>ranges</span>.<span class='ident'>extend</span>(<span class='ident'>r</span>.<span class='ident'>case_fold</span>()); + } <span class='kw'>else</span> { + <span class='ident'>folded</span>.<span class='ident'>ranges</span>.<span class='ident'>push</span>(<span class='ident'>r</span>); + } + } + <span class='ident'>folded</span>.<span class='ident'>canonicalize</span>() + } +} + +<span class='kw'>impl</span> <span class='ident'>ClassRange</span> { + <span class='doccomment'>/// Create a new class range.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// If `end < start`, then the two values are swapped so that</span> + <span class='doccomment'>/// the invariant `start <= end` is preserved.</span> + <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>start</span>: <span class='ident'>char</span>, <span class='ident'>end</span>: <span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>ClassRange</span> { + <span class='kw'>if</span> <span class='ident'>start</span> <span class='op'><=</span> <span class='ident'>end</span> { + <span class='ident'>ClassRange</span> { <span class='ident'>start</span>: <span class='ident'>start</span>, <span class='ident'>end</span>: <span class='ident'>end</span> } + } <span class='kw'>else</span> { + <span class='ident'>ClassRange</span> { <span class='ident'>start</span>: <span class='ident'>end</span>, <span class='ident'>end</span>: <span class='ident'>start</span> } + } + } + + <span class='doccomment'>/// Create a range of one character.</span> + <span class='kw'>fn</span> <span class='ident'>one</span>(<span class='ident'>c</span>: <span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>ClassRange</span> { + <span class='ident'>ClassRange</span> { <span class='ident'>start</span>: <span class='ident'>c</span>, <span class='ident'>end</span>: <span class='ident'>c</span> } + } + + <span class='doccomment'>/// Returns true if and only if the two ranges are overlapping. Note that</span> + <span class='doccomment'>/// since ranges are inclusive, `a-c` and `d-f` are overlapping!</span> + <span class='kw'>fn</span> <span class='ident'>overlapping</span>(<span class='self'>self</span>, <span class='ident'>other</span>: <span class='ident'>ClassRange</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='ident'>max</span>(<span class='self'>self</span>.<span class='ident'>start</span>, <span class='ident'>other</span>.<span class='ident'>start</span>) <span class='op'><=</span> <span class='ident'>inc_char</span>(<span class='ident'>min</span>(<span class='self'>self</span>.<span class='ident'>end</span>, <span class='ident'>other</span>.<span class='ident'>end</span>)) + } + + <span class='doccomment'>/// Creates a new range representing the union of `self` and `other.</span> + <span class='kw'>fn</span> <span class='ident'>merge</span>(<span class='self'>self</span>, <span class='ident'>other</span>: <span class='ident'>ClassRange</span>) <span class='op'>-></span> <span class='ident'>ClassRange</span> { + <span class='ident'>ClassRange</span> { + <span class='ident'>start</span>: <span class='ident'>min</span>(<span class='self'>self</span>.<span class='ident'>start</span>, <span class='ident'>other</span>.<span class='ident'>start</span>), + <span class='ident'>end</span>: <span class='ident'>max</span>(<span class='self'>self</span>.<span class='ident'>end</span>, <span class='ident'>other</span>.<span class='ident'>end</span>), + } + } + + <span class='doccomment'>/// Returns true if and only if this range contains a character that is</span> + <span class='doccomment'>/// in the case folding table.</span> + <span class='kw'>fn</span> <span class='ident'>needs_case_folding</span>(<span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='ident'>case_folding</span>::<span class='ident'>C_plus_S_table</span> + .<span class='ident'>binary_search_by</span>(<span class='op'>|</span><span class='kw-2'>&</span>(<span class='ident'>c</span>, _)<span class='op'>|</span> <span class='self'>self</span>.<span class='ident'>partial_cmp</span>(<span class='kw-2'>&</span><span class='ident'>c</span>).<span class='ident'>unwrap</span>()).<span class='ident'>is_ok</span>() + } + + <span class='doccomment'>/// Apply case folding to this range.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// Since case folding might add characters such that the range is no</span> + <span class='doccomment'>/// longer contiguous, this returns multiple class ranges. They are in</span> + <span class='doccomment'>/// canonical order.</span> + <span class='kw'>fn</span> <span class='ident'>case_fold</span>(<span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>ClassRange</span><span class='op'>></span> { + <span class='kw'>let</span> (<span class='ident'>s</span>, <span class='ident'>e</span>) <span class='op'>=</span> (<span class='self'>self</span>.<span class='ident'>start</span> <span class='kw'>as</span> <span class='ident'>u32</span>, <span class='self'>self</span>.<span class='ident'>end</span> <span class='kw'>as</span> <span class='ident'>u32</span> <span class='op'>+</span> <span class='number'>1</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>start</span> <span class='op'>=</span> <span class='ident'>simple_case_fold</span>(<span class='self'>self</span>.<span class='ident'>start</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>end</span> <span class='op'>=</span> <span class='ident'>start</span>; + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>next_case_fold</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>start</span>; + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>ranges</span> <span class='op'>=</span> <span class='ident'>Vec</span>::<span class='ident'>with_capacity</span>(<span class='number'>100</span>); + <span class='kw'>for</span> <span class='kw-2'>mut</span> <span class='ident'>c</span> <span class='kw'>in</span> (<span class='ident'>s</span><span class='op'>+</span><span class='number'>1</span>..<span class='ident'>e</span>).<span class='ident'>filter_map</span>(<span class='ident'>char</span>::<span class='ident'>from_u32</span>) { + <span class='kw'>if</span> <span class='ident'>c</span> <span class='op'>>=</span> <span class='ident'>next_case_fold</span> { + <span class='ident'>c</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>simple_case_fold_result</span>(<span class='ident'>c</span>) { + <span class='prelude-val'>Ok</span>(<span class='ident'>i</span>) <span class='op'>=></span> <span class='ident'>case_folding</span>::<span class='ident'>C_plus_S_table</span>[<span class='ident'>i</span>].<span class='number'>1</span>, + <span class='prelude-val'>Err</span>(<span class='ident'>i</span>) <span class='op'>=></span> { + <span class='kw'>if</span> <span class='ident'>i</span> <span class='op'><</span> <span class='ident'>case_folding</span>::<span class='ident'>C_plus_S_table</span>.<span class='ident'>len</span>() { + <span class='ident'>next_case_fold</span> <span class='op'>=</span> <span class='ident'>case_folding</span>::<span class='ident'>C_plus_S_table</span>[<span class='ident'>i</span>].<span class='number'>0</span>; + } <span class='kw'>else</span> { + <span class='ident'>next_case_fold</span> <span class='op'>=</span> <span class='string'>'\u{10FFFF}'</span> + } + <span class='ident'>c</span> + } + }; + } + <span class='kw'>if</span> <span class='ident'>c</span> <span class='op'>!=</span> <span class='ident'>inc_char</span>(<span class='ident'>end</span>) { + <span class='ident'>ranges</span>.<span class='ident'>push</span>(<span class='ident'>ClassRange</span>::<span class='ident'>new</span>(<span class='ident'>start</span>, <span class='ident'>end</span>)); + <span class='ident'>start</span> <span class='op'>=</span> <span class='ident'>c</span>; + } + <span class='ident'>end</span> <span class='op'>=</span> <span class='ident'>c</span>; + } + <span class='ident'>ranges</span>.<span class='ident'>push</span>(<span class='ident'>ClassRange</span>::<span class='ident'>new</span>(<span class='ident'>start</span>, <span class='ident'>end</span>)); + <span class='ident'>ranges</span> + } +} + +<span class='kw'>impl</span> <span class='ident'>PartialEq</span><span class='op'><</span><span class='ident'>char</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>ClassRange</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>eq</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='self'>self</span>.<span class='ident'>start</span> <span class='op'><=</span> <span class='op'>*</span><span class='ident'>other</span> <span class='op'>&&</span> <span class='op'>*</span><span class='ident'>other</span> <span class='op'><=</span> <span class='self'>self</span>.<span class='ident'>end</span> + } +} + +<span class='kw'>impl</span> <span class='ident'>PartialEq</span><span class='op'><</span><span class='ident'>ClassRange</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>char</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>eq</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>ClassRange</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='ident'>other</span>.<span class='ident'>eq</span>(<span class='self'>self</span>) + } +} + +<span class='kw'>impl</span> <span class='ident'>PartialOrd</span><span class='op'><</span><span class='ident'>char</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>ClassRange</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>partial_cmp</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>char</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Ordering</span><span class='op'>></span> { + <span class='prelude-val'>Some</span>(<span class='kw'>if</span> <span class='self'>self</span> <span class='op'>==</span> <span class='ident'>other</span> { + <span class='ident'>Ordering</span>::<span class='ident'>Equal</span> + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='op'>*</span><span class='ident'>other</span> <span class='op'>></span> <span class='self'>self</span>.<span class='ident'>end</span> { + <span class='ident'>Ordering</span>::<span class='ident'>Greater</span> + } <span class='kw'>else</span> { + <span class='ident'>Ordering</span>::<span class='ident'>Less</span> + }) + } +} + +<span class='kw'>impl</span> <span class='ident'>PartialOrd</span><span class='op'><</span><span class='ident'>ClassRange</span><span class='op'>></span> <span class='kw'>for</span> <span class='ident'>char</span> { + <span class='attribute'>#[<span class='ident'>inline</span>]</span> + <span class='kw'>fn</span> <span class='ident'>partial_cmp</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&</span><span class='ident'>ClassRange</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>Ordering</span><span class='op'>></span> { + <span class='ident'>other</span>.<span class='ident'>partial_cmp</span>(<span class='self'>self</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>o</span><span class='op'>|</span> <span class='ident'>o</span>.<span class='ident'>reverse</span>()) + } +} + +<span class='doccomment'>/// This implementation of `Display` will write a regular expression from the</span> +<span class='doccomment'>/// syntax tree. It does not write the original string parsed.</span> +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Display</span> <span class='kw'>for</span> <span class='ident'>Expr</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>Empty</span> <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>""</span>), + <span class='ident'>Literal</span> { <span class='kw-2'>ref</span> <span class='ident'>chars</span>, <span class='ident'>casei</span> } <span class='op'>=></span> { + <span class='kw'>if</span> <span class='ident'>casei</span> { <span class='macro'>try</span><span class='macro'>!</span>(<span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"(?i:"</span>)); } + <span class='kw'>for</span> <span class='kw-2'>&</span><span class='ident'>c</span> <span class='kw'>in</span> <span class='ident'>chars</span> { + <span class='macro'>try</span><span class='macro'>!</span>(<span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"{}"</span>, <span class='ident'>quote_char</span>(<span class='ident'>c</span>))); + } + <span class='kw'>if</span> <span class='ident'>casei</span> { <span class='macro'>try</span><span class='macro'>!</span>(<span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>")"</span>)); } + <span class='prelude-val'>Ok</span>(()) + } + <span class='ident'>AnyChar</span> <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"(?s:.)"</span>), + <span class='ident'>AnyCharNoNL</span> <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"."</span>), + <span class='ident'>Class</span>(<span class='kw-2'>ref</span> <span class='ident'>cls</span>) <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"{}"</span>, <span class='ident'>cls</span>), + <span class='ident'>StartLine</span> <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"(?m:^)"</span>), + <span class='ident'>EndLine</span> <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"(?m:$)"</span>), + <span class='ident'>StartText</span> <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>r"^"</span>), + <span class='ident'>EndText</span> <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>r"$"</span>), + <span class='ident'>WordBoundary</span> <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>r"\b"</span>), + <span class='ident'>NotWordBoundary</span> <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>r"\B"</span>), + <span class='ident'>Group</span> { <span class='kw-2'>ref</span> <span class='ident'>e</span>, <span class='ident'>i</span>: <span class='prelude-val'>None</span>, <span class='ident'>name</span>: <span class='prelude-val'>None</span> } <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"(?:{})"</span>, <span class='ident'>e</span>), + <span class='ident'>Group</span> { <span class='kw-2'>ref</span> <span class='ident'>e</span>, <span class='ident'>name</span>: <span class='prelude-val'>None</span>, .. } <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"({})"</span>, <span class='ident'>e</span>), + <span class='ident'>Group</span> { <span class='kw-2'>ref</span> <span class='ident'>e</span>, <span class='ident'>name</span>: <span class='prelude-val'>Some</span>(<span class='kw-2'>ref</span> <span class='ident'>n</span>), .. } <span class='op'>=></span> { + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"(?P<{}>{})"</span>, <span class='ident'>n</span>, <span class='ident'>e</span>) + } + <span class='ident'>Repeat</span> { <span class='kw-2'>ref</span> <span class='ident'>e</span>, <span class='ident'>r</span>, <span class='ident'>greedy</span> } <span class='op'>=></span> { + <span class='kw'>match</span> <span class='kw-2'>&</span><span class='op'>*</span><span class='op'>*</span><span class='ident'>e</span> { + <span class='kw-2'>&</span><span class='ident'>Literal</span> { <span class='kw-2'>ref</span> <span class='ident'>chars</span>, .. } <span class='kw'>if</span> <span class='ident'>chars</span>.<span class='ident'>len</span>() <span class='op'>></span> <span class='number'>1</span> <span class='op'>=></span> { + <span class='macro'>try</span><span class='macro'>!</span>(<span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"(?:{}){}"</span>, <span class='ident'>e</span>, <span class='ident'>r</span>)) + } + _ <span class='op'>=></span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"{}{}"</span>, <span class='ident'>e</span>, <span class='ident'>r</span>)), + } + <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>greedy</span> { <span class='macro'>try</span><span class='macro'>!</span>(<span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"?"</span>)); } + <span class='prelude-val'>Ok</span>(()) + } + <span class='ident'>Concat</span>(<span class='kw-2'>ref</span> <span class='ident'>es</span>) <span class='op'>=></span> { + <span class='kw'>for</span> <span class='ident'>e</span> <span class='kw'>in</span> <span class='ident'>es</span> { + <span class='macro'>try</span><span class='macro'>!</span>(<span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"{}"</span>, <span class='ident'>e</span>)); + } + <span class='prelude-val'>Ok</span>(()) + } + <span class='ident'>Alternate</span>(<span class='kw-2'>ref</span> <span class='ident'>es</span>) <span class='op'>=></span> { + <span class='kw'>for</span> (<span class='ident'>i</span>, <span class='ident'>e</span>) <span class='kw'>in</span> <span class='ident'>es</span>.<span class='ident'>iter</span>().<span class='ident'>enumerate</span>() { + <span class='kw'>if</span> <span class='ident'>i</span> <span class='op'>></span> <span class='number'>0</span> { <span class='macro'>try</span><span class='macro'>!</span>(<span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"|"</span>)); } + <span class='macro'>try</span><span class='macro'>!</span>(<span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"{}"</span>, <span class='ident'>e</span>)); + } + <span class='prelude-val'>Ok</span>(()) + } + } + } +} + +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Display</span> <span class='kw'>for</span> <span class='ident'>Repeater</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>ZeroOrOne</span> <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"?"</span>), + <span class='ident'>ZeroOrMore</span> <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"*"</span>), + <span class='ident'>OneOrMore</span> <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"+"</span>), + <span class='ident'>Range</span> { <span class='ident'>min</span>: <span class='ident'>s</span>, <span class='ident'>max</span>: <span class='prelude-val'>None</span> } <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"{{{},}}"</span>, <span class='ident'>s</span>), + <span class='ident'>Range</span> { <span class='ident'>min</span>: <span class='ident'>s</span>, <span class='ident'>max</span>: <span class='prelude-val'>Some</span>(<span class='ident'>e</span>) } <span class='kw'>if</span> <span class='ident'>s</span> <span class='op'>==</span> <span class='ident'>e</span> <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"{{{}}}"</span>, <span class='ident'>s</span>), + <span class='ident'>Range</span> { <span class='ident'>min</span>: <span class='ident'>s</span>, <span class='ident'>max</span>: <span class='prelude-val'>Some</span>(<span class='ident'>e</span>) } <span class='op'>=></span> <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"{{{}, {}}}"</span>, <span class='ident'>s</span>, <span class='ident'>e</span>), + } + } +} + +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Display</span> <span class='kw'>for</span> <span class='ident'>CharClass</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>casei</span> { + <span class='macro'>try</span><span class='macro'>!</span>(<span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"(?i:"</span>)); + } + <span class='macro'>try</span><span class='macro'>!</span>(<span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"["</span>)); + <span class='kw'>for</span> <span class='ident'>range</span> <span class='kw'>in</span> <span class='self'>self</span>.<span class='ident'>iter</span>() { + <span class='macro'>try</span><span class='macro'>!</span>(<span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"{}"</span>, <span class='ident'>range</span>)); + } + <span class='macro'>try</span><span class='macro'>!</span>(<span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"]"</span>)); + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>casei</span> { + <span class='macro'>try</span><span class='macro'>!</span>(<span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>")"</span>)); + } + <span class='prelude-val'>Ok</span>(()) + } +} + +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Display</span> <span class='kw'>for</span> <span class='ident'>ClassRange</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"{}-{}"</span>, <span class='ident'>quote_char</span>(<span class='self'>self</span>.<span class='ident'>start</span>), <span class='ident'>quote_char</span>(<span class='self'>self</span>.<span class='ident'>end</span>)) + } +} + +<span class='doccomment'>/// An alias for computations that can return a `Error`.</span> +<span class='kw'>pub</span> <span class='kw'>type</span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> <span class='op'>=</span> ::<span class='ident'>std</span>::<span class='ident'>result</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>T</span>, <span class='ident'>Error</span><span class='op'>></span>; + +<span class='doccomment'>/// A parse error.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This includes details about the specific type of error and a rough</span> +<span class='doccomment'>/// approximation of where it occurred.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Debug</span>, <span class='ident'>PartialEq</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Error</span> { + <span class='ident'>pos</span>: <span class='ident'>usize</span>, + <span class='ident'>surround</span>: <span class='ident'>String</span>, + <span class='ident'>kind</span>: <span class='ident'>ErrorKind</span>, +} + +<span class='doccomment'>/// The specific type of parse error that can occur.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Debug</span>, <span class='ident'>PartialEq</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>ErrorKind</span> { + <span class='doccomment'>/// A negation symbol is used twice in flag settings.</span> + <span class='doccomment'>/// e.g., `(?-i-s)`.</span> + <span class='ident'>DoubleFlagNegation</span>, + <span class='doccomment'>/// The same capture name was used more than once.</span> + <span class='doccomment'>/// e.g., `(?P<a>.)(?P<a>.)`.</span> + <span class='ident'>DuplicateCaptureName</span>(<span class='ident'>String</span>), + <span class='doccomment'>/// An alternate is empty. e.g., `(|a)`.</span> + <span class='ident'>EmptyAlternate</span>, + <span class='doccomment'>/// A capture group name is empty. e.g., `(?P<>a)`.</span> + <span class='ident'>EmptyCaptureName</span>, + <span class='doccomment'>/// A negation symbol was not proceded by any flags. e.g., `(?i-)`.</span> + <span class='ident'>EmptyFlagNegation</span>, + <span class='doccomment'>/// A group is empty. e.g., `()`.</span> + <span class='ident'>EmptyGroup</span>, + <span class='doccomment'>/// An invalid number was used in a counted repetition. e.g., `a{b}`.</span> + <span class='ident'>InvalidBase10</span>(<span class='ident'>String</span>), + <span class='doccomment'>/// An invalid hexadecimal number was used in an escape sequence.</span> + <span class='doccomment'>/// e.g., `\xAG`.</span> + <span class='ident'>InvalidBase16</span>(<span class='ident'>String</span>), + <span class='doccomment'>/// An invalid capture name was used. e.g., `(?P<0a>b)`.</span> + <span class='ident'>InvalidCaptureName</span>(<span class='ident'>String</span>), + <span class='doccomment'>/// An invalid class range was givien. Specifically, when the start of the</span> + <span class='doccomment'>/// range is greater than the end. e.g., `[z-a]`.</span> + <span class='ident'>InvalidClassRange</span> { + <span class='doccomment'>/// The first character specified in the range.</span> + <span class='ident'>start</span>: <span class='ident'>char</span>, + <span class='doccomment'>/// The second character specified in the range.</span> + <span class='ident'>end</span>: <span class='ident'>char</span>, + }, + <span class='doccomment'>/// An escape sequence was used in a character class where it is not</span> + <span class='doccomment'>/// allowed. e.g., `[a-\pN]` or `[\A]`.</span> + <span class='ident'>InvalidClassEscape</span>(<span class='ident'>Expr</span>), + <span class='doccomment'>/// An invalid counted repetition min/max was given. e.g., `a{2,1}`.</span> + <span class='ident'>InvalidRepeatRange</span> { + <span class='doccomment'>/// The first number specified in the repetition.</span> + <span class='ident'>min</span>: <span class='ident'>u32</span>, + <span class='doccomment'>/// The second number specified in the repetition.</span> + <span class='ident'>max</span>: <span class='ident'>u32</span>, + }, + <span class='doccomment'>/// An invalid Unicode scalar value was used in a long hexadecimal</span> + <span class='doccomment'>/// sequence. e.g., `\x{D800}`.</span> + <span class='ident'>InvalidScalarValue</span>(<span class='ident'>u32</span>), + <span class='doccomment'>/// An empty counted repetition operator. e.g., `a{}`.</span> + <span class='ident'>MissingBase10</span>, + <span class='doccomment'>/// A repetition operator was not applied to an expression. e.g., `*`.</span> + <span class='ident'>RepeaterExpectsExpr</span>, + <span class='doccomment'>/// A repetition operator was applied to an expression that cannot be</span> + <span class='doccomment'>/// repeated. e.g., `a+*` or `a|*`.</span> + <span class='ident'>RepeaterUnexpectedExpr</span>(<span class='ident'>Expr</span>), + <span class='doccomment'>/// A capture group name that is never closed. e.g., `(?P<a`.</span> + <span class='ident'>UnclosedCaptureName</span>(<span class='ident'>String</span>), + <span class='doccomment'>/// An unclosed hexadecimal literal. e.g., `\x{a`.</span> + <span class='ident'>UnclosedHex</span>, + <span class='doccomment'>/// An unclosed parenthesis. e.g., `(a`.</span> + <span class='ident'>UnclosedParen</span>, + <span class='doccomment'>/// An unclosed counted repetition operator. e.g., `a{2`.</span> + <span class='ident'>UnclosedRepeat</span>, + <span class='doccomment'>/// An unclosed named Unicode class. e.g., `\p{Yi`.</span> + <span class='ident'>UnclosedUnicodeName</span>, + <span class='doccomment'>/// Saw end of regex before class was closed. e.g., `[a`.</span> + <span class='ident'>UnexpectedClassEof</span>, + <span class='doccomment'>/// Saw end of regex before escape sequence was closed. e.g., `\`.</span> + <span class='ident'>UnexpectedEscapeEof</span>, + <span class='doccomment'>/// Saw end of regex before flags were closed. e.g., `(?i`.</span> + <span class='ident'>UnexpectedFlagEof</span>, + <span class='doccomment'>/// Saw end of regex before two hexadecimal digits were seen. e.g., `\xA`.</span> + <span class='ident'>UnexpectedTwoDigitHexEof</span>, + <span class='doccomment'>/// Unopened parenthesis. e.g., `)`.</span> + <span class='ident'>UnopenedParen</span>, + <span class='doccomment'>/// Unrecognized escape sequence. e.g., `\q`.</span> + <span class='ident'>UnrecognizedEscape</span>(<span class='ident'>char</span>), + <span class='doccomment'>/// Unrecognized flag. e.g., `(?a)`.</span> + <span class='ident'>UnrecognizedFlag</span>(<span class='ident'>char</span>), + <span class='doccomment'>/// Unrecognized named Unicode class. e.g., `\p{Foo}`.</span> + <span class='ident'>UnrecognizedUnicodeClass</span>(<span class='ident'>String</span>), + <span class='doccomment'>/// Hints that destructuring should not be exhaustive.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// This enum may grow additional variants, so this makes sure clients</span> + <span class='doccomment'>/// don't count on exhaustive matching. (Otherwise, adding a new variant</span> + <span class='doccomment'>/// could break existing code.)</span> + <span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> + <span class='ident'>__Nonexhaustive</span>, +} + +<span class='kw'>impl</span> <span class='ident'>Error</span> { + <span class='doccomment'>/// Returns an approximate *character* offset at which the error occurred.</span> + <span class='doccomment'>///</span> + <span class='doccomment'>/// The character offset may be equal to the number of characters in the</span> + <span class='doccomment'>/// string, in which case it should be interpreted as pointing to the end</span> + <span class='doccomment'>/// of the regex.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>position</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='self'>self</span>.<span class='ident'>pos</span> + } + + <span class='doccomment'>/// Returns the type of the regex parse error.</span> + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>kind</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>ErrorKind</span> { + <span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>kind</span> + } +} + +<span class='kw'>impl</span> <span class='ident'>ErrorKind</span> { + <span class='kw'>fn</span> <span class='ident'>description</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>str</span> { + <span class='kw'>use</span> <span class='ident'>ErrorKind</span>::<span class='op'>*</span>; + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>DoubleFlagNegation</span> <span class='op'>=></span> <span class='string'>"double flag negation"</span>, + <span class='ident'>DuplicateCaptureName</span>(_) <span class='op'>=></span> <span class='string'>"duplicate capture name"</span>, + <span class='ident'>EmptyAlternate</span> <span class='op'>=></span> <span class='string'>"empty alternate"</span>, + <span class='ident'>EmptyCaptureName</span> <span class='op'>=></span> <span class='string'>"empty capture name"</span>, + <span class='ident'>EmptyFlagNegation</span> <span class='op'>=></span> <span class='string'>"flag negation without any flags"</span>, + <span class='ident'>EmptyGroup</span> <span class='op'>=></span> <span class='string'>"empty group (e.g., '()')"</span>, + <span class='ident'>InvalidBase10</span>(_) <span class='op'>=></span> <span class='string'>"invalid base 10 number"</span>, + <span class='ident'>InvalidBase16</span>(_) <span class='op'>=></span> <span class='string'>"invalid base 16 number"</span>, + <span class='ident'>InvalidCaptureName</span>(_) <span class='op'>=></span> <span class='string'>"invalid capture name"</span>, + <span class='ident'>InvalidClassRange</span>{..} <span class='op'>=></span> <span class='string'>"invalid character class range"</span>, + <span class='ident'>InvalidClassEscape</span>(_) <span class='op'>=></span> <span class='string'>"invalid escape sequence in class"</span>, + <span class='ident'>InvalidRepeatRange</span>{..} <span class='op'>=></span> <span class='string'>"invalid counted repetition range"</span>, + <span class='ident'>InvalidScalarValue</span>(_) <span class='op'>=></span> <span class='string'>"invalid Unicode scalar value"</span>, + <span class='ident'>MissingBase10</span> <span class='op'>=></span> <span class='string'>"missing count in repetition operator"</span>, + <span class='ident'>RepeaterExpectsExpr</span> <span class='op'>=></span> <span class='string'>"repetition operator missing expression"</span>, + <span class='ident'>RepeaterUnexpectedExpr</span>(_) <span class='op'>=></span> <span class='string'>"expression cannot be repeated"</span>, + <span class='ident'>UnclosedCaptureName</span>(_) <span class='op'>=></span> <span class='string'>"unclosed capture group name"</span>, + <span class='ident'>UnclosedHex</span> <span class='op'>=></span> <span class='string'>"unclosed hexadecimal literal"</span>, + <span class='ident'>UnclosedParen</span> <span class='op'>=></span> <span class='string'>"unclosed parenthesis"</span>, + <span class='ident'>UnclosedRepeat</span> <span class='op'>=></span> <span class='string'>"unclosed counted repetition operator"</span>, + <span class='ident'>UnclosedUnicodeName</span> <span class='op'>=></span> <span class='string'>"unclosed Unicode class literal"</span>, + <span class='ident'>UnexpectedClassEof</span> <span class='op'>=></span> <span class='string'>"unexpected EOF in character class"</span>, + <span class='ident'>UnexpectedEscapeEof</span> <span class='op'>=></span> <span class='string'>"unexpected EOF in escape sequence"</span>, + <span class='ident'>UnexpectedFlagEof</span> <span class='op'>=></span> <span class='string'>"unexpected EOF in flags"</span>, + <span class='ident'>UnexpectedTwoDigitHexEof</span> <span class='op'>=></span> <span class='string'>"unexpected EOF in hex literal"</span>, + <span class='ident'>UnopenedParen</span> <span class='op'>=></span> <span class='string'>"unopened parenthesis"</span>, + <span class='ident'>UnrecognizedEscape</span>(_) <span class='op'>=></span> <span class='string'>"unrecognized escape sequence"</span>, + <span class='ident'>UnrecognizedFlag</span>(_) <span class='op'>=></span> <span class='string'>"unrecognized flag"</span>, + <span class='ident'>UnrecognizedUnicodeClass</span>(_) <span class='op'>=></span> <span class='string'>"unrecognized Unicode class name"</span>, + <span class='ident'>__Nonexhaustive</span> <span class='op'>=></span> <span class='macro'>unreachable</span><span class='macro'>!</span>(), + } + } +} + +<span class='kw'>impl</span> ::<span class='ident'>std</span>::<span class='ident'>error</span>::<span class='ident'>Error</span> <span class='kw'>for</span> <span class='ident'>Error</span> { + <span class='kw'>fn</span> <span class='ident'>description</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='kw-2'>&</span><span class='ident'>str</span> { + <span class='self'>self</span>.<span class='ident'>kind</span>.<span class='ident'>description</span>() + } +} + +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Display</span> <span class='kw'>for</span> <span class='ident'>Error</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Error parsing regex near '{}' at character offset {}: {}"</span>, + <span class='self'>self</span>.<span class='ident'>surround</span>, <span class='self'>self</span>.<span class='ident'>pos</span>, <span class='self'>self</span>.<span class='ident'>kind</span>) + } +} + +<span class='kw'>impl</span> <span class='ident'>fmt</span>::<span class='ident'>Display</span> <span class='kw'>for</span> <span class='ident'>ErrorKind</span> { + <span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>f</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>fmt</span>::<span class='ident'>Formatter</span>) <span class='op'>-></span> <span class='ident'>fmt</span>::<span class='prelude-ty'>Result</span> { + <span class='kw'>use</span> <span class='ident'>ErrorKind</span>::<span class='op'>*</span>; + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>DoubleFlagNegation</span> <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Only one negation symbol is allowed in flags."</span>), + <span class='ident'>DuplicateCaptureName</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Capture name '{}' is used more than once."</span>, <span class='ident'>s</span>), + <span class='ident'>EmptyAlternate</span> <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Alternations cannot be empty."</span>), + <span class='ident'>EmptyCaptureName</span> <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Capture names cannot be empty."</span>), + <span class='ident'>EmptyFlagNegation</span> <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Flag negation requires setting at least one flag."</span>), + <span class='ident'>EmptyGroup</span> <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Empty regex groups (e.g., '()') are not allowed."</span>), + <span class='ident'>InvalidBase10</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Not a valid base 10 number: '{}'"</span>, <span class='ident'>s</span>), + <span class='ident'>InvalidBase16</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Not a valid base 16 number: '{}'"</span>, <span class='ident'>s</span>), + <span class='ident'>InvalidCaptureName</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Invalid capture name: '{}'. Capture names must \ + consist of [_a-zA-Z0-9] and are not allowed to \ + start with with a number."</span>, <span class='ident'>s</span>), + <span class='ident'>InvalidClassRange</span> { <span class='ident'>start</span>, <span class='ident'>end</span> } <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Invalid character class range '{}-{}'. \ + Character class ranges must start with the smaller \ + character, but {} > {}"</span>, <span class='ident'>start</span>, <span class='ident'>end</span>, <span class='ident'>start</span>, <span class='ident'>end</span>), + <span class='ident'>InvalidClassEscape</span>(<span class='kw-2'>ref</span> <span class='ident'>e</span>) <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Invalid escape sequence in character \ + class: '{}'."</span>, <span class='ident'>e</span>), + <span class='ident'>InvalidRepeatRange</span> { <span class='ident'>min</span>, <span class='ident'>max</span> } <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Invalid counted repetition range: {{{}, {}}}. \ + Counted repetition ranges must start with the \ + minimum, but {} > {}"</span>, <span class='ident'>min</span>, <span class='ident'>max</span>, <span class='ident'>min</span>, <span class='ident'>max</span>), + <span class='ident'>InvalidScalarValue</span>(<span class='ident'>c</span>) <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Number does not correspond to a Unicode scalar \ + value: '{}'."</span>, <span class='ident'>c</span>), + <span class='ident'>MissingBase10</span> <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Missing maximum in counted reptition operator."</span>), + <span class='ident'>RepeaterExpectsExpr</span> <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Missing expression for reptition operator."</span>), + <span class='ident'>RepeaterUnexpectedExpr</span>(<span class='kw-2'>ref</span> <span class='ident'>e</span>) <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Invalid application of reptition operator to: \ + '{}'."</span>, <span class='ident'>e</span>), + <span class='ident'>UnclosedCaptureName</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Capture name group for '{}' is not closed. \ + (Missing a '>'.)"</span>, <span class='ident'>s</span>), + <span class='ident'>UnclosedHex</span> <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Unclosed hexadecimal literal (missing a '}}')."</span>), + <span class='ident'>UnclosedParen</span> <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Unclosed parenthesis."</span>), + <span class='ident'>UnclosedRepeat</span> <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Unclosed counted repetition (missing a '}}')."</span>), + <span class='ident'>UnclosedUnicodeName</span> <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Unclosed Unicode literal (missing a '}}')."</span>), + <span class='ident'>UnexpectedClassEof</span> <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Character class was not closed before the end of \ + the regex (missing a ']')."</span>), + <span class='ident'>UnexpectedEscapeEof</span> <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Started an escape sequence that didn't finish \ + before the end of the regex."</span>), + <span class='ident'>UnexpectedFlagEof</span> <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Inline flag settings was not closed before the end \ + of the regex (missing a ')' or ':')."</span>), + <span class='ident'>UnexpectedTwoDigitHexEof</span> <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Unexpected end of two digit hexadecimal literal."</span>), + <span class='ident'>UnopenedParen</span> <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Unopened parenthesis."</span>), + <span class='ident'>UnrecognizedEscape</span>(<span class='ident'>c</span>) <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Unrecognized escape sequence: '\\{}'."</span>, <span class='ident'>c</span>), + <span class='ident'>UnrecognizedFlag</span>(<span class='ident'>c</span>) <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Unrecognized flag: '{}'. \ + (Allowed flags: i, s, m, U, x.)"</span>, <span class='ident'>c</span>), + <span class='ident'>UnrecognizedUnicodeClass</span>(<span class='kw-2'>ref</span> <span class='ident'>s</span>) <span class='op'>=></span> + <span class='macro'>write</span><span class='macro'>!</span>(<span class='ident'>f</span>, <span class='string'>"Unrecognized Unicode class name: '{}'."</span>, <span class='ident'>s</span>), + <span class='ident'>__Nonexhaustive</span> <span class='op'>=></span> <span class='macro'>unreachable</span><span class='macro'>!</span>(), + } + } +} + +<span class='doccomment'>/// Returns the Unicode *simple* case folding of `c`.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// N.B. This is hidden because it really isn't the responsibility of this</span> +<span class='doccomment'>/// crate to do simple case folding. One hopes that either another crate or</span> +<span class='doccomment'>/// the standard library will be able to do this for us. In any case, we still</span> +<span class='doccomment'>/// expose it because it is used inside the various Regex engines.</span> +<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>simple_case_fold</span>(<span class='ident'>c</span>: <span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>char</span> { + <span class='ident'>simple_case_fold_result</span>(<span class='ident'>c</span>) + .<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>i</span><span class='op'>|</span> <span class='ident'>case_folding</span>::<span class='ident'>C_plus_S_table</span>[<span class='ident'>i</span>].<span class='number'>1</span>) + .<span class='ident'>unwrap_or</span>(<span class='ident'>c</span>) +} + +<span class='doccomment'>/// The result of binary search on the simple case folding table.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// This level of detail is exposed so that we can do case folding on a</span> +<span class='doccomment'>/// range of characters efficiently.</span> +<span class='kw'>fn</span> <span class='ident'>simple_case_fold_result</span>(<span class='ident'>c</span>: <span class='ident'>char</span>) <span class='op'>-></span> ::<span class='ident'>std</span>::<span class='ident'>result</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>usize</span>, <span class='ident'>usize</span><span class='op'>></span> { + <span class='ident'>case_folding</span>::<span class='ident'>C_plus_S_table</span>.<span class='ident'>binary_search_by</span>(<span class='op'>|</span><span class='kw-2'>&</span>(<span class='ident'>x</span>, _)<span class='op'>|</span> <span class='ident'>x</span>.<span class='ident'>cmp</span>(<span class='kw-2'>&</span><span class='ident'>c</span>)) +} + +<span class='doccomment'>/// Escapes all regular expression meta characters in `text`.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// The string returned may be safely used as a literal in a regular</span> +<span class='doccomment'>/// expression.</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>quote</span>(<span class='ident'>text</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>quoted</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='ident'>text</span>.<span class='ident'>len</span>()); + <span class='kw'>for</span> <span class='ident'>c</span> <span class='kw'>in</span> <span class='ident'>text</span>.<span class='ident'>chars</span>() { + <span class='kw'>if</span> <span class='ident'>parser</span>::<span class='ident'>is_punct</span>(<span class='ident'>c</span>) { + <span class='ident'>quoted</span>.<span class='ident'>push</span>(<span class='string'>'\\'</span>); + } + <span class='ident'>quoted</span>.<span class='ident'>push</span>(<span class='ident'>c</span>); + } + <span class='ident'>quoted</span> +} + +<span class='kw'>fn</span> <span class='ident'>quote_char</span>(<span class='ident'>c</span>: <span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>new</span>(); + <span class='kw'>if</span> <span class='ident'>parser</span>::<span class='ident'>is_punct</span>(<span class='ident'>c</span>) { + <span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>'\\'</span>); + } + <span class='ident'>s</span>.<span class='ident'>push</span>(<span class='ident'>c</span>); + <span class='ident'>s</span> +} + +<span class='kw'>fn</span> <span class='ident'>inc_char</span>(<span class='ident'>c</span>: <span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>char</span> { + <span class='kw'>match</span> <span class='ident'>c</span> { + <span class='ident'>char</span>::<span class='ident'>MAX</span> <span class='op'>=></span> <span class='ident'>char</span>::<span class='ident'>MAX</span>, + <span class='string'>'\u{D7FF}'</span> <span class='op'>=></span> <span class='string'>'\u{E000}'</span>, + <span class='ident'>c</span> <span class='op'>=></span> <span class='ident'>char</span>::<span class='ident'>from_u32</span>(<span class='ident'>c</span> <span class='kw'>as</span> <span class='ident'>u32</span> <span class='op'>+</span> <span class='number'>1</span>).<span class='ident'>unwrap</span>(), + } +} + +<span class='kw'>fn</span> <span class='ident'>dec_char</span>(<span class='ident'>c</span>: <span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>char</span> { + <span class='kw'>match</span> <span class='ident'>c</span> { + <span class='string'>'\x00'</span> <span class='op'>=></span> <span class='string'>'\x00'</span>, + <span class='string'>'\u{E000}'</span> <span class='op'>=></span> <span class='string'>'\u{D7FF}'</span>, + <span class='ident'>c</span> <span class='op'>=></span> <span class='ident'>char</span>::<span class='ident'>from_u32</span>(<span class='ident'>c</span> <span class='kw'>as</span> <span class='ident'>u32</span> <span class='op'>-</span> <span class='number'>1</span>).<span class='ident'>unwrap</span>(), + } +} + +<span class='doccomment'>/// Returns true if and only if `c` is a word character.</span> +<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_word_char</span>(<span class='ident'>c</span>: <span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>match</span> <span class='ident'>c</span> { + <span class='string'>'_'</span> <span class='op'>|</span> <span class='string'>'0'</span> ... <span class='string'>'9'</span> <span class='op'>|</span> <span class='string'>'a'</span> ... <span class='string'>'z'</span> <span class='op'>|</span> <span class='string'>'A'</span> ... <span class='string'>'Z'</span> <span class='op'>=></span> <span class='boolval'>true</span>, + _ <span class='op'>=></span> ::<span class='ident'>unicode</span>::<span class='ident'>regex</span>::<span class='ident'>PERLW</span>.<span class='ident'>binary_search_by</span>(<span class='op'>|</span><span class='kw-2'>&</span>(<span class='ident'>start</span>, <span class='ident'>end</span>)<span class='op'>|</span> { + <span class='kw'>if</span> <span class='ident'>c</span> <span class='op'>>=</span> <span class='ident'>start</span> <span class='op'>&&</span> <span class='ident'>c</span> <span class='op'><=</span> <span class='ident'>end</span> { + <span class='ident'>Ordering</span>::<span class='ident'>Equal</span> + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>start</span> <span class='op'>></span> <span class='ident'>c</span> { + <span class='ident'>Ordering</span>::<span class='ident'>Greater</span> + } <span class='kw'>else</span> { + <span class='ident'>Ordering</span>::<span class='ident'>Less</span> + } + }).<span class='ident'>is_ok</span>(), + } +} + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>properties</span>; + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>tests</span> { + <span class='kw'>use</span> {<span class='ident'>CharClass</span>, <span class='ident'>ClassRange</span>}; + + <span class='kw'>fn</span> <span class='ident'>class</span>(<span class='ident'>ranges</span>: <span class='kw-2'>&</span>[(<span class='ident'>char</span>, <span class='ident'>char</span>)]) <span class='op'>-></span> <span class='ident'>CharClass</span> { + <span class='kw'>let</span> <span class='ident'>ranges</span> <span class='op'>=</span> <span class='ident'>ranges</span>.<span class='ident'>iter</span>().<span class='ident'>cloned</span>() + .<span class='ident'>map</span>(<span class='op'>|</span>(<span class='ident'>c1</span>, <span class='ident'>c2</span>)<span class='op'>|</span> <span class='ident'>ClassRange</span>::<span class='ident'>new</span>(<span class='ident'>c1</span>, <span class='ident'>c2</span>)).<span class='ident'>collect</span>(); + <span class='ident'>CharClass</span>::<span class='ident'>new</span>(<span class='ident'>ranges</span>) + } + + <span class='kw'>fn</span> <span class='ident'>classi</span>(<span class='ident'>ranges</span>: <span class='kw-2'>&</span>[(<span class='ident'>char</span>, <span class='ident'>char</span>)]) <span class='op'>-></span> <span class='ident'>CharClass</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='ident'>ranges</span>); + <span class='ident'>cls</span>.<span class='ident'>casei</span> <span class='op'>=</span> <span class='boolval'>true</span>; + <span class='ident'>cls</span> + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_canon_no_change</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'a'</span>, <span class='string'>'c'</span>), (<span class='string'>'x'</span>, <span class='string'>'z'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>clone</span>().<span class='ident'>canonicalize</span>(), <span class='ident'>cls</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_canon_unordered</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'x'</span>, <span class='string'>'z'</span>), (<span class='string'>'a'</span>, <span class='string'>'c'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>canonicalize</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'a'</span>, <span class='string'>'c'</span>), (<span class='string'>'x'</span>, <span class='string'>'z'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_canon_overlap</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'x'</span>, <span class='string'>'z'</span>), (<span class='string'>'w'</span>, <span class='string'>'y'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>canonicalize</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'w'</span>, <span class='string'>'z'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_canon_overlap_many</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'c'</span>, <span class='string'>'f'</span>), (<span class='string'>'a'</span>, <span class='string'>'g'</span>), (<span class='string'>'d'</span>, <span class='string'>'j'</span>), (<span class='string'>'a'</span>, <span class='string'>'c'</span>), + (<span class='string'>'m'</span>, <span class='string'>'p'</span>), (<span class='string'>'l'</span>, <span class='string'>'s'</span>), + ]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>clone</span>().<span class='ident'>canonicalize</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'a'</span>, <span class='string'>'j'</span>), (<span class='string'>'l'</span>, <span class='string'>'s'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_canon_overlap_many_case_fold</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'C'</span>, <span class='string'>'F'</span>), (<span class='string'>'A'</span>, <span class='string'>'G'</span>), (<span class='string'>'D'</span>, <span class='string'>'J'</span>), (<span class='string'>'A'</span>, <span class='string'>'C'</span>), + (<span class='string'>'M'</span>, <span class='string'>'P'</span>), (<span class='string'>'L'</span>, <span class='string'>'S'</span>), (<span class='string'>'c'</span>, <span class='string'>'f'</span>), + ]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>case_fold</span>(), <span class='ident'>classi</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'a'</span>, <span class='string'>'j'</span>), (<span class='string'>'l'</span>, <span class='string'>'s'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_canon_overlap_boundary</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'x'</span>, <span class='string'>'z'</span>), (<span class='string'>'u'</span>, <span class='string'>'w'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>canonicalize</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'u'</span>, <span class='string'>'z'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_canon_extreme_edge_case</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'\x00'</span>, <span class='string'>'\u{10FFFF}'</span>), (<span class='string'>'\x00'</span>, <span class='string'>'\u{10FFFF}'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>canonicalize</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\x00'</span>, <span class='string'>'\u{10FFFF}'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_canon_singles</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'a'</span>, <span class='string'>'a'</span>), (<span class='string'>'b'</span>, <span class='string'>'b'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>canonicalize</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'a'</span>, <span class='string'>'b'</span>)])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_negate_single</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'a'</span>, <span class='string'>'a'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>negate</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\x00'</span>, <span class='string'>'\x60'</span>), (<span class='string'>'\x62'</span>, <span class='string'>'\u{10FFFF}'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_negate_singles</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'a'</span>, <span class='string'>'a'</span>), (<span class='string'>'b'</span>, <span class='string'>'b'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>negate</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\x00'</span>, <span class='string'>'\x60'</span>), (<span class='string'>'\x63'</span>, <span class='string'>'\u{10FFFF}'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_negate_multiples</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'a'</span>, <span class='string'>'c'</span>), (<span class='string'>'x'</span>, <span class='string'>'z'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>negate</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\x00'</span>, <span class='string'>'\x60'</span>), (<span class='string'>'\x64'</span>, <span class='string'>'\x77'</span>), (<span class='string'>'\x7b'</span>, <span class='string'>'\u{10FFFF}'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_negate_min_scalar</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'\x00'</span>, <span class='string'>'a'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>negate</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\x62'</span>, <span class='string'>'\u{10FFFF}'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_negate_max_scalar</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'a'</span>, <span class='string'>'\u{10FFFF}'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>negate</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\x00'</span>, <span class='string'>'\x60'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_negate_everything</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'\x00'</span>, <span class='string'>'\u{10FFFF}'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>negate</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_negate_everything_sans_one</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\x00'</span>, <span class='string'>'\u{10FFFD}'</span>), (<span class='string'>'\u{10FFFF}'</span>, <span class='string'>'\u{10FFFF}'</span>) + ]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>negate</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\u{10FFFE}'</span>, <span class='string'>'\u{10FFFE}'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_negate_surrogates_min</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'\x00'</span>, <span class='string'>'\u{D7FF}'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>negate</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\u{E000}'</span>, <span class='string'>'\u{10FFFF}'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_negate_surrogates_min_edge</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'\x00'</span>, <span class='string'>'\u{D7FE}'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>negate</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\u{D7FF}'</span>, <span class='string'>'\u{10FFFF}'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_negate_surrogates_max</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'\u{E000}'</span>, <span class='string'>'\u{10FFFF}'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>negate</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\x00'</span>, <span class='string'>'\u{D7FF}'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_negate_surrogates_max_edge</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'\u{E001}'</span>, <span class='string'>'\u{10FFFF}'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>negate</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\x00'</span>, <span class='string'>'\u{E000}'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_fold_retain_only_needed</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'A'</span>, <span class='string'>'Z'</span>), (<span class='string'>'a'</span>, <span class='string'>'z'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>case_fold</span>(), <span class='ident'>classi</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'a'</span>, <span class='string'>'z'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_fold_az</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'A'</span>, <span class='string'>'Z'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>case_fold</span>(), <span class='ident'>classi</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'a'</span>, <span class='string'>'z'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_fold_a_underscore</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'A'</span>, <span class='string'>'A'</span>), (<span class='string'>'_'</span>, <span class='string'>'_'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>clone</span>().<span class='ident'>canonicalize</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'A'</span>, <span class='string'>'A'</span>), (<span class='string'>'_'</span>, <span class='string'>'_'</span>), + ])); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>case_fold</span>(), <span class='ident'>classi</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'_'</span>, <span class='string'>'_'</span>), (<span class='string'>'a'</span>, <span class='string'>'a'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_fold_a_equals</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'A'</span>, <span class='string'>'A'</span>), (<span class='string'>'='</span>, <span class='string'>'='</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>clone</span>().<span class='ident'>canonicalize</span>(), <span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'='</span>, <span class='string'>'='</span>), (<span class='string'>'A'</span>, <span class='string'>'A'</span>), + ])); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>case_fold</span>(), <span class='ident'>classi</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'='</span>, <span class='string'>'='</span>), (<span class='string'>'a'</span>, <span class='string'>'a'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_fold_no_folding_needed</span>() { + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'\x00'</span>, <span class='string'>'\x10'</span>)]); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>cls</span>.<span class='ident'>case_fold</span>(), <span class='ident'>classi</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\x00'</span>, <span class='string'>'\x10'</span>), + ])); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "regex_syntax"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/src/regex_syntax/parser.rs.html b/src/regex_syntax/parser.rs.html new file mode 100644 index 0000000..3f94959 --- /dev/null +++ b/src/regex_syntax/parser.rs.html @@ -0,0 +1,4751 @@ +<!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="Source to the Rust file `/home/travis/.cargo/registry/src/github.com-0a35038f75765ae4/regex-syntax-0.1.2/src/parser.rs`."> + <meta name="keywords" content="rust, rustlang, rust-lang"> + + <title>parser.rs.html -- source</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"> + + + </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 source"><pre class="line-numbers"><span id="1"> 1</span> +<span id="2"> 2</span> +<span id="3"> 3</span> +<span id="4"> 4</span> +<span id="5"> 5</span> +<span id="6"> 6</span> +<span id="7"> 7</span> +<span id="8"> 8</span> +<span id="9"> 9</span> +<span id="10"> 10</span> +<span id="11"> 11</span> +<span id="12"> 12</span> +<span id="13"> 13</span> +<span id="14"> 14</span> +<span id="15"> 15</span> +<span id="16"> 16</span> +<span id="17"> 17</span> +<span id="18"> 18</span> +<span id="19"> 19</span> +<span id="20"> 20</span> +<span id="21"> 21</span> +<span id="22"> 22</span> +<span id="23"> 23</span> +<span id="24"> 24</span> +<span id="25"> 25</span> +<span id="26"> 26</span> +<span id="27"> 27</span> +<span id="28"> 28</span> +<span id="29"> 29</span> +<span id="30"> 30</span> +<span id="31"> 31</span> +<span id="32"> 32</span> +<span id="33"> 33</span> +<span id="34"> 34</span> +<span id="35"> 35</span> +<span id="36"> 36</span> +<span id="37"> 37</span> +<span id="38"> 38</span> +<span id="39"> 39</span> +<span id="40"> 40</span> +<span id="41"> 41</span> +<span id="42"> 42</span> +<span id="43"> 43</span> +<span id="44"> 44</span> +<span id="45"> 45</span> +<span id="46"> 46</span> +<span id="47"> 47</span> +<span id="48"> 48</span> +<span id="49"> 49</span> +<span id="50"> 50</span> +<span id="51"> 51</span> +<span id="52"> 52</span> +<span id="53"> 53</span> +<span id="54"> 54</span> +<span id="55"> 55</span> +<span id="56"> 56</span> +<span id="57"> 57</span> +<span id="58"> 58</span> +<span id="59"> 59</span> +<span id="60"> 60</span> +<span id="61"> 61</span> +<span id="62"> 62</span> +<span id="63"> 63</span> +<span id="64"> 64</span> +<span id="65"> 65</span> +<span id="66"> 66</span> +<span id="67"> 67</span> +<span id="68"> 68</span> +<span id="69"> 69</span> +<span id="70"> 70</span> +<span id="71"> 71</span> +<span id="72"> 72</span> +<span id="73"> 73</span> +<span id="74"> 74</span> +<span id="75"> 75</span> +<span id="76"> 76</span> +<span id="77"> 77</span> +<span id="78"> 78</span> +<span id="79"> 79</span> +<span id="80"> 80</span> +<span id="81"> 81</span> +<span id="82"> 82</span> +<span id="83"> 83</span> +<span id="84"> 84</span> +<span id="85"> 85</span> +<span id="86"> 86</span> +<span id="87"> 87</span> +<span id="88"> 88</span> +<span id="89"> 89</span> +<span id="90"> 90</span> +<span id="91"> 91</span> +<span id="92"> 92</span> +<span id="93"> 93</span> +<span id="94"> 94</span> +<span id="95"> 95</span> +<span id="96"> 96</span> +<span id="97"> 97</span> +<span id="98"> 98</span> +<span id="99"> 99</span> +<span id="100"> 100</span> +<span id="101"> 101</span> +<span id="102"> 102</span> +<span id="103"> 103</span> +<span id="104"> 104</span> +<span id="105"> 105</span> +<span id="106"> 106</span> +<span id="107"> 107</span> +<span id="108"> 108</span> +<span id="109"> 109</span> +<span id="110"> 110</span> +<span id="111"> 111</span> +<span id="112"> 112</span> +<span id="113"> 113</span> +<span id="114"> 114</span> +<span id="115"> 115</span> +<span id="116"> 116</span> +<span id="117"> 117</span> +<span id="118"> 118</span> +<span id="119"> 119</span> +<span id="120"> 120</span> +<span id="121"> 121</span> +<span id="122"> 122</span> +<span id="123"> 123</span> +<span id="124"> 124</span> +<span id="125"> 125</span> +<span id="126"> 126</span> +<span id="127"> 127</span> +<span id="128"> 128</span> +<span id="129"> 129</span> +<span id="130"> 130</span> +<span id="131"> 131</span> +<span id="132"> 132</span> +<span id="133"> 133</span> +<span id="134"> 134</span> +<span id="135"> 135</span> +<span id="136"> 136</span> +<span id="137"> 137</span> +<span id="138"> 138</span> +<span id="139"> 139</span> +<span id="140"> 140</span> +<span id="141"> 141</span> +<span id="142"> 142</span> +<span id="143"> 143</span> +<span id="144"> 144</span> +<span id="145"> 145</span> +<span id="146"> 146</span> +<span id="147"> 147</span> +<span id="148"> 148</span> +<span id="149"> 149</span> +<span id="150"> 150</span> +<span id="151"> 151</span> +<span id="152"> 152</span> +<span id="153"> 153</span> +<span id="154"> 154</span> +<span id="155"> 155</span> +<span id="156"> 156</span> +<span id="157"> 157</span> +<span id="158"> 158</span> +<span id="159"> 159</span> +<span id="160"> 160</span> +<span id="161"> 161</span> +<span id="162"> 162</span> +<span id="163"> 163</span> +<span id="164"> 164</span> +<span id="165"> 165</span> +<span id="166"> 166</span> +<span id="167"> 167</span> +<span id="168"> 168</span> +<span id="169"> 169</span> +<span id="170"> 170</span> +<span id="171"> 171</span> +<span id="172"> 172</span> +<span id="173"> 173</span> +<span id="174"> 174</span> +<span id="175"> 175</span> +<span id="176"> 176</span> +<span id="177"> 177</span> +<span id="178"> 178</span> +<span id="179"> 179</span> +<span id="180"> 180</span> +<span id="181"> 181</span> +<span id="182"> 182</span> +<span id="183"> 183</span> +<span id="184"> 184</span> +<span id="185"> 185</span> +<span id="186"> 186</span> +<span id="187"> 187</span> +<span id="188"> 188</span> +<span id="189"> 189</span> +<span id="190"> 190</span> +<span id="191"> 191</span> +<span id="192"> 192</span> +<span id="193"> 193</span> +<span id="194"> 194</span> +<span id="195"> 195</span> +<span id="196"> 196</span> +<span id="197"> 197</span> +<span id="198"> 198</span> +<span id="199"> 199</span> +<span id="200"> 200</span> +<span id="201"> 201</span> +<span id="202"> 202</span> +<span id="203"> 203</span> +<span id="204"> 204</span> +<span id="205"> 205</span> +<span id="206"> 206</span> +<span id="207"> 207</span> +<span id="208"> 208</span> +<span id="209"> 209</span> +<span id="210"> 210</span> +<span id="211"> 211</span> +<span id="212"> 212</span> +<span id="213"> 213</span> +<span id="214"> 214</span> +<span id="215"> 215</span> +<span id="216"> 216</span> +<span id="217"> 217</span> +<span id="218"> 218</span> +<span id="219"> 219</span> +<span id="220"> 220</span> +<span id="221"> 221</span> +<span id="222"> 222</span> +<span id="223"> 223</span> +<span id="224"> 224</span> +<span id="225"> 225</span> +<span id="226"> 226</span> +<span id="227"> 227</span> +<span id="228"> 228</span> +<span id="229"> 229</span> +<span id="230"> 230</span> +<span id="231"> 231</span> +<span id="232"> 232</span> +<span id="233"> 233</span> +<span id="234"> 234</span> +<span id="235"> 235</span> +<span id="236"> 236</span> +<span id="237"> 237</span> +<span id="238"> 238</span> +<span id="239"> 239</span> +<span id="240"> 240</span> +<span id="241"> 241</span> +<span id="242"> 242</span> +<span id="243"> 243</span> +<span id="244"> 244</span> +<span id="245"> 245</span> +<span id="246"> 246</span> +<span id="247"> 247</span> +<span id="248"> 248</span> +<span id="249"> 249</span> +<span id="250"> 250</span> +<span id="251"> 251</span> +<span id="252"> 252</span> +<span id="253"> 253</span> +<span id="254"> 254</span> +<span id="255"> 255</span> +<span id="256"> 256</span> +<span id="257"> 257</span> +<span id="258"> 258</span> +<span id="259"> 259</span> +<span id="260"> 260</span> +<span id="261"> 261</span> +<span id="262"> 262</span> +<span id="263"> 263</span> +<span id="264"> 264</span> +<span id="265"> 265</span> +<span id="266"> 266</span> +<span id="267"> 267</span> +<span id="268"> 268</span> +<span id="269"> 269</span> +<span id="270"> 270</span> +<span id="271"> 271</span> +<span id="272"> 272</span> +<span id="273"> 273</span> +<span id="274"> 274</span> +<span id="275"> 275</span> +<span id="276"> 276</span> +<span id="277"> 277</span> +<span id="278"> 278</span> +<span id="279"> 279</span> +<span id="280"> 280</span> +<span id="281"> 281</span> +<span id="282"> 282</span> +<span id="283"> 283</span> +<span id="284"> 284</span> +<span id="285"> 285</span> +<span id="286"> 286</span> +<span id="287"> 287</span> +<span id="288"> 288</span> +<span id="289"> 289</span> +<span id="290"> 290</span> +<span id="291"> 291</span> +<span id="292"> 292</span> +<span id="293"> 293</span> +<span id="294"> 294</span> +<span id="295"> 295</span> +<span id="296"> 296</span> +<span id="297"> 297</span> +<span id="298"> 298</span> +<span id="299"> 299</span> +<span id="300"> 300</span> +<span id="301"> 301</span> +<span id="302"> 302</span> +<span id="303"> 303</span> +<span id="304"> 304</span> +<span id="305"> 305</span> +<span id="306"> 306</span> +<span id="307"> 307</span> +<span id="308"> 308</span> +<span id="309"> 309</span> +<span id="310"> 310</span> +<span id="311"> 311</span> +<span id="312"> 312</span> +<span id="313"> 313</span> +<span id="314"> 314</span> +<span id="315"> 315</span> +<span id="316"> 316</span> +<span id="317"> 317</span> +<span id="318"> 318</span> +<span id="319"> 319</span> +<span id="320"> 320</span> +<span id="321"> 321</span> +<span id="322"> 322</span> +<span id="323"> 323</span> +<span id="324"> 324</span> +<span id="325"> 325</span> +<span id="326"> 326</span> +<span id="327"> 327</span> +<span id="328"> 328</span> +<span id="329"> 329</span> +<span id="330"> 330</span> +<span id="331"> 331</span> +<span id="332"> 332</span> +<span id="333"> 333</span> +<span id="334"> 334</span> +<span id="335"> 335</span> +<span id="336"> 336</span> +<span id="337"> 337</span> +<span id="338"> 338</span> +<span id="339"> 339</span> +<span id="340"> 340</span> +<span id="341"> 341</span> +<span id="342"> 342</span> +<span id="343"> 343</span> +<span id="344"> 344</span> +<span id="345"> 345</span> +<span id="346"> 346</span> +<span id="347"> 347</span> +<span id="348"> 348</span> +<span id="349"> 349</span> +<span id="350"> 350</span> +<span id="351"> 351</span> +<span id="352"> 352</span> +<span id="353"> 353</span> +<span id="354"> 354</span> +<span id="355"> 355</span> +<span id="356"> 356</span> +<span id="357"> 357</span> +<span id="358"> 358</span> +<span id="359"> 359</span> +<span id="360"> 360</span> +<span id="361"> 361</span> +<span id="362"> 362</span> +<span id="363"> 363</span> +<span id="364"> 364</span> +<span id="365"> 365</span> +<span id="366"> 366</span> +<span id="367"> 367</span> +<span id="368"> 368</span> +<span id="369"> 369</span> +<span id="370"> 370</span> +<span id="371"> 371</span> +<span id="372"> 372</span> +<span id="373"> 373</span> +<span id="374"> 374</span> +<span id="375"> 375</span> +<span id="376"> 376</span> +<span id="377"> 377</span> +<span id="378"> 378</span> +<span id="379"> 379</span> +<span id="380"> 380</span> +<span id="381"> 381</span> +<span id="382"> 382</span> +<span id="383"> 383</span> +<span id="384"> 384</span> +<span id="385"> 385</span> +<span id="386"> 386</span> +<span id="387"> 387</span> +<span id="388"> 388</span> +<span id="389"> 389</span> +<span id="390"> 390</span> +<span id="391"> 391</span> +<span id="392"> 392</span> +<span id="393"> 393</span> +<span id="394"> 394</span> +<span id="395"> 395</span> +<span id="396"> 396</span> +<span id="397"> 397</span> +<span id="398"> 398</span> +<span id="399"> 399</span> +<span id="400"> 400</span> +<span id="401"> 401</span> +<span id="402"> 402</span> +<span id="403"> 403</span> +<span id="404"> 404</span> +<span id="405"> 405</span> +<span id="406"> 406</span> +<span id="407"> 407</span> +<span id="408"> 408</span> +<span id="409"> 409</span> +<span id="410"> 410</span> +<span id="411"> 411</span> +<span id="412"> 412</span> +<span id="413"> 413</span> +<span id="414"> 414</span> +<span id="415"> 415</span> +<span id="416"> 416</span> +<span id="417"> 417</span> +<span id="418"> 418</span> +<span id="419"> 419</span> +<span id="420"> 420</span> +<span id="421"> 421</span> +<span id="422"> 422</span> +<span id="423"> 423</span> +<span id="424"> 424</span> +<span id="425"> 425</span> +<span id="426"> 426</span> +<span id="427"> 427</span> +<span id="428"> 428</span> +<span id="429"> 429</span> +<span id="430"> 430</span> +<span id="431"> 431</span> +<span id="432"> 432</span> +<span id="433"> 433</span> +<span id="434"> 434</span> +<span id="435"> 435</span> +<span id="436"> 436</span> +<span id="437"> 437</span> +<span id="438"> 438</span> +<span id="439"> 439</span> +<span id="440"> 440</span> +<span id="441"> 441</span> +<span id="442"> 442</span> +<span id="443"> 443</span> +<span id="444"> 444</span> +<span id="445"> 445</span> +<span id="446"> 446</span> +<span id="447"> 447</span> +<span id="448"> 448</span> +<span id="449"> 449</span> +<span id="450"> 450</span> +<span id="451"> 451</span> +<span id="452"> 452</span> +<span id="453"> 453</span> +<span id="454"> 454</span> +<span id="455"> 455</span> +<span id="456"> 456</span> +<span id="457"> 457</span> +<span id="458"> 458</span> +<span id="459"> 459</span> +<span id="460"> 460</span> +<span id="461"> 461</span> +<span id="462"> 462</span> +<span id="463"> 463</span> +<span id="464"> 464</span> +<span id="465"> 465</span> +<span id="466"> 466</span> +<span id="467"> 467</span> +<span id="468"> 468</span> +<span id="469"> 469</span> +<span id="470"> 470</span> +<span id="471"> 471</span> +<span id="472"> 472</span> +<span id="473"> 473</span> +<span id="474"> 474</span> +<span id="475"> 475</span> +<span id="476"> 476</span> +<span id="477"> 477</span> +<span id="478"> 478</span> +<span id="479"> 479</span> +<span id="480"> 480</span> +<span id="481"> 481</span> +<span id="482"> 482</span> +<span id="483"> 483</span> +<span id="484"> 484</span> +<span id="485"> 485</span> +<span id="486"> 486</span> +<span id="487"> 487</span> +<span id="488"> 488</span> +<span id="489"> 489</span> +<span id="490"> 490</span> +<span id="491"> 491</span> +<span id="492"> 492</span> +<span id="493"> 493</span> +<span id="494"> 494</span> +<span id="495"> 495</span> +<span id="496"> 496</span> +<span id="497"> 497</span> +<span id="498"> 498</span> +<span id="499"> 499</span> +<span id="500"> 500</span> +<span id="501"> 501</span> +<span id="502"> 502</span> +<span id="503"> 503</span> +<span id="504"> 504</span> +<span id="505"> 505</span> +<span id="506"> 506</span> +<span id="507"> 507</span> +<span id="508"> 508</span> +<span id="509"> 509</span> +<span id="510"> 510</span> +<span id="511"> 511</span> +<span id="512"> 512</span> +<span id="513"> 513</span> +<span id="514"> 514</span> +<span id="515"> 515</span> +<span id="516"> 516</span> +<span id="517"> 517</span> +<span id="518"> 518</span> +<span id="519"> 519</span> +<span id="520"> 520</span> +<span id="521"> 521</span> +<span id="522"> 522</span> +<span id="523"> 523</span> +<span id="524"> 524</span> +<span id="525"> 525</span> +<span id="526"> 526</span> +<span id="527"> 527</span> +<span id="528"> 528</span> +<span id="529"> 529</span> +<span id="530"> 530</span> +<span id="531"> 531</span> +<span id="532"> 532</span> +<span id="533"> 533</span> +<span id="534"> 534</span> +<span id="535"> 535</span> +<span id="536"> 536</span> +<span id="537"> 537</span> +<span id="538"> 538</span> +<span id="539"> 539</span> +<span id="540"> 540</span> +<span id="541"> 541</span> +<span id="542"> 542</span> +<span id="543"> 543</span> +<span id="544"> 544</span> +<span id="545"> 545</span> +<span id="546"> 546</span> +<span id="547"> 547</span> +<span id="548"> 548</span> +<span id="549"> 549</span> +<span id="550"> 550</span> +<span id="551"> 551</span> +<span id="552"> 552</span> +<span id="553"> 553</span> +<span id="554"> 554</span> +<span id="555"> 555</span> +<span id="556"> 556</span> +<span id="557"> 557</span> +<span id="558"> 558</span> +<span id="559"> 559</span> +<span id="560"> 560</span> +<span id="561"> 561</span> +<span id="562"> 562</span> +<span id="563"> 563</span> +<span id="564"> 564</span> +<span id="565"> 565</span> +<span id="566"> 566</span> +<span id="567"> 567</span> +<span id="568"> 568</span> +<span id="569"> 569</span> +<span id="570"> 570</span> +<span id="571"> 571</span> +<span id="572"> 572</span> +<span id="573"> 573</span> +<span id="574"> 574</span> +<span id="575"> 575</span> +<span id="576"> 576</span> +<span id="577"> 577</span> +<span id="578"> 578</span> +<span id="579"> 579</span> +<span id="580"> 580</span> +<span id="581"> 581</span> +<span id="582"> 582</span> +<span id="583"> 583</span> +<span id="584"> 584</span> +<span id="585"> 585</span> +<span id="586"> 586</span> +<span id="587"> 587</span> +<span id="588"> 588</span> +<span id="589"> 589</span> +<span id="590"> 590</span> +<span id="591"> 591</span> +<span id="592"> 592</span> +<span id="593"> 593</span> +<span id="594"> 594</span> +<span id="595"> 595</span> +<span id="596"> 596</span> +<span id="597"> 597</span> +<span id="598"> 598</span> +<span id="599"> 599</span> +<span id="600"> 600</span> +<span id="601"> 601</span> +<span id="602"> 602</span> +<span id="603"> 603</span> +<span id="604"> 604</span> +<span id="605"> 605</span> +<span id="606"> 606</span> +<span id="607"> 607</span> +<span id="608"> 608</span> +<span id="609"> 609</span> +<span id="610"> 610</span> +<span id="611"> 611</span> +<span id="612"> 612</span> +<span id="613"> 613</span> +<span id="614"> 614</span> +<span id="615"> 615</span> +<span id="616"> 616</span> +<span id="617"> 617</span> +<span id="618"> 618</span> +<span id="619"> 619</span> +<span id="620"> 620</span> +<span id="621"> 621</span> +<span id="622"> 622</span> +<span id="623"> 623</span> +<span id="624"> 624</span> +<span id="625"> 625</span> +<span id="626"> 626</span> +<span id="627"> 627</span> +<span id="628"> 628</span> +<span id="629"> 629</span> +<span id="630"> 630</span> +<span id="631"> 631</span> +<span id="632"> 632</span> +<span id="633"> 633</span> +<span id="634"> 634</span> +<span id="635"> 635</span> +<span id="636"> 636</span> +<span id="637"> 637</span> +<span id="638"> 638</span> +<span id="639"> 639</span> +<span id="640"> 640</span> +<span id="641"> 641</span> +<span id="642"> 642</span> +<span id="643"> 643</span> +<span id="644"> 644</span> +<span id="645"> 645</span> +<span id="646"> 646</span> +<span id="647"> 647</span> +<span id="648"> 648</span> +<span id="649"> 649</span> +<span id="650"> 650</span> +<span id="651"> 651</span> +<span id="652"> 652</span> +<span id="653"> 653</span> +<span id="654"> 654</span> +<span id="655"> 655</span> +<span id="656"> 656</span> +<span id="657"> 657</span> +<span id="658"> 658</span> +<span id="659"> 659</span> +<span id="660"> 660</span> +<span id="661"> 661</span> +<span id="662"> 662</span> +<span id="663"> 663</span> +<span id="664"> 664</span> +<span id="665"> 665</span> +<span id="666"> 666</span> +<span id="667"> 667</span> +<span id="668"> 668</span> +<span id="669"> 669</span> +<span id="670"> 670</span> +<span id="671"> 671</span> +<span id="672"> 672</span> +<span id="673"> 673</span> +<span id="674"> 674</span> +<span id="675"> 675</span> +<span id="676"> 676</span> +<span id="677"> 677</span> +<span id="678"> 678</span> +<span id="679"> 679</span> +<span id="680"> 680</span> +<span id="681"> 681</span> +<span id="682"> 682</span> +<span id="683"> 683</span> +<span id="684"> 684</span> +<span id="685"> 685</span> +<span id="686"> 686</span> +<span id="687"> 687</span> +<span id="688"> 688</span> +<span id="689"> 689</span> +<span id="690"> 690</span> +<span id="691"> 691</span> +<span id="692"> 692</span> +<span id="693"> 693</span> +<span id="694"> 694</span> +<span id="695"> 695</span> +<span id="696"> 696</span> +<span id="697"> 697</span> +<span id="698"> 698</span> +<span id="699"> 699</span> +<span id="700"> 700</span> +<span id="701"> 701</span> +<span id="702"> 702</span> +<span id="703"> 703</span> +<span id="704"> 704</span> +<span id="705"> 705</span> +<span id="706"> 706</span> +<span id="707"> 707</span> +<span id="708"> 708</span> +<span id="709"> 709</span> +<span id="710"> 710</span> +<span id="711"> 711</span> +<span id="712"> 712</span> +<span id="713"> 713</span> +<span id="714"> 714</span> +<span id="715"> 715</span> +<span id="716"> 716</span> +<span id="717"> 717</span> +<span id="718"> 718</span> +<span id="719"> 719</span> +<span id="720"> 720</span> +<span id="721"> 721</span> +<span id="722"> 722</span> +<span id="723"> 723</span> +<span id="724"> 724</span> +<span id="725"> 725</span> +<span id="726"> 726</span> +<span id="727"> 727</span> +<span id="728"> 728</span> +<span id="729"> 729</span> +<span id="730"> 730</span> +<span id="731"> 731</span> +<span id="732"> 732</span> +<span id="733"> 733</span> +<span id="734"> 734</span> +<span id="735"> 735</span> +<span id="736"> 736</span> +<span id="737"> 737</span> +<span id="738"> 738</span> +<span id="739"> 739</span> +<span id="740"> 740</span> +<span id="741"> 741</span> +<span id="742"> 742</span> +<span id="743"> 743</span> +<span id="744"> 744</span> +<span id="745"> 745</span> +<span id="746"> 746</span> +<span id="747"> 747</span> +<span id="748"> 748</span> +<span id="749"> 749</span> +<span id="750"> 750</span> +<span id="751"> 751</span> +<span id="752"> 752</span> +<span id="753"> 753</span> +<span id="754"> 754</span> +<span id="755"> 755</span> +<span id="756"> 756</span> +<span id="757"> 757</span> +<span id="758"> 758</span> +<span id="759"> 759</span> +<span id="760"> 760</span> +<span id="761"> 761</span> +<span id="762"> 762</span> +<span id="763"> 763</span> +<span id="764"> 764</span> +<span id="765"> 765</span> +<span id="766"> 766</span> +<span id="767"> 767</span> +<span id="768"> 768</span> +<span id="769"> 769</span> +<span id="770"> 770</span> +<span id="771"> 771</span> +<span id="772"> 772</span> +<span id="773"> 773</span> +<span id="774"> 774</span> +<span id="775"> 775</span> +<span id="776"> 776</span> +<span id="777"> 777</span> +<span id="778"> 778</span> +<span id="779"> 779</span> +<span id="780"> 780</span> +<span id="781"> 781</span> +<span id="782"> 782</span> +<span id="783"> 783</span> +<span id="784"> 784</span> +<span id="785"> 785</span> +<span id="786"> 786</span> +<span id="787"> 787</span> +<span id="788"> 788</span> +<span id="789"> 789</span> +<span id="790"> 790</span> +<span id="791"> 791</span> +<span id="792"> 792</span> +<span id="793"> 793</span> +<span id="794"> 794</span> +<span id="795"> 795</span> +<span id="796"> 796</span> +<span id="797"> 797</span> +<span id="798"> 798</span> +<span id="799"> 799</span> +<span id="800"> 800</span> +<span id="801"> 801</span> +<span id="802"> 802</span> +<span id="803"> 803</span> +<span id="804"> 804</span> +<span id="805"> 805</span> +<span id="806"> 806</span> +<span id="807"> 807</span> +<span id="808"> 808</span> +<span id="809"> 809</span> +<span id="810"> 810</span> +<span id="811"> 811</span> +<span id="812"> 812</span> +<span id="813"> 813</span> +<span id="814"> 814</span> +<span id="815"> 815</span> +<span id="816"> 816</span> +<span id="817"> 817</span> +<span id="818"> 818</span> +<span id="819"> 819</span> +<span id="820"> 820</span> +<span id="821"> 821</span> +<span id="822"> 822</span> +<span id="823"> 823</span> +<span id="824"> 824</span> +<span id="825"> 825</span> +<span id="826"> 826</span> +<span id="827"> 827</span> +<span id="828"> 828</span> +<span id="829"> 829</span> +<span id="830"> 830</span> +<span id="831"> 831</span> +<span id="832"> 832</span> +<span id="833"> 833</span> +<span id="834"> 834</span> +<span id="835"> 835</span> +<span id="836"> 836</span> +<span id="837"> 837</span> +<span id="838"> 838</span> +<span id="839"> 839</span> +<span id="840"> 840</span> +<span id="841"> 841</span> +<span id="842"> 842</span> +<span id="843"> 843</span> +<span id="844"> 844</span> +<span id="845"> 845</span> +<span id="846"> 846</span> +<span id="847"> 847</span> +<span id="848"> 848</span> +<span id="849"> 849</span> +<span id="850"> 850</span> +<span id="851"> 851</span> +<span id="852"> 852</span> +<span id="853"> 853</span> +<span id="854"> 854</span> +<span id="855"> 855</span> +<span id="856"> 856</span> +<span id="857"> 857</span> +<span id="858"> 858</span> +<span id="859"> 859</span> +<span id="860"> 860</span> +<span id="861"> 861</span> +<span id="862"> 862</span> +<span id="863"> 863</span> +<span id="864"> 864</span> +<span id="865"> 865</span> +<span id="866"> 866</span> +<span id="867"> 867</span> +<span id="868"> 868</span> +<span id="869"> 869</span> +<span id="870"> 870</span> +<span id="871"> 871</span> +<span id="872"> 872</span> +<span id="873"> 873</span> +<span id="874"> 874</span> +<span id="875"> 875</span> +<span id="876"> 876</span> +<span id="877"> 877</span> +<span id="878"> 878</span> +<span id="879"> 879</span> +<span id="880"> 880</span> +<span id="881"> 881</span> +<span id="882"> 882</span> +<span id="883"> 883</span> +<span id="884"> 884</span> +<span id="885"> 885</span> +<span id="886"> 886</span> +<span id="887"> 887</span> +<span id="888"> 888</span> +<span id="889"> 889</span> +<span id="890"> 890</span> +<span id="891"> 891</span> +<span id="892"> 892</span> +<span id="893"> 893</span> +<span id="894"> 894</span> +<span id="895"> 895</span> +<span id="896"> 896</span> +<span id="897"> 897</span> +<span id="898"> 898</span> +<span id="899"> 899</span> +<span id="900"> 900</span> +<span id="901"> 901</span> +<span id="902"> 902</span> +<span id="903"> 903</span> +<span id="904"> 904</span> +<span id="905"> 905</span> +<span id="906"> 906</span> +<span id="907"> 907</span> +<span id="908"> 908</span> +<span id="909"> 909</span> +<span id="910"> 910</span> +<span id="911"> 911</span> +<span id="912"> 912</span> +<span id="913"> 913</span> +<span id="914"> 914</span> +<span id="915"> 915</span> +<span id="916"> 916</span> +<span id="917"> 917</span> +<span id="918"> 918</span> +<span id="919"> 919</span> +<span id="920"> 920</span> +<span id="921"> 921</span> +<span id="922"> 922</span> +<span id="923"> 923</span> +<span id="924"> 924</span> +<span id="925"> 925</span> +<span id="926"> 926</span> +<span id="927"> 927</span> +<span id="928"> 928</span> +<span id="929"> 929</span> +<span id="930"> 930</span> +<span id="931"> 931</span> +<span id="932"> 932</span> +<span id="933"> 933</span> +<span id="934"> 934</span> +<span id="935"> 935</span> +<span id="936"> 936</span> +<span id="937"> 937</span> +<span id="938"> 938</span> +<span id="939"> 939</span> +<span id="940"> 940</span> +<span id="941"> 941</span> +<span id="942"> 942</span> +<span id="943"> 943</span> +<span id="944"> 944</span> +<span id="945"> 945</span> +<span id="946"> 946</span> +<span id="947"> 947</span> +<span id="948"> 948</span> +<span id="949"> 949</span> +<span id="950"> 950</span> +<span id="951"> 951</span> +<span id="952"> 952</span> +<span id="953"> 953</span> +<span id="954"> 954</span> +<span id="955"> 955</span> +<span id="956"> 956</span> +<span id="957"> 957</span> +<span id="958"> 958</span> +<span id="959"> 959</span> +<span id="960"> 960</span> +<span id="961"> 961</span> +<span id="962"> 962</span> +<span id="963"> 963</span> +<span id="964"> 964</span> +<span id="965"> 965</span> +<span id="966"> 966</span> +<span id="967"> 967</span> +<span id="968"> 968</span> +<span id="969"> 969</span> +<span id="970"> 970</span> +<span id="971"> 971</span> +<span id="972"> 972</span> +<span id="973"> 973</span> +<span id="974"> 974</span> +<span id="975"> 975</span> +<span id="976"> 976</span> +<span id="977"> 977</span> +<span id="978"> 978</span> +<span id="979"> 979</span> +<span id="980"> 980</span> +<span id="981"> 981</span> +<span id="982"> 982</span> +<span id="983"> 983</span> +<span id="984"> 984</span> +<span id="985"> 985</span> +<span id="986"> 986</span> +<span id="987"> 987</span> +<span id="988"> 988</span> +<span id="989"> 989</span> +<span id="990"> 990</span> +<span id="991"> 991</span> +<span id="992"> 992</span> +<span id="993"> 993</span> +<span id="994"> 994</span> +<span id="995"> 995</span> +<span id="996"> 996</span> +<span id="997"> 997</span> +<span id="998"> 998</span> +<span id="999"> 999</span> +<span id="1000">1000</span> +<span id="1001">1001</span> +<span id="1002">1002</span> +<span id="1003">1003</span> +<span id="1004">1004</span> +<span id="1005">1005</span> +<span id="1006">1006</span> +<span id="1007">1007</span> +<span id="1008">1008</span> +<span id="1009">1009</span> +<span id="1010">1010</span> +<span id="1011">1011</span> +<span id="1012">1012</span> +<span id="1013">1013</span> +<span id="1014">1014</span> +<span id="1015">1015</span> +<span id="1016">1016</span> +<span id="1017">1017</span> +<span id="1018">1018</span> +<span id="1019">1019</span> +<span id="1020">1020</span> +<span id="1021">1021</span> +<span id="1022">1022</span> +<span id="1023">1023</span> +<span id="1024">1024</span> +<span id="1025">1025</span> +<span id="1026">1026</span> +<span id="1027">1027</span> +<span id="1028">1028</span> +<span id="1029">1029</span> +<span id="1030">1030</span> +<span id="1031">1031</span> +<span id="1032">1032</span> +<span id="1033">1033</span> +<span id="1034">1034</span> +<span id="1035">1035</span> +<span id="1036">1036</span> +<span id="1037">1037</span> +<span id="1038">1038</span> +<span id="1039">1039</span> +<span id="1040">1040</span> +<span id="1041">1041</span> +<span id="1042">1042</span> +<span id="1043">1043</span> +<span id="1044">1044</span> +<span id="1045">1045</span> +<span id="1046">1046</span> +<span id="1047">1047</span> +<span id="1048">1048</span> +<span id="1049">1049</span> +<span id="1050">1050</span> +<span id="1051">1051</span> +<span id="1052">1052</span> +<span id="1053">1053</span> +<span id="1054">1054</span> +<span id="1055">1055</span> +<span id="1056">1056</span> +<span id="1057">1057</span> +<span id="1058">1058</span> +<span id="1059">1059</span> +<span id="1060">1060</span> +<span id="1061">1061</span> +<span id="1062">1062</span> +<span id="1063">1063</span> +<span id="1064">1064</span> +<span id="1065">1065</span> +<span id="1066">1066</span> +<span id="1067">1067</span> +<span id="1068">1068</span> +<span id="1069">1069</span> +<span id="1070">1070</span> +<span id="1071">1071</span> +<span id="1072">1072</span> +<span id="1073">1073</span> +<span id="1074">1074</span> +<span id="1075">1075</span> +<span id="1076">1076</span> +<span id="1077">1077</span> +<span id="1078">1078</span> +<span id="1079">1079</span> +<span id="1080">1080</span> +<span id="1081">1081</span> +<span id="1082">1082</span> +<span id="1083">1083</span> +<span id="1084">1084</span> +<span id="1085">1085</span> +<span id="1086">1086</span> +<span id="1087">1087</span> +<span id="1088">1088</span> +<span id="1089">1089</span> +<span id="1090">1090</span> +<span id="1091">1091</span> +<span id="1092">1092</span> +<span id="1093">1093</span> +<span id="1094">1094</span> +<span id="1095">1095</span> +<span id="1096">1096</span> +<span id="1097">1097</span> +<span id="1098">1098</span> +<span id="1099">1099</span> +<span id="1100">1100</span> +<span id="1101">1101</span> +<span id="1102">1102</span> +<span id="1103">1103</span> +<span id="1104">1104</span> +<span id="1105">1105</span> +<span id="1106">1106</span> +<span id="1107">1107</span> +<span id="1108">1108</span> +<span id="1109">1109</span> +<span id="1110">1110</span> +<span id="1111">1111</span> +<span id="1112">1112</span> +<span id="1113">1113</span> +<span id="1114">1114</span> +<span id="1115">1115</span> +<span id="1116">1116</span> +<span id="1117">1117</span> +<span id="1118">1118</span> +<span id="1119">1119</span> +<span id="1120">1120</span> +<span id="1121">1121</span> +<span id="1122">1122</span> +<span id="1123">1123</span> +<span id="1124">1124</span> +<span id="1125">1125</span> +<span id="1126">1126</span> +<span id="1127">1127</span> +<span id="1128">1128</span> +<span id="1129">1129</span> +<span id="1130">1130</span> +<span id="1131">1131</span> +<span id="1132">1132</span> +<span id="1133">1133</span> +<span id="1134">1134</span> +<span id="1135">1135</span> +<span id="1136">1136</span> +<span id="1137">1137</span> +<span id="1138">1138</span> +<span id="1139">1139</span> +<span id="1140">1140</span> +<span id="1141">1141</span> +<span id="1142">1142</span> +<span id="1143">1143</span> +<span id="1144">1144</span> +<span id="1145">1145</span> +<span id="1146">1146</span> +<span id="1147">1147</span> +<span id="1148">1148</span> +<span id="1149">1149</span> +<span id="1150">1150</span> +<span id="1151">1151</span> +<span id="1152">1152</span> +<span id="1153">1153</span> +<span id="1154">1154</span> +<span id="1155">1155</span> +<span id="1156">1156</span> +<span id="1157">1157</span> +<span id="1158">1158</span> +<span id="1159">1159</span> +<span id="1160">1160</span> +<span id="1161">1161</span> +<span id="1162">1162</span> +<span id="1163">1163</span> +<span id="1164">1164</span> +<span id="1165">1165</span> +<span id="1166">1166</span> +<span id="1167">1167</span> +<span id="1168">1168</span> +<span id="1169">1169</span> +<span id="1170">1170</span> +<span id="1171">1171</span> +<span id="1172">1172</span> +<span id="1173">1173</span> +<span id="1174">1174</span> +<span id="1175">1175</span> +<span id="1176">1176</span> +<span id="1177">1177</span> +<span id="1178">1178</span> +<span id="1179">1179</span> +<span id="1180">1180</span> +<span id="1181">1181</span> +<span id="1182">1182</span> +<span id="1183">1183</span> +<span id="1184">1184</span> +<span id="1185">1185</span> +<span id="1186">1186</span> +<span id="1187">1187</span> +<span id="1188">1188</span> +<span id="1189">1189</span> +<span id="1190">1190</span> +<span id="1191">1191</span> +<span id="1192">1192</span> +<span id="1193">1193</span> +<span id="1194">1194</span> +<span id="1195">1195</span> +<span id="1196">1196</span> +<span id="1197">1197</span> +<span id="1198">1198</span> +<span id="1199">1199</span> +<span id="1200">1200</span> +<span id="1201">1201</span> +<span id="1202">1202</span> +<span id="1203">1203</span> +<span id="1204">1204</span> +<span id="1205">1205</span> +<span id="1206">1206</span> +<span id="1207">1207</span> +<span id="1208">1208</span> +<span id="1209">1209</span> +<span id="1210">1210</span> +<span id="1211">1211</span> +<span id="1212">1212</span> +<span id="1213">1213</span> +<span id="1214">1214</span> +<span id="1215">1215</span> +<span id="1216">1216</span> +<span id="1217">1217</span> +<span id="1218">1218</span> +<span id="1219">1219</span> +<span id="1220">1220</span> +<span id="1221">1221</span> +<span id="1222">1222</span> +<span id="1223">1223</span> +<span id="1224">1224</span> +<span id="1225">1225</span> +<span id="1226">1226</span> +<span id="1227">1227</span> +<span id="1228">1228</span> +<span id="1229">1229</span> +<span id="1230">1230</span> +<span id="1231">1231</span> +<span id="1232">1232</span> +<span id="1233">1233</span> +<span id="1234">1234</span> +<span id="1235">1235</span> +<span id="1236">1236</span> +<span id="1237">1237</span> +<span id="1238">1238</span> +<span id="1239">1239</span> +<span id="1240">1240</span> +<span id="1241">1241</span> +<span id="1242">1242</span> +<span id="1243">1243</span> +<span id="1244">1244</span> +<span id="1245">1245</span> +<span id="1246">1246</span> +<span id="1247">1247</span> +<span id="1248">1248</span> +<span id="1249">1249</span> +<span id="1250">1250</span> +<span id="1251">1251</span> +<span id="1252">1252</span> +<span id="1253">1253</span> +<span id="1254">1254</span> +<span id="1255">1255</span> +<span id="1256">1256</span> +<span id="1257">1257</span> +<span id="1258">1258</span> +<span id="1259">1259</span> +<span id="1260">1260</span> +<span id="1261">1261</span> +<span id="1262">1262</span> +<span id="1263">1263</span> +<span id="1264">1264</span> +<span id="1265">1265</span> +<span id="1266">1266</span> +<span id="1267">1267</span> +<span id="1268">1268</span> +<span id="1269">1269</span> +<span id="1270">1270</span> +<span id="1271">1271</span> +<span id="1272">1272</span> +<span id="1273">1273</span> +<span id="1274">1274</span> +<span id="1275">1275</span> +<span id="1276">1276</span> +<span id="1277">1277</span> +<span id="1278">1278</span> +<span id="1279">1279</span> +<span id="1280">1280</span> +<span id="1281">1281</span> +<span id="1282">1282</span> +<span id="1283">1283</span> +<span id="1284">1284</span> +<span id="1285">1285</span> +<span id="1286">1286</span> +<span id="1287">1287</span> +<span id="1288">1288</span> +<span id="1289">1289</span> +<span id="1290">1290</span> +<span id="1291">1291</span> +<span id="1292">1292</span> +<span id="1293">1293</span> +<span id="1294">1294</span> +<span id="1295">1295</span> +<span id="1296">1296</span> +<span id="1297">1297</span> +<span id="1298">1298</span> +<span id="1299">1299</span> +<span id="1300">1300</span> +<span id="1301">1301</span> +<span id="1302">1302</span> +<span id="1303">1303</span> +<span id="1304">1304</span> +<span id="1305">1305</span> +<span id="1306">1306</span> +<span id="1307">1307</span> +<span id="1308">1308</span> +<span id="1309">1309</span> +<span id="1310">1310</span> +<span id="1311">1311</span> +<span id="1312">1312</span> +<span id="1313">1313</span> +<span id="1314">1314</span> +<span id="1315">1315</span> +<span id="1316">1316</span> +<span id="1317">1317</span> +<span id="1318">1318</span> +<span id="1319">1319</span> +<span id="1320">1320</span> +<span id="1321">1321</span> +<span id="1322">1322</span> +<span id="1323">1323</span> +<span id="1324">1324</span> +<span id="1325">1325</span> +<span id="1326">1326</span> +<span id="1327">1327</span> +<span id="1328">1328</span> +<span id="1329">1329</span> +<span id="1330">1330</span> +<span id="1331">1331</span> +<span id="1332">1332</span> +<span id="1333">1333</span> +<span id="1334">1334</span> +<span id="1335">1335</span> +<span id="1336">1336</span> +<span id="1337">1337</span> +<span id="1338">1338</span> +<span id="1339">1339</span> +<span id="1340">1340</span> +<span id="1341">1341</span> +<span id="1342">1342</span> +<span id="1343">1343</span> +<span id="1344">1344</span> +<span id="1345">1345</span> +<span id="1346">1346</span> +<span id="1347">1347</span> +<span id="1348">1348</span> +<span id="1349">1349</span> +<span id="1350">1350</span> +<span id="1351">1351</span> +<span id="1352">1352</span> +<span id="1353">1353</span> +<span id="1354">1354</span> +<span id="1355">1355</span> +<span id="1356">1356</span> +<span id="1357">1357</span> +<span id="1358">1358</span> +<span id="1359">1359</span> +<span id="1360">1360</span> +<span id="1361">1361</span> +<span id="1362">1362</span> +<span id="1363">1363</span> +<span id="1364">1364</span> +<span id="1365">1365</span> +<span id="1366">1366</span> +<span id="1367">1367</span> +<span id="1368">1368</span> +<span id="1369">1369</span> +<span id="1370">1370</span> +<span id="1371">1371</span> +<span id="1372">1372</span> +<span id="1373">1373</span> +<span id="1374">1374</span> +<span id="1375">1375</span> +<span id="1376">1376</span> +<span id="1377">1377</span> +<span id="1378">1378</span> +<span id="1379">1379</span> +<span id="1380">1380</span> +<span id="1381">1381</span> +<span id="1382">1382</span> +<span id="1383">1383</span> +<span id="1384">1384</span> +<span id="1385">1385</span> +<span id="1386">1386</span> +<span id="1387">1387</span> +<span id="1388">1388</span> +<span id="1389">1389</span> +<span id="1390">1390</span> +<span id="1391">1391</span> +<span id="1392">1392</span> +<span id="1393">1393</span> +<span id="1394">1394</span> +<span id="1395">1395</span> +<span id="1396">1396</span> +<span id="1397">1397</span> +<span id="1398">1398</span> +<span id="1399">1399</span> +<span id="1400">1400</span> +<span id="1401">1401</span> +<span id="1402">1402</span> +<span id="1403">1403</span> +<span id="1404">1404</span> +<span id="1405">1405</span> +<span id="1406">1406</span> +<span id="1407">1407</span> +<span id="1408">1408</span> +<span id="1409">1409</span> +<span id="1410">1410</span> +<span id="1411">1411</span> +<span id="1412">1412</span> +<span id="1413">1413</span> +<span id="1414">1414</span> +<span id="1415">1415</span> +<span id="1416">1416</span> +<span id="1417">1417</span> +<span id="1418">1418</span> +<span id="1419">1419</span> +<span id="1420">1420</span> +<span id="1421">1421</span> +<span id="1422">1422</span> +<span id="1423">1423</span> +<span id="1424">1424</span> +<span id="1425">1425</span> +<span id="1426">1426</span> +<span id="1427">1427</span> +<span id="1428">1428</span> +<span id="1429">1429</span> +<span id="1430">1430</span> +<span id="1431">1431</span> +<span id="1432">1432</span> +<span id="1433">1433</span> +<span id="1434">1434</span> +<span id="1435">1435</span> +<span id="1436">1436</span> +<span id="1437">1437</span> +<span id="1438">1438</span> +<span id="1439">1439</span> +<span id="1440">1440</span> +<span id="1441">1441</span> +<span id="1442">1442</span> +<span id="1443">1443</span> +<span id="1444">1444</span> +<span id="1445">1445</span> +<span id="1446">1446</span> +<span id="1447">1447</span> +<span id="1448">1448</span> +<span id="1449">1449</span> +<span id="1450">1450</span> +<span id="1451">1451</span> +<span id="1452">1452</span> +<span id="1453">1453</span> +<span id="1454">1454</span> +<span id="1455">1455</span> +<span id="1456">1456</span> +<span id="1457">1457</span> +<span id="1458">1458</span> +<span id="1459">1459</span> +<span id="1460">1460</span> +<span id="1461">1461</span> +<span id="1462">1462</span> +<span id="1463">1463</span> +<span id="1464">1464</span> +<span id="1465">1465</span> +<span id="1466">1466</span> +<span id="1467">1467</span> +<span id="1468">1468</span> +<span id="1469">1469</span> +<span id="1470">1470</span> +<span id="1471">1471</span> +<span id="1472">1472</span> +<span id="1473">1473</span> +<span id="1474">1474</span> +<span id="1475">1475</span> +<span id="1476">1476</span> +<span id="1477">1477</span> +<span id="1478">1478</span> +<span id="1479">1479</span> +<span id="1480">1480</span> +<span id="1481">1481</span> +<span id="1482">1482</span> +<span id="1483">1483</span> +<span id="1484">1484</span> +<span id="1485">1485</span> +<span id="1486">1486</span> +<span id="1487">1487</span> +<span id="1488">1488</span> +<span id="1489">1489</span> +<span id="1490">1490</span> +<span id="1491">1491</span> +<span id="1492">1492</span> +<span id="1493">1493</span> +<span id="1494">1494</span> +<span id="1495">1495</span> +<span id="1496">1496</span> +<span id="1497">1497</span> +<span id="1498">1498</span> +<span id="1499">1499</span> +<span id="1500">1500</span> +<span id="1501">1501</span> +<span id="1502">1502</span> +<span id="1503">1503</span> +<span id="1504">1504</span> +<span id="1505">1505</span> +<span id="1506">1506</span> +<span id="1507">1507</span> +<span id="1508">1508</span> +<span id="1509">1509</span> +<span id="1510">1510</span> +<span id="1511">1511</span> +<span id="1512">1512</span> +<span id="1513">1513</span> +<span id="1514">1514</span> +<span id="1515">1515</span> +<span id="1516">1516</span> +<span id="1517">1517</span> +<span id="1518">1518</span> +<span id="1519">1519</span> +<span id="1520">1520</span> +<span id="1521">1521</span> +<span id="1522">1522</span> +<span id="1523">1523</span> +<span id="1524">1524</span> +<span id="1525">1525</span> +<span id="1526">1526</span> +<span id="1527">1527</span> +<span id="1528">1528</span> +<span id="1529">1529</span> +<span id="1530">1530</span> +<span id="1531">1531</span> +<span id="1532">1532</span> +<span id="1533">1533</span> +<span id="1534">1534</span> +<span id="1535">1535</span> +<span id="1536">1536</span> +<span id="1537">1537</span> +<span id="1538">1538</span> +<span id="1539">1539</span> +<span id="1540">1540</span> +<span id="1541">1541</span> +<span id="1542">1542</span> +<span id="1543">1543</span> +<span id="1544">1544</span> +<span id="1545">1545</span> +<span id="1546">1546</span> +<span id="1547">1547</span> +<span id="1548">1548</span> +<span id="1549">1549</span> +<span id="1550">1550</span> +<span id="1551">1551</span> +<span id="1552">1552</span> +<span id="1553">1553</span> +<span id="1554">1554</span> +<span id="1555">1555</span> +<span id="1556">1556</span> +<span id="1557">1557</span> +<span id="1558">1558</span> +<span id="1559">1559</span> +<span id="1560">1560</span> +<span id="1561">1561</span> +<span id="1562">1562</span> +<span id="1563">1563</span> +<span id="1564">1564</span> +<span id="1565">1565</span> +<span id="1566">1566</span> +<span id="1567">1567</span> +<span id="1568">1568</span> +<span id="1569">1569</span> +<span id="1570">1570</span> +<span id="1571">1571</span> +<span id="1572">1572</span> +<span id="1573">1573</span> +<span id="1574">1574</span> +<span id="1575">1575</span> +<span id="1576">1576</span> +<span id="1577">1577</span> +<span id="1578">1578</span> +<span id="1579">1579</span> +<span id="1580">1580</span> +<span id="1581">1581</span> +<span id="1582">1582</span> +<span id="1583">1583</span> +<span id="1584">1584</span> +<span id="1585">1585</span> +<span id="1586">1586</span> +<span id="1587">1587</span> +<span id="1588">1588</span> +<span id="1589">1589</span> +<span id="1590">1590</span> +<span id="1591">1591</span> +<span id="1592">1592</span> +<span id="1593">1593</span> +<span id="1594">1594</span> +<span id="1595">1595</span> +<span id="1596">1596</span> +<span id="1597">1597</span> +<span id="1598">1598</span> +<span id="1599">1599</span> +<span id="1600">1600</span> +<span id="1601">1601</span> +<span id="1602">1602</span> +<span id="1603">1603</span> +<span id="1604">1604</span> +<span id="1605">1605</span> +<span id="1606">1606</span> +<span id="1607">1607</span> +<span id="1608">1608</span> +<span id="1609">1609</span> +<span id="1610">1610</span> +<span id="1611">1611</span> +<span id="1612">1612</span> +<span id="1613">1613</span> +<span id="1614">1614</span> +<span id="1615">1615</span> +<span id="1616">1616</span> +<span id="1617">1617</span> +<span id="1618">1618</span> +<span id="1619">1619</span> +<span id="1620">1620</span> +<span id="1621">1621</span> +<span id="1622">1622</span> +<span id="1623">1623</span> +<span id="1624">1624</span> +<span id="1625">1625</span> +<span id="1626">1626</span> +<span id="1627">1627</span> +<span id="1628">1628</span> +<span id="1629">1629</span> +<span id="1630">1630</span> +<span id="1631">1631</span> +<span id="1632">1632</span> +<span id="1633">1633</span> +<span id="1634">1634</span> +<span id="1635">1635</span> +<span id="1636">1636</span> +<span id="1637">1637</span> +<span id="1638">1638</span> +<span id="1639">1639</span> +<span id="1640">1640</span> +<span id="1641">1641</span> +<span id="1642">1642</span> +<span id="1643">1643</span> +<span id="1644">1644</span> +<span id="1645">1645</span> +<span id="1646">1646</span> +<span id="1647">1647</span> +<span id="1648">1648</span> +<span id="1649">1649</span> +<span id="1650">1650</span> +<span id="1651">1651</span> +<span id="1652">1652</span> +<span id="1653">1653</span> +<span id="1654">1654</span> +<span id="1655">1655</span> +<span id="1656">1656</span> +<span id="1657">1657</span> +<span id="1658">1658</span> +<span id="1659">1659</span> +<span id="1660">1660</span> +<span id="1661">1661</span> +<span id="1662">1662</span> +<span id="1663">1663</span> +<span id="1664">1664</span> +<span id="1665">1665</span> +<span id="1666">1666</span> +<span id="1667">1667</span> +<span id="1668">1668</span> +<span id="1669">1669</span> +<span id="1670">1670</span> +<span id="1671">1671</span> +<span id="1672">1672</span> +<span id="1673">1673</span> +<span id="1674">1674</span> +<span id="1675">1675</span> +<span id="1676">1676</span> +<span id="1677">1677</span> +<span id="1678">1678</span> +<span id="1679">1679</span> +<span id="1680">1680</span> +<span id="1681">1681</span> +<span id="1682">1682</span> +<span id="1683">1683</span> +<span id="1684">1684</span> +<span id="1685">1685</span> +<span id="1686">1686</span> +<span id="1687">1687</span> +<span id="1688">1688</span> +<span id="1689">1689</span> +<span id="1690">1690</span> +<span id="1691">1691</span> +<span id="1692">1692</span> +<span id="1693">1693</span> +<span id="1694">1694</span> +<span id="1695">1695</span> +<span id="1696">1696</span> +<span id="1697">1697</span> +<span id="1698">1698</span> +<span id="1699">1699</span> +<span id="1700">1700</span> +<span id="1701">1701</span> +<span id="1702">1702</span> +<span id="1703">1703</span> +<span id="1704">1704</span> +<span id="1705">1705</span> +<span id="1706">1706</span> +<span id="1707">1707</span> +<span id="1708">1708</span> +<span id="1709">1709</span> +<span id="1710">1710</span> +<span id="1711">1711</span> +<span id="1712">1712</span> +<span id="1713">1713</span> +<span id="1714">1714</span> +<span id="1715">1715</span> +<span id="1716">1716</span> +<span id="1717">1717</span> +<span id="1718">1718</span> +<span id="1719">1719</span> +<span id="1720">1720</span> +<span id="1721">1721</span> +<span id="1722">1722</span> +<span id="1723">1723</span> +<span id="1724">1724</span> +<span id="1725">1725</span> +<span id="1726">1726</span> +<span id="1727">1727</span> +<span id="1728">1728</span> +<span id="1729">1729</span> +<span id="1730">1730</span> +<span id="1731">1731</span> +<span id="1732">1732</span> +<span id="1733">1733</span> +<span id="1734">1734</span> +<span id="1735">1735</span> +<span id="1736">1736</span> +<span id="1737">1737</span> +<span id="1738">1738</span> +<span id="1739">1739</span> +<span id="1740">1740</span> +<span id="1741">1741</span> +<span id="1742">1742</span> +<span id="1743">1743</span> +<span id="1744">1744</span> +<span id="1745">1745</span> +<span id="1746">1746</span> +<span id="1747">1747</span> +<span id="1748">1748</span> +<span id="1749">1749</span> +<span id="1750">1750</span> +<span id="1751">1751</span> +<span id="1752">1752</span> +<span id="1753">1753</span> +<span id="1754">1754</span> +<span id="1755">1755</span> +<span id="1756">1756</span> +<span id="1757">1757</span> +<span id="1758">1758</span> +<span id="1759">1759</span> +<span id="1760">1760</span> +<span id="1761">1761</span> +<span id="1762">1762</span> +<span id="1763">1763</span> +<span id="1764">1764</span> +<span id="1765">1765</span> +<span id="1766">1766</span> +<span id="1767">1767</span> +<span id="1768">1768</span> +<span id="1769">1769</span> +<span id="1770">1770</span> +<span id="1771">1771</span> +<span id="1772">1772</span> +<span id="1773">1773</span> +<span id="1774">1774</span> +<span id="1775">1775</span> +<span id="1776">1776</span> +<span id="1777">1777</span> +<span id="1778">1778</span> +<span id="1779">1779</span> +<span id="1780">1780</span> +<span id="1781">1781</span> +<span id="1782">1782</span> +<span id="1783">1783</span> +<span id="1784">1784</span> +<span id="1785">1785</span> +<span id="1786">1786</span> +<span id="1787">1787</span> +<span id="1788">1788</span> +<span id="1789">1789</span> +<span id="1790">1790</span> +<span id="1791">1791</span> +<span id="1792">1792</span> +<span id="1793">1793</span> +<span id="1794">1794</span> +<span id="1795">1795</span> +<span id="1796">1796</span> +<span id="1797">1797</span> +<span id="1798">1798</span> +<span id="1799">1799</span> +<span id="1800">1800</span> +<span id="1801">1801</span> +<span id="1802">1802</span> +<span id="1803">1803</span> +<span id="1804">1804</span> +<span id="1805">1805</span> +<span id="1806">1806</span> +<span id="1807">1807</span> +<span id="1808">1808</span> +<span id="1809">1809</span> +<span id="1810">1810</span> +<span id="1811">1811</span> +<span id="1812">1812</span> +<span id="1813">1813</span> +<span id="1814">1814</span> +<span id="1815">1815</span> +<span id="1816">1816</span> +<span id="1817">1817</span> +<span id="1818">1818</span> +<span id="1819">1819</span> +<span id="1820">1820</span> +<span id="1821">1821</span> +<span id="1822">1822</span> +<span id="1823">1823</span> +<span id="1824">1824</span> +<span id="1825">1825</span> +<span id="1826">1826</span> +<span id="1827">1827</span> +<span id="1828">1828</span> +<span id="1829">1829</span> +<span id="1830">1830</span> +<span id="1831">1831</span> +<span id="1832">1832</span> +<span id="1833">1833</span> +<span id="1834">1834</span> +<span id="1835">1835</span> +<span id="1836">1836</span> +<span id="1837">1837</span> +<span id="1838">1838</span> +<span id="1839">1839</span> +<span id="1840">1840</span> +<span id="1841">1841</span> +<span id="1842">1842</span> +<span id="1843">1843</span> +<span id="1844">1844</span> +<span id="1845">1845</span> +<span id="1846">1846</span> +<span id="1847">1847</span> +<span id="1848">1848</span> +<span id="1849">1849</span> +<span id="1850">1850</span> +<span id="1851">1851</span> +<span id="1852">1852</span> +<span id="1853">1853</span> +<span id="1854">1854</span> +<span id="1855">1855</span> +<span id="1856">1856</span> +<span id="1857">1857</span> +<span id="1858">1858</span> +<span id="1859">1859</span> +<span id="1860">1860</span> +<span id="1861">1861</span> +<span id="1862">1862</span> +<span id="1863">1863</span> +<span id="1864">1864</span> +<span id="1865">1865</span> +<span id="1866">1866</span> +<span id="1867">1867</span> +<span id="1868">1868</span> +<span id="1869">1869</span> +<span id="1870">1870</span> +<span id="1871">1871</span> +<span id="1872">1872</span> +<span id="1873">1873</span> +<span id="1874">1874</span> +<span id="1875">1875</span> +<span id="1876">1876</span> +<span id="1877">1877</span> +<span id="1878">1878</span> +<span id="1879">1879</span> +<span id="1880">1880</span> +<span id="1881">1881</span> +<span id="1882">1882</span> +<span id="1883">1883</span> +<span id="1884">1884</span> +<span id="1885">1885</span> +<span id="1886">1886</span> +<span id="1887">1887</span> +<span id="1888">1888</span> +<span id="1889">1889</span> +<span id="1890">1890</span> +<span id="1891">1891</span> +<span id="1892">1892</span> +<span id="1893">1893</span> +<span id="1894">1894</span> +<span id="1895">1895</span> +<span id="1896">1896</span> +<span id="1897">1897</span> +<span id="1898">1898</span> +<span id="1899">1899</span> +<span id="1900">1900</span> +<span id="1901">1901</span> +<span id="1902">1902</span> +<span id="1903">1903</span> +<span id="1904">1904</span> +<span id="1905">1905</span> +<span id="1906">1906</span> +<span id="1907">1907</span> +<span id="1908">1908</span> +<span id="1909">1909</span> +<span id="1910">1910</span> +<span id="1911">1911</span> +<span id="1912">1912</span> +<span id="1913">1913</span> +<span id="1914">1914</span> +<span id="1915">1915</span> +<span id="1916">1916</span> +<span id="1917">1917</span> +<span id="1918">1918</span> +<span id="1919">1919</span> +<span id="1920">1920</span> +<span id="1921">1921</span> +<span id="1922">1922</span> +<span id="1923">1923</span> +<span id="1924">1924</span> +<span id="1925">1925</span> +<span id="1926">1926</span> +<span id="1927">1927</span> +<span id="1928">1928</span> +<span id="1929">1929</span> +<span id="1930">1930</span> +<span id="1931">1931</span> +<span id="1932">1932</span> +<span id="1933">1933</span> +<span id="1934">1934</span> +<span id="1935">1935</span> +<span id="1936">1936</span> +<span id="1937">1937</span> +<span id="1938">1938</span> +<span id="1939">1939</span> +<span id="1940">1940</span> +<span id="1941">1941</span> +<span id="1942">1942</span> +<span id="1943">1943</span> +<span id="1944">1944</span> +<span id="1945">1945</span> +<span id="1946">1946</span> +<span id="1947">1947</span> +<span id="1948">1948</span> +<span id="1949">1949</span> +<span id="1950">1950</span> +<span id="1951">1951</span> +<span id="1952">1952</span> +<span id="1953">1953</span> +<span id="1954">1954</span> +<span id="1955">1955</span> +<span id="1956">1956</span> +<span id="1957">1957</span> +<span id="1958">1958</span> +<span id="1959">1959</span> +<span id="1960">1960</span> +<span id="1961">1961</span> +<span id="1962">1962</span> +<span id="1963">1963</span> +<span id="1964">1964</span> +<span id="1965">1965</span> +<span id="1966">1966</span> +<span id="1967">1967</span> +<span id="1968">1968</span> +<span id="1969">1969</span> +<span id="1970">1970</span> +<span id="1971">1971</span> +<span id="1972">1972</span> +<span id="1973">1973</span> +<span id="1974">1974</span> +<span id="1975">1975</span> +<span id="1976">1976</span> +<span id="1977">1977</span> +<span id="1978">1978</span> +<span id="1979">1979</span> +<span id="1980">1980</span> +<span id="1981">1981</span> +<span id="1982">1982</span> +<span id="1983">1983</span> +<span id="1984">1984</span> +<span id="1985">1985</span> +<span id="1986">1986</span> +<span id="1987">1987</span> +<span id="1988">1988</span> +<span id="1989">1989</span> +<span id="1990">1990</span> +<span id="1991">1991</span> +<span id="1992">1992</span> +<span id="1993">1993</span> +<span id="1994">1994</span> +<span id="1995">1995</span> +<span id="1996">1996</span> +<span id="1997">1997</span> +<span id="1998">1998</span> +<span id="1999">1999</span> +<span id="2000">2000</span> +<span id="2001">2001</span> +<span id="2002">2002</span> +<span id="2003">2003</span> +<span id="2004">2004</span> +<span id="2005">2005</span> +<span id="2006">2006</span> +<span id="2007">2007</span> +<span id="2008">2008</span> +<span id="2009">2009</span> +<span id="2010">2010</span> +<span id="2011">2011</span> +<span id="2012">2012</span> +<span id="2013">2013</span> +<span id="2014">2014</span> +<span id="2015">2015</span> +<span id="2016">2016</span> +<span id="2017">2017</span> +<span id="2018">2018</span> +<span id="2019">2019</span> +<span id="2020">2020</span> +<span id="2021">2021</span> +<span id="2022">2022</span> +<span id="2023">2023</span> +<span id="2024">2024</span> +<span id="2025">2025</span> +<span id="2026">2026</span> +<span id="2027">2027</span> +<span id="2028">2028</span> +<span id="2029">2029</span> +<span id="2030">2030</span> +<span id="2031">2031</span> +<span id="2032">2032</span> +<span id="2033">2033</span> +<span id="2034">2034</span> +<span id="2035">2035</span> +<span id="2036">2036</span> +<span id="2037">2037</span> +<span id="2038">2038</span> +<span id="2039">2039</span> +<span id="2040">2040</span> +<span id="2041">2041</span> +<span id="2042">2042</span> +<span id="2043">2043</span> +<span id="2044">2044</span> +<span id="2045">2045</span> +<span id="2046">2046</span> +<span id="2047">2047</span> +<span id="2048">2048</span> +<span id="2049">2049</span> +<span id="2050">2050</span> +<span id="2051">2051</span> +<span id="2052">2052</span> +<span id="2053">2053</span> +<span id="2054">2054</span> +<span id="2055">2055</span> +<span id="2056">2056</span> +<span id="2057">2057</span> +<span id="2058">2058</span> +<span id="2059">2059</span> +<span id="2060">2060</span> +<span id="2061">2061</span> +<span id="2062">2062</span> +<span id="2063">2063</span> +<span id="2064">2064</span> +<span id="2065">2065</span> +<span id="2066">2066</span> +<span id="2067">2067</span> +<span id="2068">2068</span> +<span id="2069">2069</span> +<span id="2070">2070</span> +<span id="2071">2071</span> +<span id="2072">2072</span> +<span id="2073">2073</span> +<span id="2074">2074</span> +<span id="2075">2075</span> +<span id="2076">2076</span> +<span id="2077">2077</span> +<span id="2078">2078</span> +<span id="2079">2079</span> +<span id="2080">2080</span> +<span id="2081">2081</span> +<span id="2082">2082</span> +<span id="2083">2083</span> +<span id="2084">2084</span> +<span id="2085">2085</span> +<span id="2086">2086</span> +<span id="2087">2087</span> +<span id="2088">2088</span> +<span id="2089">2089</span> +<span id="2090">2090</span> +<span id="2091">2091</span> +<span id="2092">2092</span> +<span id="2093">2093</span> +<span id="2094">2094</span> +<span id="2095">2095</span> +<span id="2096">2096</span> +<span id="2097">2097</span> +<span id="2098">2098</span> +<span id="2099">2099</span> +<span id="2100">2100</span> +<span id="2101">2101</span> +<span id="2102">2102</span> +<span id="2103">2103</span> +<span id="2104">2104</span> +<span id="2105">2105</span> +<span id="2106">2106</span> +<span id="2107">2107</span> +<span id="2108">2108</span> +<span id="2109">2109</span> +<span id="2110">2110</span> +<span id="2111">2111</span> +<span id="2112">2112</span> +<span id="2113">2113</span> +<span id="2114">2114</span> +<span id="2115">2115</span> +<span id="2116">2116</span> +<span id="2117">2117</span> +<span id="2118">2118</span> +<span id="2119">2119</span> +<span id="2120">2120</span> +<span id="2121">2121</span> +<span id="2122">2122</span> +<span id="2123">2123</span> +<span id="2124">2124</span> +<span id="2125">2125</span> +<span id="2126">2126</span> +<span id="2127">2127</span> +<span id="2128">2128</span> +<span id="2129">2129</span> +<span id="2130">2130</span> +<span id="2131">2131</span> +<span id="2132">2132</span> +<span id="2133">2133</span> +<span id="2134">2134</span> +<span id="2135">2135</span> +<span id="2136">2136</span> +<span id="2137">2137</span> +<span id="2138">2138</span> +<span id="2139">2139</span> +<span id="2140">2140</span> +<span id="2141">2141</span> +<span id="2142">2142</span> +<span id="2143">2143</span> +<span id="2144">2144</span> +<span id="2145">2145</span> +<span id="2146">2146</span> +<span id="2147">2147</span> +<span id="2148">2148</span> +<span id="2149">2149</span> +<span id="2150">2150</span> +<span id="2151">2151</span> +<span id="2152">2152</span> +<span id="2153">2153</span> +<span id="2154">2154</span> +<span id="2155">2155</span> +<span id="2156">2156</span> +<span id="2157">2157</span> +<span id="2158">2158</span> +<span id="2159">2159</span> +<span id="2160">2160</span> +<span id="2161">2161</span> +<span id="2162">2162</span> +<span id="2163">2163</span> +<span id="2164">2164</span> +<span id="2165">2165</span> +<span id="2166">2166</span> +<span id="2167">2167</span> +<span id="2168">2168</span> +<span id="2169">2169</span> +<span id="2170">2170</span> +<span id="2171">2171</span> +<span id="2172">2172</span> +<span id="2173">2173</span> +<span id="2174">2174</span> +<span id="2175">2175</span> +<span id="2176">2176</span> +<span id="2177">2177</span> +<span id="2178">2178</span> +<span id="2179">2179</span> +<span id="2180">2180</span> +<span id="2181">2181</span> +<span id="2182">2182</span> +<span id="2183">2183</span> +<span id="2184">2184</span> +<span id="2185">2185</span> +<span id="2186">2186</span> +<span id="2187">2187</span> +<span id="2188">2188</span> +<span id="2189">2189</span> +<span id="2190">2190</span> +<span id="2191">2191</span> +<span id="2192">2192</span> +<span id="2193">2193</span> +<span id="2194">2194</span> +<span id="2195">2195</span> +<span id="2196">2196</span> +<span id="2197">2197</span> +<span id="2198">2198</span> +<span id="2199">2199</span> +<span id="2200">2200</span> +<span id="2201">2201</span> +<span id="2202">2202</span> +<span id="2203">2203</span> +<span id="2204">2204</span> +<span id="2205">2205</span> +<span id="2206">2206</span> +<span id="2207">2207</span> +<span id="2208">2208</span> +<span id="2209">2209</span> +<span id="2210">2210</span> +<span id="2211">2211</span> +<span id="2212">2212</span> +<span id="2213">2213</span> +<span id="2214">2214</span> +<span id="2215">2215</span> +<span id="2216">2216</span> +<span id="2217">2217</span> +<span id="2218">2218</span> +<span id="2219">2219</span> +<span id="2220">2220</span> +<span id="2221">2221</span> +<span id="2222">2222</span> +<span id="2223">2223</span> +<span id="2224">2224</span> +<span id="2225">2225</span> +<span id="2226">2226</span> +<span id="2227">2227</span> +<span id="2228">2228</span> +<span id="2229">2229</span> +<span id="2230">2230</span> +<span id="2231">2231</span> +<span id="2232">2232</span> +<span id="2233">2233</span> +<span id="2234">2234</span> +<span id="2235">2235</span> +<span id="2236">2236</span> +<span id="2237">2237</span> +<span id="2238">2238</span> +<span id="2239">2239</span> +<span id="2240">2240</span> +<span id="2241">2241</span> +<span id="2242">2242</span> +<span id="2243">2243</span> +<span id="2244">2244</span> +<span id="2245">2245</span> +<span id="2246">2246</span> +<span id="2247">2247</span> +<span id="2248">2248</span> +<span id="2249">2249</span> +<span id="2250">2250</span> +<span id="2251">2251</span> +<span id="2252">2252</span> +<span id="2253">2253</span> +<span id="2254">2254</span> +<span id="2255">2255</span> +<span id="2256">2256</span> +<span id="2257">2257</span> +<span id="2258">2258</span> +<span id="2259">2259</span> +<span id="2260">2260</span> +<span id="2261">2261</span> +<span id="2262">2262</span> +<span id="2263">2263</span> +<span id="2264">2264</span> +<span id="2265">2265</span> +<span id="2266">2266</span> +<span id="2267">2267</span> +<span id="2268">2268</span> +<span id="2269">2269</span> +<span id="2270">2270</span> +<span id="2271">2271</span> +<span id="2272">2272</span> +<span id="2273">2273</span> +<span id="2274">2274</span> +<span id="2275">2275</span> +<span id="2276">2276</span> +<span id="2277">2277</span> +<span id="2278">2278</span> +<span id="2279">2279</span> +<span id="2280">2280</span> +<span id="2281">2281</span> +<span id="2282">2282</span> +<span id="2283">2283</span> +<span id="2284">2284</span> +<span id="2285">2285</span> +<span id="2286">2286</span> +<span id="2287">2287</span> +<span id="2288">2288</span> +<span id="2289">2289</span> +<span id="2290">2290</span> +<span id="2291">2291</span> +<span id="2292">2292</span> +<span id="2293">2293</span> +<span id="2294">2294</span> +<span id="2295">2295</span> +<span id="2296">2296</span> +<span id="2297">2297</span> +<span id="2298">2298</span> +<span id="2299">2299</span> +<span id="2300">2300</span> +<span id="2301">2301</span> +<span id="2302">2302</span> +<span id="2303">2303</span> +<span id="2304">2304</span> +<span id="2305">2305</span> +<span id="2306">2306</span> +<span id="2307">2307</span> +<span id="2308">2308</span> +<span id="2309">2309</span> +<span id="2310">2310</span> +<span id="2311">2311</span> +<span id="2312">2312</span> +<span id="2313">2313</span> +<span id="2314">2314</span> +<span id="2315">2315</span> +<span id="2316">2316</span> +<span id="2317">2317</span> +<span id="2318">2318</span> +<span id="2319">2319</span> +<span id="2320">2320</span> +<span id="2321">2321</span> +<span id="2322">2322</span> +<span id="2323">2323</span> +<span id="2324">2324</span> +<span id="2325">2325</span> +<span id="2326">2326</span> +<span id="2327">2327</span> +</pre><pre class='rust '> +<span class='comment'>// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT</span> +<span class='comment'>// file at the top-level directory of this distribution and at</span> +<span class='comment'>// http://rust-lang.org/COPYRIGHT.</span> +<span class='comment'>//</span> +<span class='comment'>// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or</span> +<span class='comment'>// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license</span> +<span class='comment'>// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your</span> +<span class='comment'>// option. This file may not be copied, modified, or distributed</span> +<span class='comment'>// except according to those terms.</span> + +<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>cmp</span>::{<span class='ident'>max</span>, <span class='ident'>min</span>}; + +<span class='kw'>use</span> <span class='ident'>unicode</span>::<span class='ident'>regex</span>::<span class='ident'>UNICODE_CLASSES</span>; + +<span class='kw'>use</span> { + <span class='ident'>Expr</span>, <span class='ident'>Repeater</span>, <span class='ident'>CharClass</span>, <span class='ident'>ClassRange</span>, <span class='ident'>CaptureIndex</span>, <span class='ident'>CaptureName</span>, + <span class='ident'>Error</span>, <span class='ident'>ErrorKind</span>, <span class='prelude-ty'>Result</span>, +}; + +<span class='doccomment'>/// Parser state.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Keeps the entire input in memory and maintains a cursor (char offset).</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// It also keeps an expression stack, which is responsible for managing</span> +<span class='doccomment'>/// grouped expressions and flag state.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Parser</span> { + <span class='ident'>chars</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>char</span><span class='op'>></span>, + <span class='ident'>chari</span>: <span class='ident'>usize</span>, + <span class='ident'>stack</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Build</span><span class='op'>></span>, + <span class='ident'>caps</span>: <span class='ident'>usize</span>, + <span class='ident'>names</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span>, <span class='comment'>// to check for duplicates</span> + <span class='ident'>flags</span>: <span class='ident'>Flags</span>, +} + +<span class='doccomment'>/// An empheral type for representing the expression stack.</span> +<span class='doccomment'>///</span> +<span class='doccomment'>/// Everything on the stack is either a regular expression or a marker</span> +<span class='doccomment'>/// indicating the opening of a group (possibly non-capturing). The opening</span> +<span class='doccomment'>/// of a group copies the current flag state, which is reset on the parser</span> +<span class='doccomment'>/// state once the group closes.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>)]</span> +<span class='kw'>enum</span> <span class='ident'>Build</span> { + <span class='ident'>Expr</span>(<span class='ident'>Expr</span>), + <span class='ident'>LeftParen</span> { + <span class='ident'>i</span>: <span class='ident'>CaptureIndex</span>, + <span class='ident'>name</span>: <span class='ident'>CaptureName</span>, + <span class='ident'>chari</span>: <span class='ident'>usize</span>, + <span class='ident'>old_flags</span>: <span class='ident'>Flags</span>, + }, +} + +<span class='doccomment'>/// Flag state.</span> +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>, <span class='ident'>Copy</span>, <span class='ident'>Debug</span>)]</span> +<span class='kw'>struct</span> <span class='ident'>Flags</span> { + <span class='ident'>casei</span>: <span class='ident'>bool</span>, + <span class='ident'>multi</span>: <span class='ident'>bool</span>, + <span class='ident'>dotnl</span>: <span class='ident'>bool</span>, + <span class='ident'>swap_greed</span>: <span class='ident'>bool</span>, + <span class='ident'>ignore_space</span>: <span class='ident'>bool</span>, +} + +<span class='comment'>// Primary expression parsing routines.</span> +<span class='kw'>impl</span> <span class='ident'>Parser</span> { + <span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>parse</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Expr</span><span class='op'>></span> { + <span class='ident'>Parser</span> { + <span class='ident'>chars</span>: <span class='ident'>s</span>.<span class='ident'>chars</span>().<span class='ident'>collect</span>(), + <span class='ident'>chari</span>: <span class='number'>0</span>, + <span class='ident'>stack</span>: <span class='macro'>vec</span><span class='macro'>!</span>[], + <span class='ident'>caps</span>: <span class='number'>0</span>, + <span class='ident'>names</span>: <span class='macro'>vec</span><span class='macro'>!</span>[], + <span class='ident'>flags</span>: <span class='ident'>Flags</span> { + <span class='ident'>casei</span>: <span class='boolval'>false</span>, + <span class='ident'>multi</span>: <span class='boolval'>false</span>, + <span class='ident'>dotnl</span>: <span class='boolval'>false</span>, + <span class='ident'>swap_greed</span>: <span class='boolval'>false</span>, + <span class='ident'>ignore_space</span>: <span class='boolval'>false</span>, + }, + }.<span class='ident'>parse_expr</span>() + } + + <span class='comment'>// Top-level expression parser.</span> + <span class='comment'>//</span> + <span class='comment'>// Starts at the beginning of the input and consumes until either the end</span> + <span class='comment'>// of input or an error.</span> + <span class='kw'>fn</span> <span class='ident'>parse_expr</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Expr</span><span class='op'>></span> { + <span class='kw'>while</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>eof</span>() { + <span class='kw'>let</span> <span class='ident'>build_expr</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>cur</span>() { + <span class='string'>'\\'</span> <span class='op'>=></span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>parse_escape</span>()), + <span class='string'>'|'</span> <span class='op'>=></span> { <span class='kw'>let</span> <span class='ident'>e</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>alternate</span>()); <span class='self'>self</span>.<span class='ident'>bump</span>(); <span class='ident'>e</span> } + <span class='string'>'?'</span> <span class='op'>=></span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>parse_simple_repeat</span>(<span class='ident'>Repeater</span>::<span class='ident'>ZeroOrOne</span>)), + <span class='string'>'*'</span> <span class='op'>=></span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>parse_simple_repeat</span>(<span class='ident'>Repeater</span>::<span class='ident'>ZeroOrMore</span>)), + <span class='string'>'+'</span> <span class='op'>=></span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>parse_simple_repeat</span>(<span class='ident'>Repeater</span>::<span class='ident'>OneOrMore</span>)), + <span class='string'>'{'</span> <span class='op'>=></span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>parse_counted_repeat</span>()), + <span class='string'>'['</span> <span class='op'>=></span> <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>maybe_parse_ascii</span>() { + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>parse_class</span>()), + <span class='prelude-val'>Some</span>(<span class='ident'>cls</span>) <span class='op'>=></span> <span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>cls</span>)), + }, + <span class='string'>'^'</span> <span class='op'>=></span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>multi</span> { + <span class='self'>self</span>.<span class='ident'>parse_one</span>(<span class='ident'>Expr</span>::<span class='ident'>StartLine</span>) + } <span class='kw'>else</span> { + <span class='self'>self</span>.<span class='ident'>parse_one</span>(<span class='ident'>Expr</span>::<span class='ident'>StartText</span>) + } + } + <span class='string'>'$'</span> <span class='op'>=></span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>multi</span> { + <span class='self'>self</span>.<span class='ident'>parse_one</span>(<span class='ident'>Expr</span>::<span class='ident'>EndLine</span>) + } <span class='kw'>else</span> { + <span class='self'>self</span>.<span class='ident'>parse_one</span>(<span class='ident'>Expr</span>::<span class='ident'>EndText</span>) + } + } + <span class='string'>'.'</span> <span class='op'>=></span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>dotnl</span> { + <span class='self'>self</span>.<span class='ident'>parse_one</span>(<span class='ident'>Expr</span>::<span class='ident'>AnyChar</span>) + } <span class='kw'>else</span> { + <span class='self'>self</span>.<span class='ident'>parse_one</span>(<span class='ident'>Expr</span>::<span class='ident'>AnyCharNoNL</span>) + } + } + <span class='string'>'('</span> <span class='op'>=></span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>parse_group</span>()), + <span class='string'>')'</span> <span class='op'>=></span> { + <span class='kw'>let</span> (<span class='ident'>old_flags</span>, <span class='ident'>e</span>) <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>close_paren</span>()); + <span class='self'>self</span>.<span class='ident'>bump</span>(); + <span class='self'>self</span>.<span class='ident'>flags</span> <span class='op'>=</span> <span class='ident'>old_flags</span>; + <span class='ident'>e</span> + } + _ <span class='op'>=></span> <span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Literal</span> { + <span class='ident'>chars</span>: <span class='macro'>vec</span><span class='macro'>!</span>[<span class='self'>self</span>.<span class='ident'>bump</span>()], + <span class='ident'>casei</span>: <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>casei</span>, + }), + }; + <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>build_expr</span>.<span class='ident'>is_empty</span>() { + <span class='kw'>let</span> <span class='ident'>build_expr</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>maybe_class_case_fold</span>(<span class='ident'>build_expr</span>); + <span class='self'>self</span>.<span class='ident'>stack</span>.<span class='ident'>push</span>(<span class='ident'>build_expr</span>); + } + } + <span class='self'>self</span>.<span class='ident'>finish_concat</span>() + } + + <span class='comment'>// Parses an escape sequence, e.g., \Ax</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `\`</span> + <span class='comment'>// End: `x`</span> + <span class='kw'>fn</span> <span class='ident'>parse_escape</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Build</span><span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>bump</span>(); + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>eof</span>() { + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedEscapeEof</span>)); + } + <span class='kw'>let</span> <span class='ident'>c</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>cur</span>(); + <span class='kw'>if</span> <span class='ident'>is_punct</span>(<span class='ident'>c</span>) { + <span class='kw'>return</span> <span class='prelude-val'>Ok</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Literal</span> { + <span class='ident'>chars</span>: <span class='macro'>vec</span><span class='macro'>!</span>[<span class='self'>self</span>.<span class='ident'>bump</span>()], + <span class='ident'>casei</span>: <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>casei</span>, + })); + } + + <span class='kw'>fn</span> <span class='ident'>lit</span>(<span class='ident'>c</span>: <span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>Build</span> { + <span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Literal</span> { <span class='ident'>chars</span>: <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>c</span>], <span class='ident'>casei</span>: <span class='boolval'>false</span> }) + } + <span class='kw'>match</span> <span class='ident'>c</span> { + <span class='string'>'a'</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>bump</span>(); <span class='prelude-val'>Ok</span>(<span class='ident'>lit</span>(<span class='string'>'\x07'</span>)) } + <span class='string'>'f'</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>bump</span>(); <span class='prelude-val'>Ok</span>(<span class='ident'>lit</span>(<span class='string'>'\x0C'</span>)) } + <span class='string'>'t'</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>bump</span>(); <span class='prelude-val'>Ok</span>(<span class='ident'>lit</span>(<span class='string'>'\t'</span>)) } + <span class='string'>'n'</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>bump</span>(); <span class='prelude-val'>Ok</span>(<span class='ident'>lit</span>(<span class='string'>'\n'</span>)) } + <span class='string'>'r'</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>bump</span>(); <span class='prelude-val'>Ok</span>(<span class='ident'>lit</span>(<span class='string'>'\r'</span>)) } + <span class='string'>'v'</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>bump</span>(); <span class='prelude-val'>Ok</span>(<span class='ident'>lit</span>(<span class='string'>'\x0B'</span>)) } + <span class='string'>'A'</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>bump</span>(); <span class='prelude-val'>Ok</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>StartText</span>)) } + <span class='string'>'z'</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>bump</span>(); <span class='prelude-val'>Ok</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>EndText</span>)) } + <span class='string'>'b'</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>bump</span>(); <span class='prelude-val'>Ok</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>WordBoundary</span>)) } + <span class='string'>'B'</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>bump</span>(); <span class='prelude-val'>Ok</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>NotWordBoundary</span>)) } + <span class='string'>'0'</span><span class='op'>|</span><span class='string'>'1'</span><span class='op'>|</span><span class='string'>'2'</span><span class='op'>|</span><span class='string'>'3'</span><span class='op'>|</span><span class='string'>'4'</span><span class='op'>|</span><span class='string'>'5'</span><span class='op'>|</span><span class='string'>'6'</span><span class='op'>|</span><span class='string'>'7'</span> <span class='op'>=></span> <span class='self'>self</span>.<span class='ident'>parse_octal</span>(), + <span class='string'>'x'</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>bump</span>(); <span class='self'>self</span>.<span class='ident'>parse_hex</span>() } + <span class='string'>'p'</span><span class='op'>|</span><span class='string'>'P'</span> <span class='op'>=></span> { + <span class='self'>self</span>.<span class='ident'>bump</span>(); + <span class='self'>self</span>.<span class='ident'>parse_unicode_class</span>(<span class='ident'>c</span> <span class='op'>==</span> <span class='string'>'P'</span>) + .<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>cls</span><span class='op'>|</span> <span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>cls</span>))) + } + <span class='string'>'d'</span><span class='op'>|</span><span class='string'>'s'</span><span class='op'>|</span><span class='string'>'w'</span><span class='op'>|</span><span class='string'>'D'</span><span class='op'>|</span><span class='string'>'S'</span><span class='op'>|</span><span class='string'>'W'</span> <span class='op'>=></span> { + <span class='self'>self</span>.<span class='ident'>bump</span>(); + <span class='prelude-val'>Ok</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='self'>self</span>.<span class='ident'>parse_perl_class</span>(<span class='ident'>c</span>)))) + } + <span class='ident'>c</span> <span class='op'>=></span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>UnrecognizedEscape</span>(<span class='ident'>c</span>))), + } + } + + <span class='comment'>// Parses a group, e.g., `(abc)`.</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `(`</span> + <span class='comment'>// End: `a`</span> + <span class='comment'>//</span> + <span class='comment'>// A more interesting example, `(?P<foo>abc)`.</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `(`</span> + <span class='comment'>// End: `a`</span> + <span class='kw'>fn</span> <span class='ident'>parse_group</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Build</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>chari</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>chari</span>; + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>name</span>: <span class='ident'>CaptureName</span> <span class='op'>=</span> <span class='prelude-val'>None</span>; + <span class='self'>self</span>.<span class='ident'>bump</span>(); + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>bump_if</span>(<span class='string'>"?P<"</span>) { + <span class='kw'>let</span> <span class='ident'>n</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>parse_group_name</span>()); + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>names</span>.<span class='ident'>iter</span>().<span class='ident'>any</span>(<span class='op'>|</span><span class='ident'>n2</span><span class='op'>|</span> <span class='ident'>n2</span> <span class='op'>==</span> <span class='kw-2'>&</span><span class='ident'>n</span>) { + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>DuplicateCaptureName</span>(<span class='ident'>n</span>))); + } + <span class='self'>self</span>.<span class='ident'>names</span>.<span class='ident'>push</span>(<span class='ident'>n</span>.<span class='ident'>clone</span>()); + <span class='ident'>name</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>n</span>); + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>bump_if</span>(<span class='string'>"?"</span>) { + <span class='comment'>// This can never be capturing. It's either setting flags for</span> + <span class='comment'>// the current group, or it's opening a non-capturing group or</span> + <span class='comment'>// it's opening a group with a specific set of flags (which is</span> + <span class='comment'>// also non-capturing).</span> + <span class='comment'>// Anything else is an error.</span> + <span class='kw'>return</span> <span class='self'>self</span>.<span class='ident'>parse_group_flags</span>(<span class='ident'>chari</span>); + } + <span class='self'>self</span>.<span class='ident'>caps</span> <span class='op'>=</span> <span class='ident'>checkadd</span>(<span class='self'>self</span>.<span class='ident'>caps</span>, <span class='number'>1</span>); + <span class='prelude-val'>Ok</span>(<span class='ident'>Build</span>::<span class='ident'>LeftParen</span> { + <span class='ident'>i</span>: <span class='prelude-val'>Some</span>(<span class='self'>self</span>.<span class='ident'>caps</span>), + <span class='ident'>name</span>: <span class='ident'>name</span>, + <span class='ident'>chari</span>: <span class='ident'>chari</span>, + <span class='ident'>old_flags</span>: <span class='self'>self</span>.<span class='ident'>flags</span>, <span class='comment'>// no flags changed if we're here</span> + }) + } + + <span class='comment'>// Parses flags (inline or grouped), e.g., `(?s-i:abc)`.</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `s`</span> + <span class='comment'>// End: `a`</span> + <span class='comment'>//</span> + <span class='comment'>// Another example, `(?s-i)a`.</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `s`</span> + <span class='comment'>// End: `a`</span> + <span class='kw'>fn</span> <span class='ident'>parse_group_flags</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>opening_chari</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Build</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>old_flags</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>flags</span>; + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>sign</span> <span class='op'>=</span> <span class='boolval'>true</span>; + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>saw_flag</span> <span class='op'>=</span> <span class='boolval'>false</span>; + <span class='kw'>loop</span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>eof</span>() { + <span class='comment'>// e.g., (?i</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedFlagEof</span>)); + } + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>cur</span>() { + <span class='string'>'i'</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>casei</span> <span class='op'>=</span> <span class='ident'>sign</span>; <span class='ident'>saw_flag</span> <span class='op'>=</span> <span class='boolval'>true</span> } + <span class='string'>'m'</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>multi</span> <span class='op'>=</span> <span class='ident'>sign</span>; <span class='ident'>saw_flag</span> <span class='op'>=</span> <span class='boolval'>true</span> } + <span class='string'>'s'</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>dotnl</span> <span class='op'>=</span> <span class='ident'>sign</span>; <span class='ident'>saw_flag</span> <span class='op'>=</span> <span class='boolval'>true</span> } + <span class='string'>'U'</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>swap_greed</span> <span class='op'>=</span> <span class='ident'>sign</span>; <span class='ident'>saw_flag</span> <span class='op'>=</span> <span class='boolval'>true</span> } + <span class='string'>'x'</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>ignore_space</span> <span class='op'>=</span> <span class='ident'>sign</span>; <span class='ident'>saw_flag</span> <span class='op'>=</span> <span class='boolval'>true</span> } + <span class='string'>'-'</span> <span class='op'>=></span> { + <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>sign</span> { + <span class='comment'>// e.g., (?-i-s)</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>DoubleFlagNegation</span>)); + } + <span class='ident'>sign</span> <span class='op'>=</span> <span class='boolval'>false</span>; + <span class='ident'>saw_flag</span> <span class='op'>=</span> <span class='boolval'>false</span>; + } + <span class='string'>')'</span> <span class='op'>=></span> { + <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>saw_flag</span> { + <span class='comment'>// e.g., (?)</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>EmptyFlagNegation</span>)); + } + <span class='comment'>// At this point, we're just changing the flags inside</span> + <span class='comment'>// the current group, which means the old flags have</span> + <span class='comment'>// been saved elsewhere. Our modifications in place are</span> + <span class='comment'>// okey dokey!</span> + <span class='comment'>//</span> + <span class='comment'>// This particular flag expression only has a stateful</span> + <span class='comment'>// impact on a regex's AST, so nothing gets explicitly</span> + <span class='comment'>// added.</span> + <span class='self'>self</span>.<span class='ident'>bump</span>(); + <span class='kw'>return</span> <span class='prelude-val'>Ok</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Empty</span>)); + } + <span class='string'>':'</span> <span class='op'>=></span> { + <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>sign</span> <span class='op'>&&</span> <span class='op'>!</span><span class='ident'>saw_flag</span> { + <span class='comment'>// e.g., (?i-:a)</span> + <span class='comment'>// Note that if there's no negation, it's OK not</span> + <span class='comment'>// to see flag, because you end up with a regular</span> + <span class='comment'>// non-capturing group: `(?:a)`.</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>EmptyFlagNegation</span>)); + } + <span class='self'>self</span>.<span class='ident'>bump</span>(); + <span class='kw'>return</span> <span class='prelude-val'>Ok</span>(<span class='ident'>Build</span>::<span class='ident'>LeftParen</span> { + <span class='ident'>i</span>: <span class='prelude-val'>None</span>, + <span class='ident'>name</span>: <span class='prelude-val'>None</span>, + <span class='ident'>chari</span>: <span class='ident'>opening_chari</span>, + <span class='ident'>old_flags</span>: <span class='ident'>old_flags</span>, + }); + } + <span class='comment'>// e.g., (?z:a)</span> + <span class='ident'>c</span> <span class='op'>=></span> <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>UnrecognizedFlag</span>(<span class='ident'>c</span>))), + } + <span class='self'>self</span>.<span class='ident'>bump</span>(); + } + } + + <span class='comment'>// Parses a group name, e.g., `foo` in `(?P<foo>abc)`.</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `f`</span> + <span class='comment'>// End: `a`</span> + <span class='kw'>fn</span> <span class='ident'>parse_group_name</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>name</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>new</span>(); + <span class='kw'>while</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>eof</span>() <span class='op'>&&</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>peek_is</span>(<span class='string'>'>'</span>) { + <span class='ident'>name</span>.<span class='ident'>push</span>(<span class='self'>self</span>.<span class='ident'>bump</span>()); + } + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>eof</span>() { + <span class='comment'>// e.g., (?P<a</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>UnclosedCaptureName</span>(<span class='ident'>name</span>))); + } + <span class='kw'>let</span> <span class='ident'>all_valid</span> <span class='op'>=</span> <span class='ident'>name</span>.<span class='ident'>chars</span>().<span class='ident'>all</span>(<span class='ident'>is_valid_capture_char</span>); + <span class='kw'>match</span> <span class='ident'>name</span>.<span class='ident'>chars</span>().<span class='ident'>next</span>() { + <span class='comment'>// e.g., (?P<>a)</span> + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>EmptyCaptureName</span>)), + <span class='prelude-val'>Some</span>(<span class='ident'>c</span>) <span class='kw'>if</span> (<span class='ident'>c</span> <span class='op'>>=</span> <span class='string'>'0'</span> <span class='op'>&&</span> <span class='ident'>c</span> <span class='op'><=</span> <span class='string'>'9'</span>) <span class='op'>||</span> <span class='op'>!</span><span class='ident'>all_valid</span> <span class='op'>=></span> { + <span class='comment'>// e.g., (?P<a#>x)</span> + <span class='comment'>// e.g., (?P<1a>x)</span> + <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>InvalidCaptureName</span>(<span class='ident'>name</span>))) + } + _ <span class='op'>=></span> { + <span class='self'>self</span>.<span class='ident'>bump</span>(); <span class='comment'>// for `>`</span> + <span class='prelude-val'>Ok</span>(<span class='ident'>name</span>) + } + } + } + + <span class='comment'>// Parses a counted repeition operator, e.g., `a{2,4}?z`.</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `{`</span> + <span class='comment'>// End: `z`</span> + <span class='kw'>fn</span> <span class='ident'>parse_counted_repeat</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Build</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>e</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>pop</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>RepeaterExpectsExpr</span>)); <span class='comment'>// e.g., ({5}</span> + <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>e</span>.<span class='ident'>can_repeat</span>() { + <span class='comment'>// e.g., a*{5}</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>RepeaterUnexpectedExpr</span>(<span class='ident'>e</span>))); + } + <span class='self'>self</span>.<span class='ident'>bump</span>(); + <span class='kw'>let</span> <span class='ident'>min</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>parse_decimal</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>!=</span> <span class='string'>','</span> <span class='op'>&&</span> <span class='ident'>c</span> <span class='op'>!=</span> <span class='string'>'}'</span>)); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>max_opt</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>min</span>); + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>bump_if</span>(<span class='string'>','</span>) { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>peek_is</span>(<span class='string'>'}'</span>) { + <span class='ident'>max_opt</span> <span class='op'>=</span> <span class='prelude-val'>None</span>; + } <span class='kw'>else</span> { + <span class='kw'>let</span> <span class='ident'>max</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>parse_decimal</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>!=</span> <span class='string'>'}'</span>)); + <span class='kw'>if</span> <span class='ident'>min</span> <span class='op'>></span> <span class='ident'>max</span> { + <span class='comment'>// e.g., a{2,1}</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>InvalidRepeatRange</span> { + <span class='ident'>min</span>: <span class='ident'>min</span>, + <span class='ident'>max</span>: <span class='ident'>max</span>, + })); + } + <span class='ident'>max_opt</span> <span class='op'>=</span> <span class='prelude-val'>Some</span>(<span class='ident'>max</span>); + } + } + <span class='kw'>if</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>bump_if</span>(<span class='string'>'}'</span>) { + <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>UnclosedRepeat</span>)) + } <span class='kw'>else</span> { + <span class='prelude-val'>Ok</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>e</span>), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>Range</span> { <span class='ident'>min</span>: <span class='ident'>min</span>, <span class='ident'>max</span>: <span class='ident'>max_opt</span> }, + <span class='ident'>greedy</span>: <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>bump_if</span>(<span class='string'>'?'</span>) <span class='op'>^</span> <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>swap_greed</span>, + })) + } + } + + <span class='comment'>// Parses a simple repetition operator, e.g., `a+?z`.</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `+`</span> + <span class='comment'>// End: `z`</span> + <span class='comment'>//</span> + <span class='comment'>// N.B. "simple" in this context means "not min/max repetition",</span> + <span class='comment'>// e.g., `a{1,2}`.</span> + <span class='kw'>fn</span> <span class='ident'>parse_simple_repeat</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>rep</span>: <span class='ident'>Repeater</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Build</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>e</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>pop</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>RepeaterExpectsExpr</span>)); <span class='comment'>// e.g., (*</span> + <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>e</span>.<span class='ident'>can_repeat</span>() { + <span class='comment'>// e.g., a**</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>RepeaterUnexpectedExpr</span>(<span class='ident'>e</span>))); + } + <span class='self'>self</span>.<span class='ident'>bump</span>(); + <span class='prelude-val'>Ok</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>e</span>), + <span class='ident'>r</span>: <span class='ident'>rep</span>, + <span class='ident'>greedy</span>: <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>bump_if</span>(<span class='string'>'?'</span>) <span class='op'>^</span> <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>swap_greed</span>, + })) + } + + <span class='comment'>// Parses a decimal number until the given character, e.g., `a{123,456}`.</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `1`</span> + <span class='comment'>// End: `,` (where `until == ','`)</span> + <span class='kw'>fn</span> <span class='ident'>parse_decimal</span><span class='op'><</span><span class='ident'>B</span>: <span class='ident'>Bumpable</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>until</span>: <span class='ident'>B</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>u32</span><span class='op'>></span> { + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>bump_get</span>(<span class='ident'>until</span>) { + <span class='comment'>// e.g., a{}</span> + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>MissingBase10</span>)), + <span class='prelude-val'>Some</span>(<span class='ident'>n</span>) <span class='op'>=></span> { + <span class='comment'>// e.g., a{xyz</span> + <span class='comment'>// e.g., a{9999999999}</span> + <span class='kw'>let</span> <span class='ident'>n</span> <span class='op'>=</span> <span class='ident'>n</span>.<span class='ident'>trim</span>(); + <span class='ident'>u32</span>::<span class='ident'>from_str_radix</span>(<span class='ident'>n</span>, <span class='number'>10</span>) + .<span class='ident'>map_err</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>InvalidBase10</span>(<span class='ident'>n</span>.<span class='ident'>into</span>()))) + } + } + } + + <span class='comment'>// Parses an octal number, up to 3 digits, e.g., `a\123b`</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `1`</span> + <span class='comment'>// End: `b`</span> + <span class='kw'>fn</span> <span class='ident'>parse_octal</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Build</span><span class='op'>></span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>char</span>; + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>i</span> <span class='op'>=</span> <span class='number'>0</span>; <span class='comment'>// counter for limiting octal to 3 digits.</span> + <span class='kw'>let</span> <span class='ident'>n</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>bump_get</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> { <span class='ident'>i</span> <span class='op'>+=</span> <span class='number'>1</span>; <span class='ident'>i</span> <span class='op'><=</span> <span class='number'>3</span> <span class='op'>&&</span> <span class='ident'>c</span> <span class='op'>>=</span> <span class='string'>'0'</span> <span class='op'>&&</span> <span class='ident'>c</span> <span class='op'><=</span> <span class='string'>'7'</span> }) + .<span class='ident'>expect</span>(<span class='string'>"octal string"</span>); <span class='comment'>// guaranteed at least 1 digit</span> + <span class='comment'>// I think both of the following unwraps are impossible to fail.</span> + <span class='comment'>// We limit it to a three digit octal number, which maxes out at</span> + <span class='comment'>// `0777` or `511` in decimal. Since all digits are in `0...7`, we'll</span> + <span class='comment'>// always have a valid `u32` number. Moreover, since all numbers in</span> + <span class='comment'>// the range `0...511` are valid Unicode scalar values, it will always</span> + <span class='comment'>// be a valid `char`.</span> + <span class='comment'>//</span> + <span class='comment'>// Hence, we `unwrap` with reckless abandon.</span> + <span class='kw'>let</span> <span class='ident'>n</span> <span class='op'>=</span> <span class='ident'>u32</span>::<span class='ident'>from_str_radix</span>(<span class='kw-2'>&</span><span class='ident'>n</span>, <span class='number'>8</span>).<span class='ident'>ok</span>().<span class='ident'>expect</span>(<span class='string'>"valid octal number"</span>); + <span class='prelude-val'>Ok</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Literal</span> { + <span class='ident'>chars</span>: <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>char</span>::<span class='ident'>from_u32</span>(<span class='ident'>n</span>).<span class='ident'>expect</span>(<span class='string'>"Unicode scalar value"</span>)], + <span class='ident'>casei</span>: <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>casei</span>, + })) + } + + <span class='comment'>// Parses a hex number, e.g., `a\x5ab`.</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `5`</span> + <span class='comment'>// End: `b`</span> + <span class='comment'>//</span> + <span class='comment'>// And also, `a\x{2603}b`.</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `{`</span> + <span class='comment'>// End: `b`</span> + <span class='kw'>fn</span> <span class='ident'>parse_hex</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Build</span><span class='op'>></span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>bump_if</span>(<span class='string'>'{'</span>) { + <span class='self'>self</span>.<span class='ident'>parse_hex_many_digits</span>() + } <span class='kw'>else</span> { + <span class='self'>self</span>.<span class='ident'>parse_hex_two_digits</span>() + } + } + + <span class='comment'>// Parses a many-digit hex number, e.g., `a\x{2603}b`.</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `2`</span> + <span class='comment'>// End: `b`</span> + <span class='kw'>fn</span> <span class='ident'>parse_hex_many_digits</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Build</span><span class='op'>></span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>char</span>; + + <span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>bump_get</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>!=</span> <span class='string'>'}'</span>).<span class='ident'>unwrap_or</span>(<span class='string'>""</span>.<span class='ident'>into</span>()); + <span class='kw'>let</span> <span class='ident'>n</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>u32</span>::<span class='ident'>from_str_radix</span>(<span class='kw-2'>&</span><span class='ident'>s</span>, <span class='number'>16</span>) + .<span class='ident'>map_err</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>InvalidBase16</span>(<span class='ident'>s</span>)))); + <span class='kw'>let</span> <span class='ident'>c</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>char</span>::<span class='ident'>from_u32</span>(<span class='ident'>n</span>) + .<span class='ident'>ok_or</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>InvalidScalarValue</span>(<span class='ident'>n</span>)))); + <span class='kw'>if</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>bump_if</span>(<span class='string'>'}'</span>) { + <span class='comment'>// e.g., a\x{d</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>UnclosedHex</span>)); + } + <span class='prelude-val'>Ok</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Literal</span> { + <span class='ident'>chars</span>: <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>c</span>], + <span class='ident'>casei</span>: <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>casei</span>, + })) + } + + <span class='comment'>// Parses a two-digit hex number, e.g., `a\x5ab`.</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `5`</span> + <span class='comment'>// End: `b`</span> + <span class='kw'>fn</span> <span class='ident'>parse_hex_two_digits</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Build</span><span class='op'>></span> { + <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>char</span>; + + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>i</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>bump_get</span>(<span class='op'>|</span>_<span class='op'>|</span> { <span class='ident'>i</span> <span class='op'>+=</span> <span class='number'>1</span>; <span class='ident'>i</span> <span class='op'><=</span> <span class='number'>2</span> }).<span class='ident'>unwrap_or</span>(<span class='string'>""</span>.<span class='ident'>into</span>()); + <span class='kw'>if</span> <span class='ident'>s</span>.<span class='ident'>len</span>() <span class='op'><</span> <span class='number'>2</span> { + <span class='comment'>// e.g., a\x</span> + <span class='comment'>// e.g., a\xf</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedTwoDigitHexEof</span>)); + } + <span class='kw'>let</span> <span class='ident'>n</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>u32</span>::<span class='ident'>from_str_radix</span>(<span class='kw-2'>&</span><span class='ident'>s</span>, <span class='number'>16</span>) + .<span class='ident'>map_err</span>(<span class='op'>|</span>_<span class='op'>|</span> <span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>InvalidBase16</span>(<span class='ident'>s</span>)))); + <span class='prelude-val'>Ok</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Literal</span> { + <span class='comment'>// Because 0...255 are all valid Unicode scalar values.</span> + <span class='ident'>chars</span>: <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>char</span>::<span class='ident'>from_u32</span>(<span class='ident'>n</span>).<span class='ident'>expect</span>(<span class='string'>"Unicode scalar value"</span>)], + <span class='ident'>casei</span>: <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>casei</span>, + })) + } + + <span class='comment'>// Parses a character class, e.g., `[^a-zA-Z0-9]+`.</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `[`</span> + <span class='comment'>// End: `+`</span> + <span class='kw'>fn</span> <span class='ident'>parse_class</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Build</span><span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>bump</span>(); + <span class='kw'>let</span> <span class='ident'>negated</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>bump_if</span>(<span class='string'>'^'</span>); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>class</span> <span class='op'>=</span> <span class='ident'>CharClass</span>::<span class='ident'>empty</span>(); + <span class='kw'>while</span> <span class='self'>self</span>.<span class='ident'>bump_if</span>(<span class='string'>'-'</span>) { + <span class='ident'>class</span>.<span class='ident'>ranges</span>.<span class='ident'>push</span>(<span class='ident'>ClassRange</span>::<span class='ident'>one</span>(<span class='string'>'-'</span>)); + } + <span class='kw'>loop</span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>eof</span>() { + <span class='comment'>// e.g., [a</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedClassEof</span>)); + } + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>cur</span>() { + <span class='comment'>// If no ranges have been added, then `]` is the first</span> + <span class='comment'>// character (sans, perhaps, the `^` symbol), so it should</span> + <span class='comment'>// be interpreted as a `]` instead of a closing class bracket.</span> + <span class='string'>']'</span> <span class='kw'>if</span> <span class='ident'>class</span>.<span class='ident'>len</span>() <span class='op'>></span> <span class='number'>0</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>bump</span>(); <span class='kw'>break</span> } + <span class='string'>'['</span> <span class='op'>=></span> <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>maybe_parse_ascii</span>() { + <span class='prelude-val'>Some</span>(<span class='ident'>class2</span>) <span class='op'>=></span> <span class='ident'>class</span>.<span class='ident'>ranges</span>.<span class='ident'>extend</span>(<span class='ident'>class2</span>), + <span class='prelude-val'>None</span> <span class='op'>=></span> { + <span class='self'>self</span>.<span class='ident'>bump</span>(); + <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>parse_class_range</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>class</span>, <span class='string'>'['</span>)) + } + }, + <span class='string'>'\\'</span> <span class='op'>=></span> <span class='kw'>match</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>parse_escape</span>()) { + <span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class2</span>)) <span class='op'>=></span> { + <span class='ident'>class</span>.<span class='ident'>ranges</span>.<span class='ident'>extend</span>(<span class='ident'>class2</span>); + } + <span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Literal</span> { <span class='ident'>chars</span>, .. }) <span class='op'>=></span> { + <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>parse_class_range</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>class</span>, <span class='ident'>chars</span>[<span class='number'>0</span>])); + } + <span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>e</span>) <span class='op'>=></span> { + <span class='kw'>let</span> <span class='ident'>err</span> <span class='op'>=</span> <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidClassEscape</span>(<span class='ident'>e</span>); + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>err</span>)); + } + <span class='comment'>// Because `parse_escape` can never return `LeftParen`.</span> + _ <span class='op'>=></span> <span class='macro'>unreachable</span><span class='macro'>!</span>(), + }, + <span class='ident'>start</span> <span class='op'>=></span> { + <span class='self'>self</span>.<span class='ident'>bump</span>(); + <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>parse_class_range</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>class</span>, <span class='ident'>start</span>)); + } + } + } + <span class='kw'>if</span> <span class='ident'>negated</span> { + <span class='ident'>class</span> <span class='op'>=</span> <span class='ident'>class</span>.<span class='ident'>negate</span>(); + } + <span class='prelude-val'>Ok</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>.<span class='ident'>canonicalize</span>()))) + } + + <span class='comment'>// Parses a single range in a character class.</span> + <span class='comment'>//</span> + <span class='comment'>// Since this is a helper for `parse_class`, its signature sticks out.</span> + <span class='comment'>// Namely, it requires the start character of the range and the char</span> + <span class='comment'>// class to mutate.</span> + <span class='comment'>//</span> + <span class='comment'>// e.g., `[a-z]`</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `-` (with start == `a`)</span> + <span class='comment'>// End: `]`</span> + <span class='kw'>fn</span> <span class='ident'>parse_class_range</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>class</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>CharClass</span>, <span class='ident'>start</span>: <span class='ident'>char</span>) + <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>()<span class='op'>></span> { + <span class='kw'>if</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>bump_if</span>(<span class='string'>'-'</span>) { + <span class='comment'>// Not a range, so just push a singleton range.</span> + <span class='ident'>class</span>.<span class='ident'>ranges</span>.<span class='ident'>push</span>(<span class='ident'>ClassRange</span>::<span class='ident'>one</span>(<span class='ident'>start</span>)); + <span class='kw'>return</span> <span class='prelude-val'>Ok</span>(()); + } + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>eof</span>() { + <span class='comment'>// e.g., [a-</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedClassEof</span>)); + } + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>peek_is</span>(<span class='string'>']'</span>) { + <span class='comment'>// This is the end of the class, so we permit use of `-` as a</span> + <span class='comment'>// regular char (just like we do in the beginning).</span> + <span class='ident'>class</span>.<span class='ident'>ranges</span>.<span class='ident'>push</span>(<span class='ident'>ClassRange</span>::<span class='ident'>one</span>(<span class='ident'>start</span>)); + <span class='ident'>class</span>.<span class='ident'>ranges</span>.<span class='ident'>push</span>(<span class='ident'>ClassRange</span>::<span class='ident'>one</span>(<span class='string'>'-'</span>)); + <span class='kw'>return</span> <span class='prelude-val'>Ok</span>(()); + } + + <span class='comment'>// We have a real range. Just need to check to parse literal and</span> + <span class='comment'>// make sure it's a valid range.</span> + <span class='kw'>let</span> <span class='ident'>end</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>cur</span>() { + <span class='string'>'\\'</span> <span class='op'>=></span> <span class='kw'>match</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='self'>self</span>.<span class='ident'>parse_escape</span>()) { + <span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Literal</span> { <span class='ident'>chars</span>, .. }) <span class='op'>=></span> <span class='ident'>chars</span>[<span class='number'>0</span>], + <span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>e</span>) <span class='op'>=></span> { + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>InvalidClassEscape</span>(<span class='ident'>e</span>))); + } + <span class='comment'>// Because `parse_escape` can never return `LeftParen`.</span> + _ <span class='op'>=></span> <span class='macro'>unreachable</span><span class='macro'>!</span>(), + }, + _ <span class='op'>=></span> <span class='self'>self</span>.<span class='ident'>bump</span>(), + }; + <span class='kw'>if</span> <span class='ident'>end</span> <span class='op'><</span> <span class='ident'>start</span> { + <span class='comment'>// e.g., [z-a]</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>InvalidClassRange</span> { + <span class='ident'>start</span>: <span class='ident'>start</span>, + <span class='ident'>end</span>: <span class='ident'>end</span>, + })); + } + <span class='ident'>class</span>.<span class='ident'>ranges</span>.<span class='ident'>push</span>(<span class='ident'>ClassRange</span>::<span class='ident'>new</span>(<span class='ident'>start</span>, <span class='ident'>end</span>)); + <span class='prelude-val'>Ok</span>(()) + } + + <span class='comment'>// Parses an ASCII class, e.g., `[:alnum:]+`.</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `[`</span> + <span class='comment'>// End: `+`</span> + <span class='comment'>//</span> + <span class='comment'>// Also supports negation, e.g., `[:^alnum:]`.</span> + <span class='comment'>//</span> + <span class='comment'>// This parsing routine is distinct from the others in that it doesn't</span> + <span class='comment'>// actually report any errors. Namely, if it fails, then the parser should</span> + <span class='comment'>// fall back to parsing a regular class.</span> + <span class='comment'>//</span> + <span class='comment'>// This method will only make progress in the parser if it succeeds.</span> + <span class='comment'>// Otherwise, the input remains where it started.</span> + <span class='kw'>fn</span> <span class='ident'>maybe_parse_ascii</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CharClass</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>parse</span>(<span class='ident'>p</span>: <span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>Parser</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CharClass</span><span class='op'>></span> { + <span class='ident'>p</span>.<span class='ident'>bump</span>(); <span class='comment'>// the `[`</span> + <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>p</span>.<span class='ident'>bump_if</span>(<span class='string'>':'</span>) { <span class='kw'>return</span> <span class='prelude-val'>None</span>; } + <span class='kw'>let</span> <span class='ident'>negate</span> <span class='op'>=</span> <span class='ident'>p</span>.<span class='ident'>bump_if</span>(<span class='string'>'^'</span>); + <span class='kw'>let</span> <span class='ident'>name</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='ident'>p</span>.<span class='ident'>bump_get</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>!=</span> <span class='string'>':'</span>) { + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='kw'>return</span> <span class='prelude-val'>None</span>, + <span class='prelude-val'>Some</span>(<span class='ident'>name</span>) <span class='op'>=></span> <span class='ident'>name</span>, + }; + <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>p</span>.<span class='ident'>bump_if</span>(<span class='string'>":]"</span>) { <span class='kw'>return</span> <span class='prelude-val'>None</span>; } + <span class='ident'>ascii_class</span>(<span class='kw-2'>&</span><span class='ident'>name</span>).<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='kw'>if</span> <span class='op'>!</span><span class='ident'>negate</span> { <span class='ident'>c</span> } <span class='kw'>else</span> { <span class='ident'>c</span>.<span class='ident'>negate</span>() }) + } + <span class='kw'>let</span> <span class='ident'>start</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>chari</span>; + <span class='kw'>match</span> <span class='ident'>parse</span>(<span class='self'>self</span>) { + <span class='prelude-val'>None</span> <span class='op'>=></span> { <span class='self'>self</span>.<span class='ident'>chari</span> <span class='op'>=</span> <span class='ident'>start</span>; <span class='prelude-val'>None</span> } + <span class='ident'>result</span> <span class='op'>=></span> <span class='ident'>result</span>, + } + } + + <span class='comment'>// Parses a Uncode class name, e.g., `a\pLb`.</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `L`</span> + <span class='comment'>// End: `b`</span> + <span class='comment'>//</span> + <span class='comment'>// And also, `a\p{Greek}b`.</span> + <span class='comment'>//</span> + <span class='comment'>// Start: `{`</span> + <span class='comment'>// End: `b`</span> + <span class='comment'>//</span> + <span class='comment'>// `negate` is true when the class name is used with `\P`.</span> + <span class='kw'>fn</span> <span class='ident'>parse_unicode_class</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>neg</span>: <span class='ident'>bool</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>CharClass</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>name</span> <span class='op'>=</span> + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>bump_if</span>(<span class='string'>'{'</span>) { + <span class='kw'>let</span> <span class='ident'>n</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>bump_get</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>!=</span> <span class='string'>'}'</span>).<span class='ident'>unwrap_or</span>(<span class='string'>""</span>.<span class='ident'>into</span>()); + <span class='kw'>if</span> <span class='ident'>n</span>.<span class='ident'>is_empty</span>() <span class='op'>||</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>bump_if</span>(<span class='string'>'}'</span>) { + <span class='comment'>// e.g., \p{Greek</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>UnclosedUnicodeName</span>)); + } + <span class='ident'>n</span> + } <span class='kw'>else</span> { + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>eof</span>() { + <span class='comment'>// e.g., \p</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedEscapeEof</span>)); + } + <span class='self'>self</span>.<span class='ident'>bump</span>().<span class='ident'>to_string</span>() + }; + <span class='kw'>match</span> <span class='ident'>unicode_class</span>(<span class='kw-2'>&</span><span class='ident'>name</span>) { + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>UnrecognizedUnicodeClass</span>(<span class='ident'>name</span>))), + <span class='prelude-val'>Some</span>(<span class='ident'>cls</span>) <span class='op'>=></span> <span class='kw'>if</span> <span class='ident'>neg</span> { <span class='prelude-val'>Ok</span>(<span class='ident'>cls</span>.<span class='ident'>negate</span>()) } <span class='kw'>else</span> { <span class='prelude-val'>Ok</span>(<span class='ident'>cls</span>) }, + } + } + + <span class='comment'>// Parses a perl character class with Unicode support.</span> + <span class='comment'>//</span> + <span class='comment'>// `name` must be one of d, s, w, D, S, W. If not, this function panics.</span> + <span class='comment'>//</span> + <span class='comment'>// No parser state is changed.</span> + <span class='kw'>fn</span> <span class='ident'>parse_perl_class</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>name</span>: <span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>CharClass</span> { + <span class='kw'>use</span> <span class='ident'>unicode</span>::<span class='ident'>regex</span>::{<span class='ident'>PERLD</span>, <span class='ident'>PERLS</span>, <span class='ident'>PERLW</span>}; + <span class='kw'>match</span> <span class='ident'>name</span> { + <span class='string'>'d'</span> <span class='op'>=></span> <span class='ident'>raw_class_to_expr</span>(<span class='ident'>PERLD</span>), + <span class='string'>'D'</span> <span class='op'>=></span> <span class='ident'>raw_class_to_expr</span>(<span class='ident'>PERLD</span>).<span class='ident'>negate</span>(), + <span class='string'>'s'</span> <span class='op'>=></span> <span class='ident'>raw_class_to_expr</span>(<span class='ident'>PERLS</span>), + <span class='string'>'S'</span> <span class='op'>=></span> <span class='ident'>raw_class_to_expr</span>(<span class='ident'>PERLS</span>).<span class='ident'>negate</span>(), + <span class='string'>'w'</span> <span class='op'>=></span> <span class='ident'>raw_class_to_expr</span>(<span class='ident'>PERLW</span>), + <span class='string'>'W'</span> <span class='op'>=></span> <span class='ident'>raw_class_to_expr</span>(<span class='ident'>PERLW</span>).<span class='ident'>negate</span>(), + _ <span class='op'>=></span> <span class='macro'>unreachable</span><span class='macro'>!</span>(), + } + } + + <span class='comment'>// Always bump to the next input and return the given expression as a</span> + <span class='comment'>// `Build`.</span> + <span class='comment'>//</span> + <span class='comment'>// This is mostly for convenience when the surrounding context implies</span> + <span class='comment'>// that the next character corresponds to the given expression.</span> + <span class='kw'>fn</span> <span class='ident'>parse_one</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>e</span>: <span class='ident'>Expr</span>) <span class='op'>-></span> <span class='ident'>Build</span> { + <span class='self'>self</span>.<span class='ident'>bump</span>(); + <span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>e</span>) + } +} + +<span class='comment'>// Auxiliary helper methods.</span> +<span class='kw'>impl</span> <span class='ident'>Parser</span> { + <span class='kw'>fn</span> <span class='ident'>chars</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>Chars</span> { + <span class='ident'>Chars</span>::<span class='ident'>new</span>(<span class='kw-2'>&</span><span class='self'>self</span>.<span class='ident'>chars</span>[<span class='self'>self</span>.<span class='ident'>chari</span>..], <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>ignore_space</span>) + } + + <span class='kw'>fn</span> <span class='ident'>bump</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>char</span> { + <span class='kw'>let</span> <span class='ident'>c</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>cur</span>(); + <span class='self'>self</span>.<span class='ident'>chari</span> <span class='op'>=</span> <span class='ident'>checkadd</span>(<span class='self'>self</span>.<span class='ident'>chari</span>, <span class='self'>self</span>.<span class='ident'>chars</span>().<span class='ident'>next_count</span>()); + <span class='ident'>c</span> + } + + <span class='kw'>fn</span> <span class='ident'>cur</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>char</span> { <span class='self'>self</span>.<span class='ident'>chars</span>().<span class='ident'>next</span>().<span class='ident'>unwrap</span>() } + + <span class='kw'>fn</span> <span class='ident'>eof</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { <span class='self'>self</span>.<span class='ident'>chars</span>().<span class='ident'>next</span>().<span class='ident'>is_none</span>() } + + <span class='kw'>fn</span> <span class='ident'>bump_get</span><span class='op'><</span><span class='ident'>B</span>: <span class='ident'>Bumpable</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>s</span>: <span class='ident'>B</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>String</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='ident'>n</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>match_end</span>(<span class='self'>self</span>); + <span class='kw'>if</span> <span class='ident'>n</span> <span class='op'>==</span> <span class='number'>0</span> { + <span class='prelude-val'>None</span> + } <span class='kw'>else</span> { + <span class='kw'>let</span> <span class='ident'>end</span> <span class='op'>=</span> <span class='ident'>checkadd</span>(<span class='self'>self</span>.<span class='ident'>chari</span>, <span class='ident'>n</span>); + <span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>chars</span>[<span class='self'>self</span>.<span class='ident'>chari</span>..<span class='ident'>end</span>] + .<span class='ident'>iter</span>().<span class='ident'>cloned</span>().<span class='ident'>collect</span>::<span class='op'><</span><span class='ident'>String</span><span class='op'>></span>(); + <span class='self'>self</span>.<span class='ident'>chari</span> <span class='op'>=</span> <span class='ident'>end</span>; + <span class='prelude-val'>Some</span>(<span class='ident'>s</span>) + } + } + + <span class='kw'>fn</span> <span class='ident'>bump_if</span><span class='op'><</span><span class='ident'>B</span>: <span class='ident'>Bumpable</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>s</span>: <span class='ident'>B</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>let</span> <span class='ident'>n</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>match_end</span>(<span class='self'>self</span>); + <span class='kw'>if</span> <span class='ident'>n</span> <span class='op'>==</span> <span class='number'>0</span> { + <span class='boolval'>false</span> + } <span class='kw'>else</span> { + <span class='self'>self</span>.<span class='ident'>chari</span> <span class='op'>=</span> <span class='ident'>checkadd</span>(<span class='self'>self</span>.<span class='ident'>chari</span>, <span class='ident'>n</span>); + <span class='boolval'>true</span> + } + } + + <span class='kw'>fn</span> <span class='ident'>peek_is</span><span class='op'><</span><span class='ident'>B</span>: <span class='ident'>Bumpable</span><span class='op'>></span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>s</span>: <span class='ident'>B</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='ident'>s</span>.<span class='ident'>match_end</span>(<span class='self'>self</span>) <span class='op'>></span> <span class='number'>0</span> + } + + <span class='kw'>fn</span> <span class='ident'>err</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>kind</span>: <span class='ident'>ErrorKind</span>) <span class='op'>-></span> <span class='ident'>Error</span> { + <span class='self'>self</span>.<span class='ident'>errat</span>(<span class='self'>self</span>.<span class='ident'>chari</span>, <span class='ident'>kind</span>) + } + + <span class='kw'>fn</span> <span class='ident'>errat</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>pos</span>: <span class='ident'>usize</span>, <span class='ident'>kind</span>: <span class='ident'>ErrorKind</span>) <span class='op'>-></span> <span class='ident'>Error</span> { + <span class='ident'>Error</span> { <span class='ident'>pos</span>: <span class='ident'>pos</span>, <span class='ident'>surround</span>: <span class='self'>self</span>.<span class='ident'>windowat</span>(<span class='ident'>pos</span>), <span class='ident'>kind</span>: <span class='ident'>kind</span> } + } + + <span class='kw'>fn</span> <span class='ident'>windowat</span>(<span class='kw-2'>&</span><span class='self'>self</span>, <span class='ident'>pos</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>String</span> { + <span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>max</span>(<span class='number'>5</span>, <span class='ident'>pos</span>) <span class='op'>-</span> <span class='number'>5</span>; + <span class='kw'>let</span> <span class='ident'>e</span> <span class='op'>=</span> <span class='ident'>min</span>(<span class='self'>self</span>.<span class='ident'>chars</span>.<span class='ident'>len</span>(), <span class='ident'>checkadd</span>(<span class='ident'>pos</span>, <span class='number'>5</span>)); + <span class='self'>self</span>.<span class='ident'>chars</span>[<span class='ident'>s</span>..<span class='ident'>e</span>].<span class='ident'>iter</span>().<span class='ident'>cloned</span>().<span class='ident'>collect</span>() + } + + <span class='kw'>fn</span> <span class='ident'>pop</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>expected</span>: <span class='ident'>ErrorKind</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Expr</span><span class='op'>></span> { + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>stack</span>.<span class='ident'>pop</span>() { + <span class='prelude-val'>None</span> <span class='op'>|</span> <span class='prelude-val'>Some</span>(<span class='ident'>Build</span>::<span class='ident'>LeftParen</span>{..}) <span class='op'>=></span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>expected</span>)), + <span class='prelude-val'>Some</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>e</span>)) <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='ident'>e</span>), + } + } + + <span class='comment'>// If the current contexts calls for case insensitivity and if the expr</span> + <span class='comment'>// given is a character class, do case folding on it and return the new</span> + <span class='comment'>// class.</span> + <span class='comment'>//</span> + <span class='comment'>// Otherwise, return the expression unchanged.</span> + <span class='kw'>fn</span> <span class='ident'>maybe_class_case_fold</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>bexpr</span>: <span class='ident'>Build</span>) <span class='op'>-></span> <span class='ident'>Build</span> { + <span class='kw'>match</span> <span class='ident'>bexpr</span> { + <span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>cls</span>)) <span class='op'>=></span> { + <span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Class</span>( + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>flags</span>.<span class='ident'>casei</span> <span class='op'>&&</span> <span class='op'>!</span><span class='ident'>cls</span>.<span class='ident'>casei</span> { + <span class='ident'>cls</span>.<span class='ident'>case_fold</span>() + } <span class='kw'>else</span> { + <span class='ident'>cls</span> + } + )) + } + <span class='ident'>bexpr</span> <span class='op'>=></span> <span class='ident'>bexpr</span>, + } + } +} + +<span class='kw'>struct</span> <span class='ident'>Chars</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='ident'>chars</span>: <span class='kw-2'>&</span><span class='lifetime'>'a</span> [<span class='ident'>char</span>], + <span class='ident'>cur</span>: <span class='ident'>usize</span>, + <span class='ident'>ignore_space</span>: <span class='ident'>bool</span>, + <span class='ident'>in_comment</span>: <span class='ident'>bool</span>, +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>Iterator</span> <span class='kw'>for</span> <span class='ident'>Chars</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='kw'>type</span> <span class='ident'>Item</span> <span class='op'>=</span> <span class='ident'>char</span>; + <span class='kw'>fn</span> <span class='ident'>next</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>char</span><span class='op'>></span> { + <span class='self'>self</span>.<span class='ident'>skip</span>(); + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>cur</span> <span class='op'><</span> <span class='self'>self</span>.<span class='ident'>chars</span>.<span class='ident'>len</span>() { + <span class='kw'>let</span> <span class='ident'>c</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>chars</span>[<span class='self'>self</span>.<span class='ident'>cur</span>]; + <span class='self'>self</span>.<span class='ident'>cur</span> <span class='op'>=</span> <span class='ident'>checkadd</span>(<span class='self'>self</span>.<span class='ident'>cur</span>, <span class='number'>1</span>); + <span class='prelude-val'>Some</span>(<span class='ident'>c</span>) + } <span class='kw'>else</span> { + <span class='prelude-val'>None</span> + } + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>Chars</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> { + <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>chars</span>: <span class='kw-2'>&</span>[<span class='ident'>char</span>], <span class='ident'>ignore_space</span>: <span class='ident'>bool</span>) <span class='op'>-></span> <span class='ident'>Chars</span> { + <span class='ident'>Chars</span> { + <span class='ident'>chars</span>: <span class='ident'>chars</span>, + <span class='ident'>cur</span>: <span class='number'>0</span>, + <span class='ident'>ignore_space</span>: <span class='ident'>ignore_space</span>, + <span class='ident'>in_comment</span>: <span class='boolval'>false</span>, + } + } + + <span class='doccomment'>/// Skip line comments and whitespace</span> + <span class='kw'>fn</span> <span class='ident'>skip</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) { + <span class='kw'>if</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>ignore_space</span> { <span class='kw'>return</span>; } + <span class='kw'>while</span> <span class='self'>self</span>.<span class='ident'>cur</span> <span class='op'><</span> <span class='self'>self</span>.<span class='ident'>chars</span>.<span class='ident'>len</span>() { + <span class='comment'>// Handle escaping of `#`, i.e. don't start a comment with `\#`.</span> + <span class='kw'>let</span> <span class='ident'>next_cur</span> <span class='op'>=</span> <span class='ident'>checkadd</span>(<span class='self'>self</span>.<span class='ident'>cur</span>, <span class='number'>1</span>); + <span class='kw'>if</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>in_comment</span> <span class='op'>&&</span> <span class='self'>self</span>.<span class='ident'>c</span>() <span class='op'>==</span> <span class='string'>'\\'</span> + <span class='op'>&&</span> <span class='ident'>next_cur</span> <span class='op'><</span> <span class='self'>self</span>.<span class='ident'>chars</span>.<span class='ident'>len</span>() + <span class='op'>&&</span> <span class='self'>self</span>.<span class='ident'>chars</span>[<span class='ident'>next_cur</span>] <span class='op'>==</span> <span class='string'>'#'</span> + { + <span class='self'>self</span>.<span class='ident'>cur</span> <span class='op'>=</span> <span class='ident'>next_cur</span>; + <span class='kw'>break</span>; + } + + <span class='kw'>if</span> <span class='op'>!</span><span class='self'>self</span>.<span class='ident'>in_comment</span> <span class='op'>&&</span> <span class='self'>self</span>.<span class='ident'>c</span>() <span class='op'>==</span> <span class='string'>'#'</span> { + <span class='self'>self</span>.<span class='ident'>in_comment</span> <span class='op'>=</span> <span class='boolval'>true</span>; + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>in_comment</span> <span class='op'>&&</span> <span class='self'>self</span>.<span class='ident'>c</span>() <span class='op'>==</span> <span class='string'>'\n'</span> { + <span class='self'>self</span>.<span class='ident'>in_comment</span> <span class='op'>=</span> <span class='boolval'>false</span>; + } + + <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>in_comment</span> <span class='op'>||</span> <span class='self'>self</span>.<span class='ident'>c</span>().<span class='ident'>is_whitespace</span>() { + <span class='self'>self</span>.<span class='ident'>cur</span> <span class='op'>=</span> <span class='ident'>next_cur</span>; + } <span class='kw'>else</span> { + <span class='kw'>break</span>; + } + } + } + + <span class='kw'>fn</span> <span class='ident'>c</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>char</span> { + <span class='self'>self</span>.<span class='ident'>chars</span>[<span class='self'>self</span>.<span class='ident'>cur</span>] + } + + <span class='kw'>fn</span> <span class='ident'>next_count</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='self'>self</span>.<span class='ident'>next</span>(); + <span class='self'>self</span>.<span class='ident'>cur</span> + } +} + +<span class='comment'>// Auxiliary methods for manipulating the expression stack.</span> +<span class='kw'>impl</span> <span class='ident'>Parser</span> { + <span class='comment'>// Called whenever an alternate (`|`) is found.</span> + <span class='comment'>//</span> + <span class='comment'>// This pops the expression stack until:</span> + <span class='comment'>//</span> + <span class='comment'>// 1. The stack is empty. Pushes an alternation with one arm.</span> + <span class='comment'>// 2. An opening parenthesis is found. Leave the parenthesis</span> + <span class='comment'>// on the stack and push an alternation with one arm.</span> + <span class='comment'>// 3. An alternate (`|`) is found. Pop the existing alternation,</span> + <span class='comment'>// add an arm and push the modified alternation.</span> + <span class='comment'>//</span> + <span class='comment'>// Each "arm" in the above corresponds to the concatenation of all</span> + <span class='comment'>// popped expressions.</span> + <span class='comment'>//</span> + <span class='comment'>// In the first two cases, the stack is left in an invalid state</span> + <span class='comment'>// because an alternation with one arm is not allowed. This</span> + <span class='comment'>// particular state will be detected by `finish_concat` and an</span> + <span class='comment'>// error will be reported.</span> + <span class='comment'>//</span> + <span class='comment'>// In none of the cases is an empty arm allowed. If an empty arm</span> + <span class='comment'>// is found, an error is reported.</span> + <span class='kw'>fn</span> <span class='ident'>alternate</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Build</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>concat</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[]; + <span class='kw'>let</span> <span class='ident'>alts</span> <span class='op'>=</span> <span class='op'>|</span><span class='ident'>es</span><span class='op'>|</span> <span class='prelude-val'>Ok</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Alternate</span>(<span class='ident'>es</span>))); + <span class='kw'>loop</span> { + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>stack</span>.<span class='ident'>pop</span>() { + <span class='prelude-val'>None</span> <span class='op'>=></span> { + <span class='kw'>if</span> <span class='ident'>concat</span>.<span class='ident'>is_empty</span>() { + <span class='comment'>// e.g., |a</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>EmptyAlternate</span>)); + } + <span class='kw'>return</span> <span class='ident'>alts</span>(<span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>rev_concat</span>(<span class='ident'>concat</span>)]); + } + <span class='prelude-val'>Some</span>(<span class='ident'>e</span> <span class='kw-2'>@</span> <span class='ident'>Build</span>::<span class='ident'>LeftParen</span>{..}) <span class='op'>=></span> { + <span class='kw'>if</span> <span class='ident'>concat</span>.<span class='ident'>is_empty</span>() { + <span class='comment'>// e.g., (|a)</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>EmptyAlternate</span>)); + } + <span class='self'>self</span>.<span class='ident'>stack</span>.<span class='ident'>push</span>(<span class='ident'>e</span>); + <span class='kw'>return</span> <span class='ident'>alts</span>(<span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>rev_concat</span>(<span class='ident'>concat</span>)]); + } + <span class='prelude-val'>Some</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Alternate</span>(<span class='kw-2'>mut</span> <span class='ident'>es</span>))) <span class='op'>=></span> { + <span class='kw'>if</span> <span class='ident'>concat</span>.<span class='ident'>is_empty</span>() { + <span class='comment'>// e.g., a||</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>EmptyAlternate</span>)); + } + <span class='ident'>es</span>.<span class='ident'>push</span>(<span class='ident'>rev_concat</span>(<span class='ident'>concat</span>)); + <span class='kw'>return</span> <span class='ident'>alts</span>(<span class='ident'>es</span>); + } + <span class='prelude-val'>Some</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>e</span>)) <span class='op'>=></span> { <span class='ident'>concat</span>.<span class='ident'>push</span>(<span class='ident'>e</span>); } + } + } + } + + <span class='comment'>// Called whenever a closing parenthesis (`)`) is found.</span> + <span class='comment'>//</span> + <span class='comment'>// This pops the expression stack until:</span> + <span class='comment'>//</span> + <span class='comment'>// 1. The stack is empty. An error is reported because this</span> + <span class='comment'>// indicates an unopened parenthesis.</span> + <span class='comment'>// 2. An opening parenthesis is found. Pop the opening parenthesis</span> + <span class='comment'>// and push a `Group` expression.</span> + <span class='comment'>// 3. An alternate (`|`) is found. Pop the existing alternation</span> + <span class='comment'>// and an arm to it in place. Pop one more item from the stack.</span> + <span class='comment'>// If the stack was empty, then report an unopened parenthesis</span> + <span class='comment'>// error, otherwise assume it is an opening parenthesis and</span> + <span class='comment'>// push a `Group` expression with the popped alternation.</span> + <span class='comment'>// (We can assume this is an opening parenthesis because an</span> + <span class='comment'>// alternation either corresponds to the entire Regex or it</span> + <span class='comment'>// corresponds to an entire group. This is guaranteed by the</span> + <span class='comment'>// `alternate` method.)</span> + <span class='comment'>//</span> + <span class='comment'>// Each "arm" in the above corresponds to the concatenation of all</span> + <span class='comment'>// popped expressions.</span> + <span class='comment'>//</span> + <span class='comment'>// Empty arms nor empty groups are allowed.</span> + <span class='kw'>fn</span> <span class='ident'>close_paren</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span>(<span class='ident'>Flags</span>, <span class='ident'>Build</span>)<span class='op'>></span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>concat</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[]; + <span class='kw'>loop</span> { + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>stack</span>.<span class='ident'>pop</span>() { + <span class='comment'>// e.g., )</span> + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>UnopenedParen</span>)), + <span class='prelude-val'>Some</span>(<span class='ident'>Build</span>::<span class='ident'>LeftParen</span> { <span class='ident'>i</span>, <span class='ident'>name</span>, <span class='ident'>old_flags</span>, .. }) <span class='op'>=></span> { + <span class='kw'>if</span> <span class='ident'>concat</span>.<span class='ident'>is_empty</span>() { + <span class='comment'>// e.g., ()</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>EmptyGroup</span>)); + } + <span class='kw'>return</span> <span class='prelude-val'>Ok</span>((<span class='ident'>old_flags</span>, <span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>rev_concat</span>(<span class='ident'>concat</span>)), + <span class='ident'>i</span>: <span class='ident'>i</span>, + <span class='ident'>name</span>: <span class='ident'>name</span>, + }))); + } + <span class='prelude-val'>Some</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Alternate</span>(<span class='kw-2'>mut</span> <span class='ident'>es</span>))) <span class='op'>=></span> { + <span class='kw'>if</span> <span class='ident'>concat</span>.<span class='ident'>is_empty</span>() { + <span class='comment'>// e.g., (a|)</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>EmptyAlternate</span>)); + } + <span class='ident'>es</span>.<span class='ident'>push</span>(<span class='ident'>rev_concat</span>(<span class='ident'>concat</span>)); + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>stack</span>.<span class='ident'>pop</span>() { + <span class='comment'>// e.g., a|b)</span> + <span class='prelude-val'>None</span> <span class='op'>=></span> <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>UnopenedParen</span>)), + <span class='prelude-val'>Some</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(_)) <span class='op'>=></span> <span class='macro'>unreachable</span><span class='macro'>!</span>(), + <span class='prelude-val'>Some</span>(<span class='ident'>Build</span>::<span class='ident'>LeftParen</span> { <span class='ident'>i</span>, <span class='ident'>name</span>, <span class='ident'>old_flags</span>, .. }) <span class='op'>=></span> { + <span class='kw'>return</span> <span class='prelude-val'>Ok</span>((<span class='ident'>old_flags</span>, <span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>Expr</span>::<span class='ident'>Alternate</span>(<span class='ident'>es</span>)), + <span class='ident'>i</span>: <span class='ident'>i</span>, + <span class='ident'>name</span>: <span class='ident'>name</span>, + }))); + } + } + } + <span class='prelude-val'>Some</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>e</span>)) <span class='op'>=></span> { <span class='ident'>concat</span>.<span class='ident'>push</span>(<span class='ident'>e</span>); } + } + } + } + + <span class='comment'>// Called only when the parser reaches the end of input.</span> + <span class='comment'>//</span> + <span class='comment'>// This pops the expression stack until:</span> + <span class='comment'>//</span> + <span class='comment'>// 1. The stack is empty. Return concatenation of popped</span> + <span class='comment'>// expressions. This concatenation may be empty!</span> + <span class='comment'>// 2. An alternation is found. Pop the alternation and push</span> + <span class='comment'>// a new arm. Return the alternation as the entire Regex.</span> + <span class='comment'>//</span> + <span class='comment'>// If an opening parenthesis is popped, then an error is</span> + <span class='comment'>// returned since it indicates an unclosed parenthesis.</span> + <span class='kw'>fn</span> <span class='ident'>finish_concat</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='self'>self</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>Expr</span><span class='op'>></span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>concat</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[]; + <span class='kw'>loop</span> { + <span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>stack</span>.<span class='ident'>pop</span>() { + <span class='prelude-val'>None</span> <span class='op'>=></span> { <span class='kw'>return</span> <span class='prelude-val'>Ok</span>(<span class='ident'>rev_concat</span>(<span class='ident'>concat</span>)); } + <span class='prelude-val'>Some</span>(<span class='ident'>Build</span>::<span class='ident'>LeftParen</span>{ <span class='ident'>chari</span>, ..}) <span class='op'>=></span> { + <span class='comment'>// e.g., a(b</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>errat</span>(<span class='ident'>chari</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnclosedParen</span>)); + } + <span class='prelude-val'>Some</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Alternate</span>(<span class='kw-2'>mut</span> <span class='ident'>es</span>))) <span class='op'>=></span> { + <span class='kw'>if</span> <span class='ident'>concat</span>.<span class='ident'>is_empty</span>() { + <span class='comment'>// e.g., a|</span> + <span class='kw'>return</span> <span class='prelude-val'>Err</span>(<span class='self'>self</span>.<span class='ident'>err</span>(<span class='ident'>ErrorKind</span>::<span class='ident'>EmptyAlternate</span>)); + } + <span class='ident'>es</span>.<span class='ident'>push</span>(<span class='ident'>rev_concat</span>(<span class='ident'>concat</span>)); + <span class='kw'>return</span> <span class='prelude-val'>Ok</span>(<span class='ident'>Expr</span>::<span class='ident'>Alternate</span>(<span class='ident'>es</span>)); + } + <span class='prelude-val'>Some</span>(<span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>e</span>)) <span class='op'>=></span> { <span class='ident'>concat</span>.<span class='ident'>push</span>(<span class='ident'>e</span>); } + } + } + } +} + +<span class='kw'>impl</span> <span class='ident'>Build</span> { + <span class='kw'>fn</span> <span class='ident'>is_empty</span>(<span class='kw-2'>&</span><span class='self'>self</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> { + <span class='ident'>Build</span>::<span class='ident'>Expr</span>(<span class='ident'>Expr</span>::<span class='ident'>Empty</span>) <span class='op'>=></span> <span class='boolval'>true</span>, + _ <span class='op'>=></span> <span class='boolval'>false</span>, + } + } +} + +<span class='comment'>// Make it ergonomic to conditionally bump the parser.</span> +<span class='comment'>// i.e., `bump_if('a')` or `bump_if("abc")`.</span> +<span class='kw'>trait</span> <span class='ident'>Bumpable</span> { + <span class='kw'>fn</span> <span class='ident'>match_end</span>(<span class='self'>self</span>, <span class='ident'>p</span>: <span class='kw-2'>&</span><span class='ident'>Parser</span>) <span class='op'>-></span> <span class='ident'>usize</span>; +} + +<span class='kw'>impl</span> <span class='ident'>Bumpable</span> <span class='kw'>for</span> <span class='ident'>char</span> { + <span class='kw'>fn</span> <span class='ident'>match_end</span>(<span class='self'>self</span>, <span class='ident'>p</span>: <span class='kw-2'>&</span><span class='ident'>Parser</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>chars</span> <span class='op'>=</span> <span class='ident'>p</span>.<span class='ident'>chars</span>(); + <span class='kw'>if</span> <span class='ident'>chars</span>.<span class='ident'>next</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>c</span><span class='op'>|</span> <span class='ident'>c</span> <span class='op'>==</span> <span class='self'>self</span>).<span class='ident'>unwrap_or</span>(<span class='boolval'>false</span>) { + <span class='ident'>chars</span>.<span class='ident'>cur</span> + } <span class='kw'>else</span> { + <span class='number'>0</span> + } + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='lifetime'>'a</span><span class='op'>></span> <span class='ident'>Bumpable</span> <span class='kw'>for</span> <span class='kw-2'>&</span><span class='lifetime'>'a</span> <span class='ident'>str</span> { + <span class='kw'>fn</span> <span class='ident'>match_end</span>(<span class='self'>self</span>, <span class='ident'>p</span>: <span class='kw-2'>&</span><span class='ident'>Parser</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>search</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>chars</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>rest</span> <span class='op'>=</span> <span class='ident'>p</span>.<span class='ident'>chars</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>count</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>loop</span> { + <span class='kw'>match</span> (<span class='ident'>rest</span>.<span class='ident'>next</span>(), <span class='ident'>search</span>.<span class='ident'>next</span>()) { + (<span class='prelude-val'>Some</span>(<span class='ident'>c1</span>), <span class='prelude-val'>Some</span>(<span class='ident'>c2</span>)) <span class='kw'>if</span> <span class='ident'>c1</span> <span class='op'>==</span> <span class='ident'>c2</span> <span class='op'>=></span> <span class='ident'>count</span> <span class='op'>=</span> <span class='ident'>rest</span>.<span class='ident'>cur</span>, + (_, <span class='prelude-val'>None</span>) <span class='op'>=></span> <span class='kw'>return</span> <span class='ident'>count</span>, + _ <span class='op'>=></span> <span class='kw'>return</span> <span class='number'>0</span>, + } + } + } +} + +<span class='kw'>impl</span><span class='op'><</span><span class='ident'>F</span>: <span class='ident'>FnMut</span>(<span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>bool</span><span class='op'>></span> <span class='ident'>Bumpable</span> <span class='kw'>for</span> <span class='ident'>F</span> { + <span class='kw'>fn</span> <span class='ident'>match_end</span>(<span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>p</span>: <span class='kw-2'>&</span><span class='ident'>Parser</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>chars</span> <span class='op'>=</span> <span class='ident'>p</span>.<span class='ident'>chars</span>(); + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>count</span> <span class='op'>=</span> <span class='number'>0</span>; + <span class='kw'>while</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>c</span>) <span class='op'>=</span> <span class='ident'>chars</span>.<span class='ident'>next</span>() { + <span class='kw'>if</span> <span class='op'>!</span><span class='self'>self</span>(<span class='ident'>c</span>) { + <span class='kw'>break</span> + } + <span class='ident'>count</span> <span class='op'>=</span> <span class='ident'>chars</span>.<span class='ident'>cur</span>; + } + <span class='ident'>count</span> + } +} + +<span class='comment'>// Turn a sequence of expressions into a concatenation.</span> +<span class='comment'>// This only uses `Concat` if there are 2 or more expressions.</span> +<span class='kw'>fn</span> <span class='ident'>rev_concat</span>(<span class='kw-2'>mut</span> <span class='ident'>exprs</span>: <span class='ident'>Vec</span><span class='op'><</span><span class='ident'>Expr</span><span class='op'>></span>) <span class='op'>-></span> <span class='ident'>Expr</span> { + <span class='kw'>if</span> <span class='ident'>exprs</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>0</span> { + <span class='ident'>Expr</span>::<span class='ident'>Empty</span> + } <span class='kw'>else</span> <span class='kw'>if</span> <span class='ident'>exprs</span>.<span class='ident'>len</span>() <span class='op'>==</span> <span class='number'>1</span> { + <span class='ident'>exprs</span>.<span class='ident'>pop</span>().<span class='ident'>unwrap</span>() + } <span class='kw'>else</span> { + <span class='ident'>exprs</span>.<span class='ident'>reverse</span>(); + <span class='ident'>Expr</span>::<span class='ident'>Concat</span>(<span class='ident'>exprs</span>) + } +} + +<span class='comment'>// Returns true if and only if the given character is allowed in a capture</span> +<span class='comment'>// name. Note that the first char of a capture name must not be numeric.</span> +<span class='kw'>fn</span> <span class='ident'>is_valid_capture_char</span>(<span class='ident'>c</span>: <span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='ident'>c</span> <span class='op'>==</span> <span class='string'>'_'</span> <span class='op'>||</span> (<span class='ident'>c</span> <span class='op'>>=</span> <span class='string'>'0'</span> <span class='op'>&&</span> <span class='ident'>c</span> <span class='op'><=</span> <span class='string'>'9'</span>) + <span class='op'>||</span> (<span class='ident'>c</span> <span class='op'>>=</span> <span class='string'>'a'</span> <span class='op'>&&</span> <span class='ident'>c</span> <span class='op'><=</span> <span class='string'>'z'</span>) <span class='op'>||</span> (<span class='ident'>c</span> <span class='op'>>=</span> <span class='string'>'A'</span> <span class='op'>&&</span> <span class='ident'>c</span> <span class='op'><=</span> <span class='string'>'Z'</span>) +} + +<span class='doccomment'>/// Returns true if the give character has significance in a regex.</span> +<span class='attribute'>#[<span class='ident'>doc</span>(<span class='ident'>hidden</span>)]</span> +<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_punct</span>(<span class='ident'>c</span>: <span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>bool</span> { + <span class='kw'>match</span> <span class='ident'>c</span> { + <span class='string'>'\\'</span> <span class='op'>|</span> <span class='string'>'.'</span> <span class='op'>|</span> <span class='string'>'+'</span> <span class='op'>|</span> <span class='string'>'*'</span> <span class='op'>|</span> <span class='string'>'?'</span> <span class='op'>|</span> <span class='string'>'('</span> <span class='op'>|</span> <span class='string'>')'</span> <span class='op'>|</span> <span class='string'>'|'</span> <span class='op'>|</span> + <span class='string'>'['</span> <span class='op'>|</span> <span class='string'>']'</span> <span class='op'>|</span> <span class='string'>'{'</span> <span class='op'>|</span> <span class='string'>'}'</span> <span class='op'>|</span> <span class='string'>'^'</span> <span class='op'>|</span> <span class='string'>'$'</span> <span class='op'>|</span> <span class='string'>'#'</span> <span class='op'>=></span> <span class='boolval'>true</span>, + _ <span class='op'>=></span> <span class='boolval'>false</span>, + } +} + +<span class='kw'>fn</span> <span class='ident'>checkadd</span>(<span class='ident'>x</span>: <span class='ident'>usize</span>, <span class='ident'>y</span>: <span class='ident'>usize</span>) <span class='op'>-></span> <span class='ident'>usize</span> { + <span class='ident'>x</span>.<span class='ident'>checked_add</span>(<span class='ident'>y</span>).<span class='ident'>expect</span>(<span class='string'>"regex length overflow"</span>) +} + +<span class='kw'>fn</span> <span class='ident'>unicode_class</span>(<span class='ident'>name</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CharClass</span><span class='op'>></span> { + <span class='ident'>UNICODE_CLASSES</span>.<span class='ident'>binary_search_by</span>(<span class='op'>|</span><span class='kw-2'>&</span>(<span class='ident'>s</span>, _)<span class='op'>|</span> <span class='ident'>s</span>.<span class='ident'>cmp</span>(<span class='ident'>name</span>)).<span class='ident'>ok</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>i</span><span class='op'>|</span> { + <span class='ident'>raw_class_to_expr</span>(<span class='ident'>UNICODE_CLASSES</span>[<span class='ident'>i</span>].<span class='number'>1</span>) + }) +} + +<span class='kw'>fn</span> <span class='ident'>ascii_class</span>(<span class='ident'>name</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='prelude-ty'>Option</span><span class='op'><</span><span class='ident'>CharClass</span><span class='op'>></span> { + <span class='ident'>ASCII_CLASSES</span>.<span class='ident'>binary_search_by</span>(<span class='op'>|</span><span class='kw-2'>&</span>(<span class='ident'>s</span>, _)<span class='op'>|</span> <span class='ident'>s</span>.<span class='ident'>cmp</span>(<span class='ident'>name</span>)).<span class='ident'>ok</span>().<span class='ident'>map</span>(<span class='op'>|</span><span class='ident'>i</span><span class='op'>|</span> { + <span class='ident'>raw_class_to_expr</span>(<span class='ident'>ASCII_CLASSES</span>[<span class='ident'>i</span>].<span class='number'>1</span>) + }) +} + +<span class='kw'>fn</span> <span class='ident'>raw_class_to_expr</span>(<span class='ident'>raw</span>: <span class='kw-2'>&</span>[(<span class='ident'>char</span>, <span class='ident'>char</span>)]) <span class='op'>-></span> <span class='ident'>CharClass</span> { + <span class='kw'>let</span> <span class='ident'>range</span> <span class='op'>=</span> <span class='op'>|</span><span class='kw-2'>&</span>(<span class='ident'>s</span>, <span class='ident'>e</span>)<span class='op'>|</span> <span class='ident'>ClassRange</span> { <span class='ident'>start</span>: <span class='ident'>s</span>, <span class='ident'>end</span>: <span class='ident'>e</span> }; + <span class='ident'>CharClass</span>::<span class='ident'>new</span>(<span class='ident'>raw</span>.<span class='ident'>iter</span>().<span class='ident'>map</span>(<span class='ident'>range</span>).<span class='ident'>collect</span>()) +} + +<span class='kw'>type</span> <span class='ident'>Class</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='lifetime'>'static</span> [(<span class='ident'>char</span>, <span class='ident'>char</span>)]; +<span class='kw'>type</span> <span class='ident'>NamedClasses</span> <span class='op'>=</span> <span class='kw-2'>&</span><span class='lifetime'>'static</span> [(<span class='kw-2'>&</span><span class='lifetime'>'static</span> <span class='ident'>str</span>, <span class='ident'>Class</span>)]; + +<span class='kw'>const</span> <span class='ident'>ASCII_CLASSES</span>: <span class='ident'>NamedClasses</span> <span class='op'>=</span> <span class='kw-2'>&</span>[ + <span class='comment'>// Classes must be in alphabetical order so that bsearch works.</span> + <span class='comment'>// [:alnum:] alphanumeric (== [0-9A-Za-z])</span> + <span class='comment'>// [:alpha:] alphabetic (== [A-Za-z])</span> + <span class='comment'>// [:ascii:] ASCII (== [\x00-\x7F])</span> + <span class='comment'>// [:blank:] blank (== [\t ])</span> + <span class='comment'>// [:cntrl:] control (== [\x00-\x1F\x7F])</span> + <span class='comment'>// [:digit:] digits (== [0-9])</span> + <span class='comment'>// [:graph:] graphical (== [!-~])</span> + <span class='comment'>// [:lower:] lower case (== [a-z])</span> + <span class='comment'>// [:print:] printable (== [ -~] == [ [:graph:]])</span> + <span class='comment'>// [:punct:] punctuation (== [!-/:-@[-`{-~])</span> + <span class='comment'>// [:space:] whitespace (== [\t\n\v\f\r ])</span> + <span class='comment'>// [:upper:] upper case (== [A-Z])</span> + <span class='comment'>// [:word:] word characters (== [0-9A-Za-z_])</span> + <span class='comment'>// [:xdigit:] hex digit (== [0-9A-Fa-f])</span> + <span class='comment'>// Taken from: http://golang.org/pkg/regex/syntax/</span> + (<span class='string'>"alnum"</span>, <span class='kw-2'>&</span><span class='ident'>ALNUM</span>), + (<span class='string'>"alpha"</span>, <span class='kw-2'>&</span><span class='ident'>ALPHA</span>), + (<span class='string'>"ascii"</span>, <span class='kw-2'>&</span><span class='ident'>ASCII</span>), + (<span class='string'>"blank"</span>, <span class='kw-2'>&</span><span class='ident'>BLANK</span>), + (<span class='string'>"cntrl"</span>, <span class='kw-2'>&</span><span class='ident'>CNTRL</span>), + (<span class='string'>"digit"</span>, <span class='kw-2'>&</span><span class='ident'>DIGIT</span>), + (<span class='string'>"graph"</span>, <span class='kw-2'>&</span><span class='ident'>GRAPH</span>), + (<span class='string'>"lower"</span>, <span class='kw-2'>&</span><span class='ident'>LOWER</span>), + (<span class='string'>"print"</span>, <span class='kw-2'>&</span><span class='ident'>PRINT</span>), + (<span class='string'>"punct"</span>, <span class='kw-2'>&</span><span class='ident'>PUNCT</span>), + (<span class='string'>"space"</span>, <span class='kw-2'>&</span><span class='ident'>SPACE</span>), + (<span class='string'>"upper"</span>, <span class='kw-2'>&</span><span class='ident'>UPPER</span>), + (<span class='string'>"word"</span>, <span class='kw-2'>&</span><span class='ident'>WORD</span>), + (<span class='string'>"xdigit"</span>, <span class='kw-2'>&</span><span class='ident'>XDIGIT</span>), +]; + +<span class='kw'>const</span> <span class='ident'>ALNUM</span>: <span class='ident'>Class</span> <span class='op'>=</span> <span class='kw-2'>&</span>[(<span class='string'>'0'</span>, <span class='string'>'9'</span>), (<span class='string'>'A'</span>, <span class='string'>'Z'</span>), (<span class='string'>'a'</span>, <span class='string'>'z'</span>)]; +<span class='kw'>const</span> <span class='ident'>ALPHA</span>: <span class='ident'>Class</span> <span class='op'>=</span> <span class='kw-2'>&</span>[(<span class='string'>'A'</span>, <span class='string'>'Z'</span>), (<span class='string'>'a'</span>, <span class='string'>'z'</span>)]; +<span class='kw'>const</span> <span class='ident'>ASCII</span>: <span class='ident'>Class</span> <span class='op'>=</span> <span class='kw-2'>&</span>[(<span class='string'>'\x00'</span>, <span class='string'>'\x7F'</span>)]; +<span class='kw'>const</span> <span class='ident'>BLANK</span>: <span class='ident'>Class</span> <span class='op'>=</span> <span class='kw-2'>&</span>[(<span class='string'>' '</span>, <span class='string'>' '</span>), (<span class='string'>'\t'</span>, <span class='string'>'\t'</span>)]; +<span class='kw'>const</span> <span class='ident'>CNTRL</span>: <span class='ident'>Class</span> <span class='op'>=</span> <span class='kw-2'>&</span>[(<span class='string'>'\x00'</span>, <span class='string'>'\x1F'</span>), (<span class='string'>'\x7F'</span>, <span class='string'>'\x7F'</span>)]; +<span class='kw'>const</span> <span class='ident'>DIGIT</span>: <span class='ident'>Class</span> <span class='op'>=</span> <span class='kw-2'>&</span>[(<span class='string'>'0'</span>, <span class='string'>'9'</span>)]; +<span class='kw'>const</span> <span class='ident'>GRAPH</span>: <span class='ident'>Class</span> <span class='op'>=</span> <span class='kw-2'>&</span>[(<span class='string'>'!'</span>, <span class='string'>'~'</span>)]; +<span class='kw'>const</span> <span class='ident'>LOWER</span>: <span class='ident'>Class</span> <span class='op'>=</span> <span class='kw-2'>&</span>[(<span class='string'>'a'</span>, <span class='string'>'z'</span>)]; +<span class='kw'>const</span> <span class='ident'>PRINT</span>: <span class='ident'>Class</span> <span class='op'>=</span> <span class='kw-2'>&</span>[(<span class='string'>' '</span>, <span class='string'>'~'</span>)]; +<span class='kw'>const</span> <span class='ident'>PUNCT</span>: <span class='ident'>Class</span> <span class='op'>=</span> <span class='kw-2'>&</span>[(<span class='string'>'!'</span>, <span class='string'>'/'</span>), (<span class='string'>':'</span>, <span class='string'>'@'</span>), (<span class='string'>'['</span>, <span class='string'>'`'</span>), (<span class='string'>'{'</span>, <span class='string'>'~'</span>)]; +<span class='kw'>const</span> <span class='ident'>SPACE</span>: <span class='ident'>Class</span> <span class='op'>=</span> <span class='kw-2'>&</span>[(<span class='string'>'\t'</span>, <span class='string'>'\t'</span>), (<span class='string'>'\n'</span>, <span class='string'>'\n'</span>), (<span class='string'>'\x0B'</span>, <span class='string'>'\x0B'</span>), + (<span class='string'>'\x0C'</span>, <span class='string'>'\x0C'</span>), (<span class='string'>'\r'</span>, <span class='string'>'\r'</span>), (<span class='string'>' '</span>, <span class='string'>' '</span>)]; +<span class='kw'>const</span> <span class='ident'>UPPER</span>: <span class='ident'>Class</span> <span class='op'>=</span> <span class='kw-2'>&</span>[(<span class='string'>'A'</span>, <span class='string'>'Z'</span>)]; +<span class='kw'>const</span> <span class='ident'>WORD</span>: <span class='ident'>Class</span> <span class='op'>=</span> <span class='kw-2'>&</span>[(<span class='string'>'0'</span>, <span class='string'>'9'</span>), (<span class='string'>'A'</span>, <span class='string'>'Z'</span>), (<span class='string'>'a'</span>, <span class='string'>'z'</span>), (<span class='string'>'_'</span>, <span class='string'>'_'</span>)]; +<span class='kw'>const</span> <span class='ident'>XDIGIT</span>: <span class='ident'>Class</span> <span class='op'>=</span> <span class='kw-2'>&</span>[(<span class='string'>'0'</span>, <span class='string'>'9'</span>), (<span class='string'>'A'</span>, <span class='string'>'F'</span>), (<span class='string'>'a'</span>, <span class='string'>'f'</span>)]; + +<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span> +<span class='kw'>mod</span> <span class='ident'>tests</span> { + <span class='kw'>use</span> { <span class='ident'>CharClass</span>, <span class='ident'>ClassRange</span>, <span class='ident'>Expr</span>, <span class='ident'>Repeater</span>, <span class='ident'>ErrorKind</span> }; + <span class='kw'>use</span> <span class='ident'>unicode</span>::<span class='ident'>regex</span>::{<span class='ident'>PERLD</span>, <span class='ident'>PERLS</span>, <span class='ident'>PERLW</span>}; + <span class='kw'>use</span> <span class='ident'>super</span>::<span class='ident'>Parser</span>; + <span class='kw'>use</span> <span class='ident'>super</span>::{<span class='ident'>LOWER</span>, <span class='ident'>UPPER</span>}; + + <span class='kw'>static</span> <span class='ident'>YI</span>: <span class='kw-2'>&</span><span class='lifetime'>'static</span> [(<span class='ident'>char</span>, <span class='ident'>char</span>)] <span class='op'>=</span> <span class='kw-2'>&</span>[ + (<span class='string'>'\u{a000}'</span>, <span class='string'>'\u{a48c}'</span>), (<span class='string'>'\u{a490}'</span>, <span class='string'>'\u{a4c6}'</span>), + ]; + + <span class='kw'>fn</span> <span class='ident'>p</span>(<span class='ident'>s</span>: <span class='kw-2'>&</span><span class='ident'>str</span>) <span class='op'>-></span> <span class='ident'>Expr</span> { <span class='ident'>Parser</span>::<span class='ident'>parse</span>(<span class='ident'>s</span>).<span class='ident'>unwrap</span>() } + <span class='kw'>fn</span> <span class='ident'>lit</span>(<span class='ident'>c</span>: <span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>Expr</span> { <span class='ident'>Expr</span>::<span class='ident'>Literal</span> { <span class='ident'>chars</span>: <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>c</span>], <span class='ident'>casei</span>: <span class='boolval'>false</span> } } + <span class='kw'>fn</span> <span class='ident'>liti</span>(<span class='ident'>c</span>: <span class='ident'>char</span>) <span class='op'>-></span> <span class='ident'>Expr</span> { <span class='ident'>Expr</span>::<span class='ident'>Literal</span> { <span class='ident'>chars</span>: <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>c</span>], <span class='ident'>casei</span>: <span class='boolval'>true</span> } } + <span class='kw'>fn</span> <span class='ident'>b</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span>(<span class='ident'>v</span>: <span class='ident'>T</span>) <span class='op'>-></span> <span class='ident'>Box</span><span class='op'><</span><span class='ident'>T</span><span class='op'>></span> { <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>v</span>) } + <span class='kw'>fn</span> <span class='ident'>c</span>(<span class='ident'>es</span>: <span class='kw-2'>&</span>[<span class='ident'>Expr</span>]) <span class='op'>-></span> <span class='ident'>Expr</span> { <span class='ident'>Expr</span>::<span class='ident'>Concat</span>(<span class='ident'>es</span>.<span class='ident'>to_vec</span>()) } + + <span class='kw'>fn</span> <span class='ident'>class</span>(<span class='ident'>ranges</span>: <span class='kw-2'>&</span>[(<span class='ident'>char</span>, <span class='ident'>char</span>)]) <span class='op'>-></span> <span class='ident'>CharClass</span> { + <span class='kw'>let</span> <span class='ident'>ranges</span> <span class='op'>=</span> <span class='ident'>ranges</span>.<span class='ident'>iter</span>().<span class='ident'>cloned</span>() + .<span class='ident'>map</span>(<span class='op'>|</span>(<span class='ident'>c1</span>, <span class='ident'>c2</span>)<span class='op'>|</span> <span class='ident'>ClassRange</span>::<span class='ident'>new</span>(<span class='ident'>c1</span>, <span class='ident'>c2</span>)).<span class='ident'>collect</span>(); + <span class='ident'>CharClass</span>::<span class='ident'>new</span>(<span class='ident'>ranges</span>) + } + + <span class='kw'>fn</span> <span class='ident'>classes</span>(<span class='ident'>classes</span>: <span class='kw-2'>&</span>[<span class='kw-2'>&</span>[(<span class='ident'>char</span>, <span class='ident'>char</span>)]]) <span class='op'>-></span> <span class='ident'>CharClass</span> { + <span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>CharClass</span>::<span class='ident'>empty</span>(); + <span class='kw'>for</span> <span class='kw-2'>&</span><span class='ident'>ranges</span> <span class='kw'>in</span> <span class='ident'>classes</span> { + <span class='ident'>cls</span>.<span class='ident'>ranges</span>.<span class='ident'>extend</span>(<span class='ident'>class</span>(<span class='ident'>ranges</span>)); + } + <span class='ident'>cls</span>.<span class='ident'>canonicalize</span>() + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>empty</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>""</span>), <span class='ident'>Expr</span>::<span class='ident'>Empty</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>literal</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"a"</span>), <span class='ident'>lit</span>(<span class='string'>'a'</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>literal_string</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"ab"</span>), <span class='ident'>Expr</span>::<span class='ident'>Concat</span>(<span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>lit</span>(<span class='string'>'a'</span>), <span class='ident'>lit</span>(<span class='string'>'b'</span>)])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>start_literal</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"^a"</span>), <span class='ident'>Expr</span>::<span class='ident'>Concat</span>(<span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>Expr</span>::<span class='ident'>StartText</span>, + <span class='ident'>Expr</span>::<span class='ident'>Literal</span> { <span class='ident'>chars</span>: <span class='macro'>vec</span><span class='macro'>!</span>[<span class='string'>'a'</span>], <span class='ident'>casei</span>: <span class='boolval'>false</span> }, + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>repeat_zero_or_one_greedy</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"a?"</span>), <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>ZeroOrOne</span>, + <span class='ident'>greedy</span>: <span class='boolval'>true</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>repeat_zero_or_one_greedy_concat</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"ab?"</span>), <span class='ident'>Expr</span>::<span class='ident'>Concat</span>(<span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>lit</span>(<span class='string'>'a'</span>), + <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'b'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>ZeroOrOne</span>, + <span class='ident'>greedy</span>: <span class='boolval'>true</span>, + }, + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>repeat_zero_or_one_nongreedy</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"a??"</span>), <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>ZeroOrOne</span>, + <span class='ident'>greedy</span>: <span class='boolval'>false</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>repeat_one_or_more_greedy</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"a+"</span>), <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>OneOrMore</span>, + <span class='ident'>greedy</span>: <span class='boolval'>true</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>repeat_one_or_more_nongreedy</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"a+?"</span>), <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>OneOrMore</span>, + <span class='ident'>greedy</span>: <span class='boolval'>false</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>repeat_zero_or_more_greedy</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"a*"</span>), <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>ZeroOrMore</span>, + <span class='ident'>greedy</span>: <span class='boolval'>true</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>repeat_zero_or_more_nongreedy</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"a*?"</span>), <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>ZeroOrMore</span>, + <span class='ident'>greedy</span>: <span class='boolval'>false</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>repeat_counted_exact</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"a{5}"</span>), <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>Range</span> { <span class='ident'>min</span>: <span class='number'>5</span>, <span class='ident'>max</span>: <span class='prelude-val'>Some</span>(<span class='number'>5</span>) }, + <span class='ident'>greedy</span>: <span class='boolval'>true</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>repeat_counted_min</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"a{5,}"</span>), <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>Range</span> { <span class='ident'>min</span>: <span class='number'>5</span>, <span class='ident'>max</span>: <span class='prelude-val'>None</span> }, + <span class='ident'>greedy</span>: <span class='boolval'>true</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>repeat_counted_min_max</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"a{5,10}"</span>), <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>Range</span> { <span class='ident'>min</span>: <span class='number'>5</span>, <span class='ident'>max</span>: <span class='prelude-val'>Some</span>(<span class='number'>10</span>) }, + <span class='ident'>greedy</span>: <span class='boolval'>true</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>repeat_counted_exact_nongreedy</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"a{5}?"</span>), <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>Range</span> { <span class='ident'>min</span>: <span class='number'>5</span>, <span class='ident'>max</span>: <span class='prelude-val'>Some</span>(<span class='number'>5</span>) }, + <span class='ident'>greedy</span>: <span class='boolval'>false</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>repeat_counted_min_nongreedy</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"a{5,}?"</span>), <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>Range</span> { <span class='ident'>min</span>: <span class='number'>5</span>, <span class='ident'>max</span>: <span class='prelude-val'>None</span> }, + <span class='ident'>greedy</span>: <span class='boolval'>false</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>repeat_counted_min_max_nongreedy</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"a{5,10}?"</span>), <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>Range</span> { <span class='ident'>min</span>: <span class='number'>5</span>, <span class='ident'>max</span>: <span class='prelude-val'>Some</span>(<span class='number'>10</span>) }, + <span class='ident'>greedy</span>: <span class='boolval'>false</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>repeat_counted_whitespace</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"a{ 5 }"</span>), <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>Range</span> { <span class='ident'>min</span>: <span class='number'>5</span>, <span class='ident'>max</span>: <span class='prelude-val'>Some</span>(<span class='number'>5</span>) }, + <span class='ident'>greedy</span>: <span class='boolval'>true</span>, + }); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"a{ 5 , 10 }"</span>), <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>Range</span> { <span class='ident'>min</span>: <span class='number'>5</span>, <span class='ident'>max</span>: <span class='prelude-val'>Some</span>(<span class='number'>10</span>) }, + <span class='ident'>greedy</span>: <span class='boolval'>true</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>group_literal</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(a)"</span>), <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>i</span>: <span class='prelude-val'>Some</span>(<span class='number'>1</span>), + <span class='ident'>name</span>: <span class='prelude-val'>None</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>group_literal_concat</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(ab)"</span>), <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>c</span>(<span class='kw-2'>&</span>[<span class='ident'>lit</span>(<span class='string'>'a'</span>), <span class='ident'>lit</span>(<span class='string'>'b'</span>)])), + <span class='ident'>i</span>: <span class='prelude-val'>Some</span>(<span class='number'>1</span>), + <span class='ident'>name</span>: <span class='prelude-val'>None</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>alt_two</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"a|b"</span>), <span class='ident'>Expr</span>::<span class='ident'>Alternate</span>(<span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>lit</span>(<span class='string'>'a'</span>), <span class='ident'>lit</span>(<span class='string'>'b'</span>)])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>alt_many</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"a|b|c"</span>), <span class='ident'>Expr</span>::<span class='ident'>Alternate</span>(<span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>lit</span>(<span class='string'>'a'</span>), <span class='ident'>lit</span>(<span class='string'>'b'</span>), <span class='ident'>lit</span>(<span class='string'>'c'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>alt_many_concat</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"ab|bc|cd"</span>), <span class='ident'>Expr</span>::<span class='ident'>Alternate</span>(<span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>c</span>(<span class='kw-2'>&</span>[<span class='ident'>lit</span>(<span class='string'>'a'</span>), <span class='ident'>lit</span>(<span class='string'>'b'</span>)]), + <span class='ident'>c</span>(<span class='kw-2'>&</span>[<span class='ident'>lit</span>(<span class='string'>'b'</span>), <span class='ident'>lit</span>(<span class='string'>'c'</span>)]), + <span class='ident'>c</span>(<span class='kw-2'>&</span>[<span class='ident'>lit</span>(<span class='string'>'c'</span>), <span class='ident'>lit</span>(<span class='string'>'d'</span>)]), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>alt_group_two</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(a|b)"</span>), <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>Expr</span>::<span class='ident'>Alternate</span>(<span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>lit</span>(<span class='string'>'a'</span>), <span class='ident'>lit</span>(<span class='string'>'b'</span>)])), + <span class='ident'>i</span>: <span class='prelude-val'>Some</span>(<span class='number'>1</span>), + <span class='ident'>name</span>: <span class='prelude-val'>None</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>alt_group_many</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(a|b|c)"</span>), <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>Expr</span>::<span class='ident'>Alternate</span>(<span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>lit</span>(<span class='string'>'a'</span>), <span class='ident'>lit</span>(<span class='string'>'b'</span>), <span class='ident'>lit</span>(<span class='string'>'c'</span>)])), + <span class='ident'>i</span>: <span class='prelude-val'>Some</span>(<span class='number'>1</span>), + <span class='ident'>name</span>: <span class='prelude-val'>None</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>alt_group_many_concat</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(ab|bc|cd)"</span>), <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>Expr</span>::<span class='ident'>Alternate</span>(<span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>c</span>(<span class='kw-2'>&</span>[<span class='ident'>lit</span>(<span class='string'>'a'</span>), <span class='ident'>lit</span>(<span class='string'>'b'</span>)]), + <span class='ident'>c</span>(<span class='kw-2'>&</span>[<span class='ident'>lit</span>(<span class='string'>'b'</span>), <span class='ident'>lit</span>(<span class='string'>'c'</span>)]), + <span class='ident'>c</span>(<span class='kw-2'>&</span>[<span class='ident'>lit</span>(<span class='string'>'c'</span>), <span class='ident'>lit</span>(<span class='string'>'d'</span>)]), + ])), + <span class='ident'>i</span>: <span class='prelude-val'>Some</span>(<span class='number'>1</span>), + <span class='ident'>name</span>: <span class='prelude-val'>None</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>alt_group_nested</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(ab|(bc|(cd)))"</span>), <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>Expr</span>::<span class='ident'>Alternate</span>(<span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>c</span>(<span class='kw-2'>&</span>[<span class='ident'>lit</span>(<span class='string'>'a'</span>), <span class='ident'>lit</span>(<span class='string'>'b'</span>)]), + <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>Expr</span>::<span class='ident'>Alternate</span>(<span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>c</span>(<span class='kw-2'>&</span>[<span class='ident'>lit</span>(<span class='string'>'b'</span>), <span class='ident'>lit</span>(<span class='string'>'c'</span>)]), + <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>c</span>(<span class='kw-2'>&</span>[<span class='ident'>lit</span>(<span class='string'>'c'</span>), <span class='ident'>lit</span>(<span class='string'>'d'</span>)])), + <span class='ident'>i</span>: <span class='prelude-val'>Some</span>(<span class='number'>3</span>), + <span class='ident'>name</span>: <span class='prelude-val'>None</span>, + } + ])), + <span class='ident'>i</span>: <span class='prelude-val'>Some</span>(<span class='number'>2</span>), + <span class='ident'>name</span>: <span class='prelude-val'>None</span>, + }, + ])), + <span class='ident'>i</span>: <span class='prelude-val'>Some</span>(<span class='number'>1</span>), + <span class='ident'>name</span>: <span class='prelude-val'>None</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>group_name</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?P<foo>a)"</span>), <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>i</span>: <span class='prelude-val'>Some</span>(<span class='number'>1</span>), + <span class='ident'>name</span>: <span class='prelude-val'>Some</span>(<span class='string'>"foo"</span>.<span class='ident'>into</span>()), + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>group_no_capture</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?:a)"</span>), <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>i</span>: <span class='prelude-val'>None</span>, + <span class='ident'>name</span>: <span class='prelude-val'>None</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>group_flags</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?i:a)"</span>), <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>liti</span>(<span class='string'>'a'</span>)), + <span class='ident'>i</span>: <span class='prelude-val'>None</span>, + <span class='ident'>name</span>: <span class='prelude-val'>None</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>group_flags_returned</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?i:a)a"</span>), <span class='ident'>c</span>(<span class='kw-2'>&</span>[ + <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>liti</span>(<span class='string'>'a'</span>)), + <span class='ident'>i</span>: <span class='prelude-val'>None</span>, + <span class='ident'>name</span>: <span class='prelude-val'>None</span>, + }, + <span class='ident'>lit</span>(<span class='string'>'a'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>group_flags_retained</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?i)(?-i:a)a"</span>), <span class='ident'>c</span>(<span class='kw-2'>&</span>[ + <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>i</span>: <span class='prelude-val'>None</span>, + <span class='ident'>name</span>: <span class='prelude-val'>None</span>, + }, + <span class='ident'>liti</span>(<span class='string'>'a'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>flags_inline</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?i)a"</span>), <span class='ident'>liti</span>(<span class='string'>'a'</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>flags_inline_multiple</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?is)a."</span>), <span class='ident'>c</span>(<span class='kw-2'>&</span>[<span class='ident'>liti</span>(<span class='string'>'a'</span>), <span class='ident'>Expr</span>::<span class='ident'>AnyChar</span>])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>flags_inline_multiline</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?m)^(?-m)$"</span>), <span class='ident'>c</span>(<span class='kw-2'>&</span>[<span class='ident'>Expr</span>::<span class='ident'>StartLine</span>, <span class='ident'>Expr</span>::<span class='ident'>EndText</span>])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>flags_inline_swap_greed</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?U)a*a*?(?i-U)a*a*?"</span>), <span class='ident'>c</span>(<span class='kw-2'>&</span>[ + <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>ZeroOrMore</span>, + <span class='ident'>greedy</span>: <span class='boolval'>false</span>, + }, + <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>ZeroOrMore</span>, + <span class='ident'>greedy</span>: <span class='boolval'>true</span>, + }, + <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>liti</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>ZeroOrMore</span>, + <span class='ident'>greedy</span>: <span class='boolval'>true</span>, + }, + <span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>liti</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>ZeroOrMore</span>, + <span class='ident'>greedy</span>: <span class='boolval'>false</span>, + }, + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>flags_inline_multiple_negate_one</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?is)a.(?i-s)a."</span>), <span class='ident'>c</span>(<span class='kw-2'>&</span>[ + <span class='ident'>liti</span>(<span class='string'>'a'</span>), <span class='ident'>Expr</span>::<span class='ident'>AnyChar</span>, <span class='ident'>liti</span>(<span class='string'>'a'</span>), <span class='ident'>Expr</span>::<span class='ident'>AnyCharNoNL</span>, + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>flags_inline_negate</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?i)a(?-i)a"</span>), <span class='ident'>c</span>(<span class='kw-2'>&</span>[<span class='ident'>liti</span>(<span class='string'>'a'</span>), <span class='ident'>lit</span>(<span class='string'>'a'</span>)])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>flags_group_inline</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(a(?i)a)a"</span>), <span class='ident'>c</span>(<span class='kw-2'>&</span>[ + <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>c</span>(<span class='kw-2'>&</span>[<span class='ident'>lit</span>(<span class='string'>'a'</span>), <span class='ident'>liti</span>(<span class='string'>'a'</span>)])), + <span class='ident'>i</span>: <span class='prelude-val'>Some</span>(<span class='number'>1</span>), + <span class='ident'>name</span>: <span class='prelude-val'>None</span>, + }, + <span class='ident'>lit</span>(<span class='string'>'a'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>flags_group_inline_retain</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?i)((?-i)a)a"</span>), <span class='ident'>c</span>(<span class='kw-2'>&</span>[ + <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>i</span>: <span class='prelude-val'>Some</span>(<span class='number'>1</span>), + <span class='ident'>name</span>: <span class='prelude-val'>None</span>, + }, + <span class='ident'>liti</span>(<span class='string'>'a'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_simple</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\a\f\t\n\r\v"</span>), <span class='ident'>c</span>(<span class='kw-2'>&</span>[ + <span class='ident'>lit</span>(<span class='string'>'\x07'</span>), <span class='ident'>lit</span>(<span class='string'>'\x0C'</span>), <span class='ident'>lit</span>(<span class='string'>'\t'</span>), + <span class='ident'>lit</span>(<span class='string'>'\n'</span>), <span class='ident'>lit</span>(<span class='string'>'\r'</span>), <span class='ident'>lit</span>(<span class='string'>'\x0B'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_boundaries</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\A\z\b\B"</span>), <span class='ident'>c</span>(<span class='kw-2'>&</span>[ + <span class='ident'>Expr</span>::<span class='ident'>StartText</span>, <span class='ident'>Expr</span>::<span class='ident'>EndText</span>, + <span class='ident'>Expr</span>::<span class='ident'>WordBoundary</span>, <span class='ident'>Expr</span>::<span class='ident'>NotWordBoundary</span>, + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_punctuation</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\\\.\+\*\?\(\)\|\[\]\{\}\^\$\#"</span>), <span class='ident'>c</span>(<span class='kw-2'>&</span>[ + <span class='ident'>lit</span>(<span class='string'>'\\'</span>), <span class='ident'>lit</span>(<span class='string'>'.'</span>), <span class='ident'>lit</span>(<span class='string'>'+'</span>), <span class='ident'>lit</span>(<span class='string'>'*'</span>), <span class='ident'>lit</span>(<span class='string'>'?'</span>), + <span class='ident'>lit</span>(<span class='string'>'('</span>), <span class='ident'>lit</span>(<span class='string'>')'</span>), <span class='ident'>lit</span>(<span class='string'>'|'</span>), <span class='ident'>lit</span>(<span class='string'>'['</span>), <span class='ident'>lit</span>(<span class='string'>']'</span>), + <span class='ident'>lit</span>(<span class='string'>'{'</span>), <span class='ident'>lit</span>(<span class='string'>'}'</span>), <span class='ident'>lit</span>(<span class='string'>'^'</span>), <span class='ident'>lit</span>(<span class='string'>'$'</span>), <span class='ident'>lit</span>(<span class='string'>'#'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_octal</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\123"</span>), <span class='ident'>lit</span>(<span class='string'>'S'</span>)); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\1234"</span>), <span class='ident'>c</span>(<span class='kw-2'>&</span>[<span class='ident'>lit</span>(<span class='string'>'S'</span>), <span class='ident'>lit</span>(<span class='string'>'4'</span>)])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_hex2</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\x53"</span>), <span class='ident'>lit</span>(<span class='string'>'S'</span>)); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\x534"</span>), <span class='ident'>c</span>(<span class='kw-2'>&</span>[<span class='ident'>lit</span>(<span class='string'>'S'</span>), <span class='ident'>lit</span>(<span class='string'>'4'</span>)])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_hex</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\x{53}"</span>), <span class='ident'>lit</span>(<span class='string'>'S'</span>)); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\x{53}4"</span>), <span class='ident'>c</span>(<span class='kw-2'>&</span>[<span class='ident'>lit</span>(<span class='string'>'S'</span>), <span class='ident'>lit</span>(<span class='string'>'4'</span>)])); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\x{2603}"</span>), <span class='ident'>lit</span>(<span class='string'>'\u{2603}'</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_unicode_name</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\p{Yi}"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>YI</span>))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_unicode_letter</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\pZ"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\u{20}'</span>, <span class='string'>'\u{20}'</span>), (<span class='string'>'\u{a0}'</span>, <span class='string'>'\u{a0}'</span>), + (<span class='string'>'\u{1680}'</span>, <span class='string'>'\u{1680}'</span>), (<span class='string'>'\u{2000}'</span>, <span class='string'>'\u{200a}'</span>), + (<span class='string'>'\u{2028}'</span>, <span class='string'>'\u{2029}'</span>), (<span class='string'>'\u{202f}'</span>, <span class='string'>'\u{202f}'</span>), + (<span class='string'>'\u{205f}'</span>, <span class='string'>'\u{205f}'</span>), (<span class='string'>'\u{3000}'</span>, <span class='string'>'\u{3000}'</span>), + ]))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_unicode_name_case_fold</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)\p{Yi}"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>YI</span>).<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_unicode_letter_case_fold</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)\pZ"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\u{20}'</span>, <span class='string'>'\u{20}'</span>), (<span class='string'>'\u{a0}'</span>, <span class='string'>'\u{a0}'</span>), + (<span class='string'>'\u{1680}'</span>, <span class='string'>'\u{1680}'</span>), (<span class='string'>'\u{2000}'</span>, <span class='string'>'\u{200a}'</span>), + (<span class='string'>'\u{2028}'</span>, <span class='string'>'\u{2029}'</span>), (<span class='string'>'\u{202f}'</span>, <span class='string'>'\u{202f}'</span>), + (<span class='string'>'\u{205f}'</span>, <span class='string'>'\u{205f}'</span>), (<span class='string'>'\u{3000}'</span>, <span class='string'>'\u{3000}'</span>), + ]).<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_unicode_name_negate</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\P{Yi}"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>YI</span>).<span class='ident'>negate</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_unicode_letter_negate</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\PZ"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\u{20}'</span>, <span class='string'>'\u{20}'</span>), (<span class='string'>'\u{a0}'</span>, <span class='string'>'\u{a0}'</span>), + (<span class='string'>'\u{1680}'</span>, <span class='string'>'\u{1680}'</span>), (<span class='string'>'\u{2000}'</span>, <span class='string'>'\u{200a}'</span>), + (<span class='string'>'\u{2028}'</span>, <span class='string'>'\u{2029}'</span>), (<span class='string'>'\u{202f}'</span>, <span class='string'>'\u{202f}'</span>), + (<span class='string'>'\u{205f}'</span>, <span class='string'>'\u{205f}'</span>), (<span class='string'>'\u{3000}'</span>, <span class='string'>'\u{3000}'</span>), + ]).<span class='ident'>negate</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_unicode_name_negate_case_fold</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)\P{Yi}"</span>), + <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>YI</span>).<span class='ident'>negate</span>().<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_unicode_letter_negate_case_fold</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)\PZ"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\u{20}'</span>, <span class='string'>'\u{20}'</span>), (<span class='string'>'\u{a0}'</span>, <span class='string'>'\u{a0}'</span>), + (<span class='string'>'\u{1680}'</span>, <span class='string'>'\u{1680}'</span>), (<span class='string'>'\u{2000}'</span>, <span class='string'>'\u{200a}'</span>), + (<span class='string'>'\u{2028}'</span>, <span class='string'>'\u{2029}'</span>), (<span class='string'>'\u{202f}'</span>, <span class='string'>'\u{202f}'</span>), + (<span class='string'>'\u{205f}'</span>, <span class='string'>'\u{205f}'</span>), (<span class='string'>'\u{3000}'</span>, <span class='string'>'\u{3000}'</span>), + ]).<span class='ident'>negate</span>().<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_perl_d</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\d"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLD</span>))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_perl_s</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\s"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLS</span>))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_perl_w</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\w"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLW</span>))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_perl_d_negate</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\D"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLD</span>).<span class='ident'>negate</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_perl_s_negate</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\S"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLS</span>).<span class='ident'>negate</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_perl_w_negate</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"\W"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLW</span>).<span class='ident'>negate</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_perl_d_case_fold</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)\d"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLD</span>).<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_perl_s_case_fold</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)\s"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLS</span>).<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_perl_w_case_fold</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)\w"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLW</span>).<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_perl_d_case_fold_negate</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)\D"</span>), + <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLD</span>).<span class='ident'>negate</span>().<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_perl_s_case_fold_negate</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)\S"</span>), + <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLS</span>).<span class='ident'>negate</span>().<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>escape_perl_w_case_fold_negate</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)\W"</span>), + <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLW</span>).<span class='ident'>negate</span>().<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_singleton</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[a]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'a'</span>, <span class='string'>'a'</span>)]))); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[\x00]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'\x00'</span>, <span class='string'>'\x00'</span>)]))); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[\n]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'\n'</span>, <span class='string'>'\n'</span>)]))); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"[\n]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'\n'</span>, <span class='string'>'\n'</span>)]))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_singleton_negate</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[^a]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\x00'</span>, <span class='string'>'\x60'</span>), (<span class='string'>'\x62'</span>, <span class='string'>'\u{10FFFF}'</span>), + ]))); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[^\x00]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\x01'</span>, <span class='string'>'\u{10FFFF}'</span>), + ]))); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[^\n]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\x00'</span>, <span class='string'>'\x09'</span>), (<span class='string'>'\x0b'</span>, <span class='string'>'\u{10FFFF}'</span>), + ]))); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"[^\n]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[ + (<span class='string'>'\x00'</span>, <span class='string'>'\x09'</span>), (<span class='string'>'\x0b'</span>, <span class='string'>'\u{10FFFF}'</span>), + ]))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_singleton_class</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[\d]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLD</span>))); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[\p{Yi}]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>YI</span>))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_singleton_class_negate</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[^\d]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLD</span>).<span class='ident'>negate</span>())); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[^\w]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLW</span>).<span class='ident'>negate</span>())); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[^\s]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLS</span>).<span class='ident'>negate</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_singleton_class_negate_negate</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[^\D]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLD</span>))); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[^\W]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLW</span>))); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[^\S]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLS</span>))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_singleton_class_casei</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)[\d]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLD</span>).<span class='ident'>case_fold</span>())); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)[\p{Yi}]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>YI</span>).<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_singleton_class_negate_casei</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)[^\d]"</span>), + <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLD</span>).<span class='ident'>negate</span>().<span class='ident'>case_fold</span>())); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)[^\w]"</span>), + <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLW</span>).<span class='ident'>negate</span>().<span class='ident'>case_fold</span>())); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)[^\s]"</span>), + <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLS</span>).<span class='ident'>negate</span>().<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_singleton_class_negate_negate_casei</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)[^\D]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLD</span>).<span class='ident'>case_fold</span>())); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)[^\W]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLW</span>).<span class='ident'>case_fold</span>())); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)[^\S]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLS</span>).<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_multiple_class</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[\d\p{Yi}]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>classes</span>(<span class='kw-2'>&</span>[ + <span class='ident'>PERLD</span>, <span class='ident'>YI</span>, + ]))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_multiple_class_negate</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[^\d\p{Yi}]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>classes</span>(<span class='kw-2'>&</span>[ + <span class='ident'>PERLD</span>, <span class='ident'>YI</span>, + ]).<span class='ident'>negate</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_multiple_class_negate_negate</span>() { + <span class='kw'>let</span> <span class='ident'>nperld</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='ident'>PERLD</span>).<span class='ident'>negate</span>(); + <span class='kw'>let</span> <span class='ident'>nyi</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='ident'>YI</span>).<span class='ident'>negate</span>(); + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>CharClass</span>::<span class='ident'>empty</span>().<span class='ident'>merge</span>(<span class='ident'>nperld</span>).<span class='ident'>merge</span>(<span class='ident'>nyi</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[^\D\P{Yi}]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>cls</span>.<span class='ident'>negate</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_multiple_class_casei</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)[\d\p{Yi}]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>classes</span>(<span class='kw-2'>&</span>[ + <span class='ident'>PERLD</span>, <span class='ident'>YI</span>, + ]).<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_multiple_class_negate_casei</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)[^\d\p{Yi}]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>classes</span>(<span class='kw-2'>&</span>[ + <span class='ident'>PERLD</span>, <span class='ident'>YI</span>, + ]).<span class='ident'>negate</span>().<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_multiple_class_negate_negate_casei</span>() { + <span class='kw'>let</span> <span class='ident'>nperld</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='ident'>PERLD</span>).<span class='ident'>negate</span>(); + <span class='kw'>let</span> <span class='ident'>nyi</span> <span class='op'>=</span> <span class='ident'>class</span>(<span class='ident'>YI</span>).<span class='ident'>negate</span>(); + <span class='kw'>let</span> <span class='ident'>class</span> <span class='op'>=</span> <span class='ident'>CharClass</span>::<span class='ident'>empty</span>().<span class='ident'>merge</span>(<span class='ident'>nperld</span>).<span class='ident'>merge</span>(<span class='ident'>nyi</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?i)[^\D\P{Yi}]"</span>), + <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>.<span class='ident'>negate</span>().<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_class_hypen</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[\p{Yi}-]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>classes</span>(<span class='kw-2'>&</span>[ + <span class='kw-2'>&</span>[(<span class='string'>'-'</span>, <span class='string'>'-'</span>)], <span class='ident'>YI</span>, + ]))); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"[\p{Yi}-a]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>classes</span>(<span class='kw-2'>&</span>[ + <span class='kw-2'>&</span>[(<span class='string'>'-'</span>, <span class='string'>'-'</span>)], <span class='kw-2'>&</span>[(<span class='string'>'a'</span>, <span class='string'>'a'</span>)], <span class='ident'>YI</span>, + ]))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_brackets</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"[]]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>']'</span>, <span class='string'>']'</span>)]))); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"[][]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'['</span>, <span class='string'>'['</span>), (<span class='string'>']'</span>, <span class='string'>']'</span>)]))); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"[[]]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Concat</span>(<span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'['</span>, <span class='string'>'['</span>)])), + <span class='ident'>lit</span>(<span class='string'>']'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_brackets_hypen</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"[]-]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'-'</span>, <span class='string'>'-'</span>), (<span class='string'>']'</span>, <span class='string'>']'</span>)]))); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"[-]]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Concat</span>(<span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'-'</span>, <span class='string'>'-'</span>)])), + <span class='ident'>lit</span>(<span class='string'>']'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>class_overlapping</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"[a-fd-h]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'a'</span>, <span class='string'>'h'</span>)]))); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"[a-fg-m]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'a'</span>, <span class='string'>'m'</span>)]))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>ascii_class</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"[:upper:]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>UPPER</span>))); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"[[:upper:]]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>UPPER</span>))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>ascii_class_not</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"[:abc:]"</span>), + <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>':'</span>, <span class='string'>':'</span>), (<span class='string'>'a'</span>, <span class='string'>'c'</span>)]))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>ascii_class_multiple</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"[[:lower:][:upper:]]"</span>), + <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>classes</span>(<span class='kw-2'>&</span>[<span class='ident'>UPPER</span>, <span class='ident'>LOWER</span>]))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>ascii_class_negate</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"[[:^upper:]]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>UPPER</span>).<span class='ident'>negate</span>())); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"[^[:^upper:]]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>UPPER</span>))); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>ascii_class_negate_multiple</span>() { + <span class='kw'>let</span> (<span class='ident'>nlower</span>, <span class='ident'>nupper</span>) <span class='op'>=</span> (<span class='ident'>class</span>(<span class='ident'>LOWER</span>).<span class='ident'>negate</span>(), <span class='ident'>class</span>(<span class='ident'>UPPER</span>).<span class='ident'>negate</span>()); + <span class='kw'>let</span> <span class='ident'>cls</span> <span class='op'>=</span> <span class='ident'>CharClass</span>::<span class='ident'>empty</span>().<span class='ident'>merge</span>(<span class='ident'>nlower</span>).<span class='ident'>merge</span>(<span class='ident'>nupper</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"[[:^lower:][:^upper:]]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>cls</span>.<span class='ident'>clone</span>())); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"[^[:^lower:][:^upper:]]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>cls</span>.<span class='ident'>negate</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>ascii_class_case_fold</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?i)[:upper:]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>UPPER</span>).<span class='ident'>case_fold</span>())); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?i)[[:upper:]]"</span>), + <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>UPPER</span>).<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>ascii_class_negate_case_fold</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?i)[[:^upper:]]"</span>), + <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>UPPER</span>).<span class='ident'>negate</span>().<span class='ident'>case_fold</span>())); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?i)[^[:^upper:]]"</span>), + <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>UPPER</span>).<span class='ident'>case_fold</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>ignore_space_literal</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?x) a b c"</span>), <span class='ident'>Expr</span>::<span class='ident'>Concat</span>(<span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>lit</span>(<span class='string'>'a'</span>), <span class='ident'>lit</span>(<span class='string'>'b'</span>), <span class='ident'>lit</span>(<span class='string'>'c'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>ignore_space_literal_off</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?x) a b c(?-x) a"</span>), <span class='ident'>Expr</span>::<span class='ident'>Concat</span>(<span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>lit</span>(<span class='string'>'a'</span>), <span class='ident'>lit</span>(<span class='string'>'b'</span>), <span class='ident'>lit</span>(<span class='string'>'c'</span>), <span class='ident'>lit</span>(<span class='string'>' '</span>), <span class='ident'>lit</span>(<span class='string'>'a'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>ignore_space_class</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?x)[a + - z +]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'a'</span>, <span class='string'>'z'</span>)]))); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>"(?x)[ ^ a + - z +]"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='kw-2'>&</span>[(<span class='string'>'a'</span>, <span class='string'>'z'</span>)]).<span class='ident'>negate</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>ignore_space_escape</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?x)\ d"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLD</span>))); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?x)\ + D"</span>), <span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLD</span>).<span class='ident'>negate</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>ignore_space_comments</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?x)(?P<foo> + a # comment 1 +)(?P<bar> + z # comment 2 +)"</span>), <span class='ident'>Expr</span>::<span class='ident'>Concat</span>(<span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>i</span>: <span class='prelude-val'>Some</span>(<span class='number'>1</span>), + <span class='ident'>name</span>: <span class='prelude-val'>Some</span>(<span class='string'>"foo"</span>.<span class='ident'>into</span>()), + }, + <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>lit</span>(<span class='string'>'z'</span>)), + <span class='ident'>i</span>: <span class='prelude-val'>Some</span>(<span class='number'>2</span>), + <span class='ident'>name</span>: <span class='prelude-val'>Some</span>(<span class='string'>"bar"</span>.<span class='ident'>into</span>()), + }, + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>ignore_space_comments_re_enable</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?x)a # hi +(?-x:#) # sweet"</span>), <span class='ident'>Expr</span>::<span class='ident'>Concat</span>(<span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>lit</span>(<span class='string'>'a'</span>), + <span class='ident'>Expr</span>::<span class='ident'>Group</span> { + <span class='ident'>e</span>: <span class='ident'>Box</span>::<span class='ident'>new</span>(<span class='ident'>lit</span>(<span class='string'>'#'</span>)), + <span class='ident'>i</span>: <span class='prelude-val'>None</span>, + <span class='ident'>name</span>: <span class='prelude-val'>None</span>, + }, + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>ignore_space_escape_punctuation</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?x)\\\.\+\*\?\(\)\|\[\]\{\}\^\$\#"</span>), <span class='ident'>c</span>(<span class='kw-2'>&</span>[ + <span class='ident'>lit</span>(<span class='string'>'\\'</span>), <span class='ident'>lit</span>(<span class='string'>'.'</span>), <span class='ident'>lit</span>(<span class='string'>'+'</span>), <span class='ident'>lit</span>(<span class='string'>'*'</span>), <span class='ident'>lit</span>(<span class='string'>'?'</span>), + <span class='ident'>lit</span>(<span class='string'>'('</span>), <span class='ident'>lit</span>(<span class='string'>')'</span>), <span class='ident'>lit</span>(<span class='string'>'|'</span>), <span class='ident'>lit</span>(<span class='string'>'['</span>), <span class='ident'>lit</span>(<span class='string'>']'</span>), + <span class='ident'>lit</span>(<span class='string'>'{'</span>), <span class='ident'>lit</span>(<span class='string'>'}'</span>), <span class='ident'>lit</span>(<span class='string'>'^'</span>), <span class='ident'>lit</span>(<span class='string'>'$'</span>), <span class='ident'>lit</span>(<span class='string'>'#'</span>), + ])); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>ignore_space_escape_hash</span>() { + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>p</span>(<span class='string'>r"(?x)a\# # hi there"</span>), <span class='ident'>Expr</span>::<span class='ident'>Concat</span>(<span class='macro'>vec</span><span class='macro'>!</span>[ + <span class='ident'>lit</span>(<span class='string'>'a'</span>), + <span class='ident'>lit</span>(<span class='string'>'#'</span>), + ])); + } + + <span class='comment'>// Test every single possible error case.</span> + + <span class='macro'>macro_rules</span><span class='macro'>!</span> <span class='ident'>test_err</span> { + (<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>re</span>:<span class='ident'>expr</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>pos</span>:<span class='ident'>expr</span>, <span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>kind</span>:<span class='ident'>expr</span>) <span class='op'>=></span> {{ + <span class='kw'>let</span> <span class='ident'>err</span> <span class='op'>=</span> <span class='ident'>Parser</span>::<span class='ident'>parse</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>re</span>).<span class='ident'>unwrap_err</span>(); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>pos</span>, <span class='ident'>err</span>.<span class='ident'>pos</span>); + <span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>kind</span>, <span class='ident'>err</span>.<span class='ident'>kind</span>); + <span class='macro'>assert</span><span class='macro'>!</span>(<span class='macro-nonterminal'>$</span><span class='macro-nonterminal'>re</span>.<span class='ident'>contains</span>(<span class='kw-2'>&</span><span class='ident'>err</span>.<span class='ident'>surround</span>)); + }} + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_repeat_no_expr_simple</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"(*"</span>, <span class='number'>1</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>RepeaterExpectsExpr</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_repeat_no_expr_counted</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"({5}"</span>, <span class='number'>1</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>RepeaterExpectsExpr</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_repeat_beginning_counted</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"{5}"</span>, <span class='number'>0</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>RepeaterExpectsExpr</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_repeat_illegal_exprs_simple</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"a**"</span>, <span class='number'>2</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>RepeaterUnexpectedExpr</span>(<span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>ZeroOrMore</span>, + <span class='ident'>greedy</span>: <span class='boolval'>true</span>, + })); + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"a|*"</span>, <span class='number'>2</span>, + <span class='ident'>ErrorKind</span>::<span class='ident'>RepeaterUnexpectedExpr</span>(<span class='ident'>Expr</span>::<span class='ident'>Alternate</span>(<span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>lit</span>(<span class='string'>'a'</span>)])) + ); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_repeat_illegal_exprs_counted</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"a*{5}"</span>, <span class='number'>2</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>RepeaterUnexpectedExpr</span>(<span class='ident'>Expr</span>::<span class='ident'>Repeat</span> { + <span class='ident'>e</span>: <span class='ident'>b</span>(<span class='ident'>lit</span>(<span class='string'>'a'</span>)), + <span class='ident'>r</span>: <span class='ident'>Repeater</span>::<span class='ident'>ZeroOrMore</span>, + <span class='ident'>greedy</span>: <span class='boolval'>true</span>, + })); + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"a|{5}"</span>, <span class='number'>2</span>, + <span class='ident'>ErrorKind</span>::<span class='ident'>RepeaterUnexpectedExpr</span>(<span class='ident'>Expr</span>::<span class='ident'>Alternate</span>(<span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>lit</span>(<span class='string'>'a'</span>)])) + ); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_repeat_empty_number</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"a{}"</span>, <span class='number'>2</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>MissingBase10</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_repeat_eof</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"a{5"</span>, <span class='number'>3</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnclosedRepeat</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_repeat_empty_number_eof</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"a{xyz"</span>, <span class='number'>5</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidBase10</span>(<span class='string'>"xyz"</span>.<span class='ident'>into</span>())); + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"a{12,xyz"</span>, <span class='number'>8</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidBase10</span>(<span class='string'>"xyz"</span>.<span class='ident'>into</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_repeat_invalid_number</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"a{9999999999}"</span>, <span class='number'>12</span>, + <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidBase10</span>(<span class='string'>"9999999999"</span>.<span class='ident'>into</span>())); + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"a{1,9999999999}"</span>, <span class='number'>14</span>, + <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidBase10</span>(<span class='string'>"9999999999"</span>.<span class='ident'>into</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_repeat_invalid_number_extra</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"a{12x}"</span>, <span class='number'>5</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidBase10</span>(<span class='string'>"12x"</span>.<span class='ident'>into</span>())); + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"a{1,12x}"</span>, <span class='number'>7</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidBase10</span>(<span class='string'>"12x"</span>.<span class='ident'>into</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_repeat_invalid_range</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"a{2,1}"</span>, <span class='number'>5</span>, + <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidRepeatRange</span> { <span class='ident'>min</span>: <span class='number'>2</span>, <span class='ident'>max</span>: <span class='number'>1</span> }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_alternate_empty</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"|a"</span>, <span class='number'>0</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>EmptyAlternate</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_alternate_empty_with_group</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"(|a)"</span>, <span class='number'>1</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>EmptyAlternate</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_alternate_empty_with_alternate</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"a||"</span>, <span class='number'>2</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>EmptyAlternate</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_close_paren_unopened_empty</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>")"</span>, <span class='number'>0</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnopenedParen</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_close_paren_unopened</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"ab)"</span>, <span class='number'>2</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnopenedParen</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_close_paren_unopened_with_alt</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"a|b)"</span>, <span class='number'>3</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnopenedParen</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_close_paren_empty_alt</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"(a|)"</span>, <span class='number'>3</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>EmptyAlternate</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_close_paren_empty_group</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"()"</span>, <span class='number'>1</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>EmptyGroup</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_close_paren_empty_group_with_name</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"(?P<foo>)"</span>, <span class='number'>8</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>EmptyGroup</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_finish_concat_unclosed</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"ab(xy"</span>, <span class='number'>2</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnclosedParen</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_finish_concat_empty_alt</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"a|"</span>, <span class='number'>2</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>EmptyAlternate</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_group_name_invalid</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"(?P<a#>x)"</span>, <span class='number'>6</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidCaptureName</span>(<span class='string'>"a#"</span>.<span class='ident'>into</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_group_name_invalid_leading</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"(?P<1a>a)"</span>, <span class='number'>6</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidCaptureName</span>(<span class='string'>"1a"</span>.<span class='ident'>into</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_group_name_unexpected_eof</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"(?P<a"</span>, <span class='number'>5</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnclosedCaptureName</span>(<span class='string'>"a"</span>.<span class='ident'>into</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_group_name_empty</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"(?P<>a)"</span>, <span class='number'>4</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>EmptyCaptureName</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_group_opts_unrecognized_flag</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"(?z:a)"</span>, <span class='number'>2</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnrecognizedFlag</span>(<span class='string'>'z'</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_group_opts_unexpected_eof</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"(?i"</span>, <span class='number'>3</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedFlagEof</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_group_opts_double_negation</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"(?-i-s:a)"</span>, <span class='number'>4</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>DoubleFlagNegation</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_group_opts_empty_negation</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"(?i-:a)"</span>, <span class='number'>4</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>EmptyFlagNegation</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_group_opts_empty</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"(?)"</span>, <span class='number'>2</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>EmptyFlagNegation</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_escape_unexpected_eof</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"\"</span>, <span class='number'>1</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedEscapeEof</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_escape_unrecognized</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"\m"</span>, <span class='number'>1</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnrecognizedEscape</span>(<span class='string'>'m'</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_escape_hex2_eof0</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"\x"</span>, <span class='number'>2</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedTwoDigitHexEof</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_escape_hex2_eof1</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"\xA"</span>, <span class='number'>3</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedTwoDigitHexEof</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_escape_hex2_invalid</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"\xAG"</span>, <span class='number'>4</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidBase16</span>(<span class='string'>"AG"</span>.<span class='ident'>into</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_escape_hex_eof0</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"\x{"</span>, <span class='number'>3</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidBase16</span>(<span class='string'>""</span>.<span class='ident'>into</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_escape_hex_eof1</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"\x{A"</span>, <span class='number'>4</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnclosedHex</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_escape_hex_invalid</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"\x{AG}"</span>, <span class='number'>5</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidBase16</span>(<span class='string'>"AG"</span>.<span class='ident'>into</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_escape_hex_invalid_scalar_value_surrogate</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"\x{D800}"</span>, <span class='number'>7</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidScalarValue</span>(<span class='number'>0xD800</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_escape_hex_invalid_scalar_value_high</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"\x{110000}"</span>, <span class='number'>9</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidScalarValue</span>(<span class='number'>0x110000</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_escape_hex_invalid_u32</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"\x{9999999999}"</span>, <span class='number'>13</span>, + <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidBase16</span>(<span class='string'>"9999999999"</span>.<span class='ident'>into</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_unicode_unclosed</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"\p{"</span>, <span class='number'>3</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnclosedUnicodeName</span>); + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"\p{Greek"</span>, <span class='number'>8</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnclosedUnicodeName</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_unicode_no_letter</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"\p"</span>, <span class='number'>2</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedEscapeEof</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_unicode_unknown_letter</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"\pA"</span>, <span class='number'>3</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnrecognizedUnicodeClass</span>(<span class='string'>"A"</span>.<span class='ident'>into</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_unicode_unknown_name</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"\p{Yii}"</span>, <span class='number'>7</span>, + <span class='ident'>ErrorKind</span>::<span class='ident'>UnrecognizedUnicodeClass</span>(<span class='string'>"Yii"</span>.<span class='ident'>into</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_class_eof_empty</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"["</span>, <span class='number'>1</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedClassEof</span>); + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"[^"</span>, <span class='number'>2</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedClassEof</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_class_eof_non_empty</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"[a"</span>, <span class='number'>2</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedClassEof</span>); + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"[^a"</span>, <span class='number'>3</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedClassEof</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_class_eof_range</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"[a-"</span>, <span class='number'>3</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedClassEof</span>); + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"[^a-"</span>, <span class='number'>4</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedClassEof</span>); + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"[---"</span>, <span class='number'>4</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedClassEof</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_class_invalid_escape</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"[\pA]"</span>, <span class='number'>4</span>, + <span class='ident'>ErrorKind</span>::<span class='ident'>UnrecognizedUnicodeClass</span>(<span class='string'>"A"</span>.<span class='ident'>into</span>())); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_class_valid_escape_not_allowed</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"[\A]"</span>, <span class='number'>3</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidClassEscape</span>(<span class='ident'>Expr</span>::<span class='ident'>StartText</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_class_range_valid_escape_not_allowed</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"[a-\d]"</span>, <span class='number'>5</span>, + <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidClassEscape</span>(<span class='ident'>Expr</span>::<span class='ident'>Class</span>(<span class='ident'>class</span>(<span class='ident'>PERLD</span>)))); + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"[a-\A]"</span>, <span class='number'>5</span>, + <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidClassEscape</span>(<span class='ident'>Expr</span>::<span class='ident'>StartText</span>)); + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>r"[\A-a]"</span>, <span class='number'>3</span>, + <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidClassEscape</span>(<span class='ident'>Expr</span>::<span class='ident'>StartText</span>)); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_class_invalid_range</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"[z-a]"</span>, <span class='number'>4</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>InvalidClassRange</span> { + <span class='ident'>start</span>: <span class='string'>'z'</span>, + <span class='ident'>end</span>: <span class='string'>'a'</span>, + }); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_class_empty_range</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"[]"</span>, <span class='number'>2</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedClassEof</span>); + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"[^]"</span>, <span class='number'>3</span>, <span class='ident'>ErrorKind</span>::<span class='ident'>UnexpectedClassEof</span>); + } + + <span class='attribute'>#[<span class='ident'>test</span>]</span> + <span class='kw'>fn</span> <span class='ident'>error_duplicate_capture_name</span>() { + <span class='macro'>test_err</span><span class='macro'>!</span>(<span class='string'>"(?P<a>.)(?P<a>.)"</span>, <span class='number'>14</span>, + <span class='ident'>ErrorKind</span>::<span class='ident'>DuplicateCaptureName</span>(<span class='string'>"a"</span>.<span class='ident'>into</span>())); + } +} +</pre> +</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>⇤</dt> + <dd>Move up in search results</dd> + <dt>⇥</dt> + <dd>Move down in search results</dd> + <dt>⏎</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 = "regex_syntax"; + window.playgroundUrl = ""; + </script> + <script src="../../jquery.js"></script> + <script src="../../main.js"></script> + + <script async src="../../search-index.js"></script> +</body> +</html>
\ No newline at end of file |