aboutsummaryrefslogtreecommitdiff
path: root/doc/ltn12.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/ltn12.html')
-rw-r--r--doc/ltn12.html41
1 files changed, 22 insertions, 19 deletions
diff --git a/doc/ltn12.html b/doc/ltn12.html
index 363ce43..7b379c2 100644
--- a/doc/ltn12.html
+++ b/doc/ltn12.html
@@ -35,13 +35,21 @@
35 35
36<h2 id=ltn12>LTN12</h2> 36<h2 id=ltn12>LTN12</h2>
37 37
38<p> The LTN12 module implements the ideas described in 38<p> The <tt>ltn12</tt> namespace implements the ideas described in
39<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks"> 39<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">
40LTN012, Filters sources and sinks</a>. This manual simply describe the 40LTN012, Filters sources and sinks</a>. This manual simply describes the
41functions. Please refer to the LTN for a deeper explanation of the 41functions. Please refer to the LTN for a deeper explanation of the
42functionality provided by this module. 42functionality provided by this module.
43</p> 43</p>
44 44
45<p class=description> To obtain the <tt>ltn12</tt> namespace, run:
46</p>
47
48<pre class=example>
49-- loads the LTN21 module
50local ltn12 = require("ltn12")
51</pre>
52
45<!-- filters ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 53<!-- filters ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
46 54
47<h3 id="filter">Filters</h3> 55<h3 id="filter">Filters</h3>
@@ -68,15 +76,15 @@ The function returns the chained filter.
68</p> 76</p>
69 77
70<p class=note> 78<p class=note>
71The nesting of filters can be arbritrary. For instance, the useless filter 79The nesting of filters can be arbitrary. For instance, the useless filter
72below doesn't do anything but return the data that was passed to it, 80below doesn't do anything but return the data that was passed to it,
73unaltered. 81unaltered.
74</p> 82</p>
75 83
76<pre class=example> 84<pre class=example>
77-- load required modules 85-- load required modules
78ltn12 = require("ltn12") 86local ltn12 = require("ltn12")
79mime = require("mime") 87local mime = require("mime")
80 88
81-- create a silly identity filter 89-- create a silly identity filter
82id = ltn12.filter.chain( 90id = ltn12.filter.chain(
@@ -165,12 +173,7 @@ ltn12.sink.<b>chain(</b>filter, sink<b>)</b>
165</p> 173</p>
166 174
167<p class=description> 175<p class=description>
168Creates a new sink that passes data through a <tt>filter</tt> before sending 176Creates and returns a new sink that passes data through a <tt>filter</tt> before sending it to a given <tt>sink</tt>.
169it to a given <tt>sink</tt>.
170</p>
171
172<p class=return>
173The function returns the new sink.
174</p> 177</p>
175 178
176<!-- error ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 179<!-- error ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@@ -180,7 +183,7 @@ ltn12.sink.<b>error(</b>message<b>)</b>
180</p> 183</p>
181 184
182<p class=description> 185<p class=description>
183Creates and returns a sink that aborts transmission with an error 186Creates and returns a sink that aborts transmission with the error
184<tt>message</tt>. 187<tt>message</tt>.
185</p> 188</p>
186 189
@@ -202,7 +205,7 @@ Creates a sink that sends data to a file.
202<p class=return> 205<p class=return>
203The function returns a sink that sends all data to the given <tt>handle</tt> 206The function returns a sink that sends all data to the given <tt>handle</tt>
204and closes the file when done, or a sink that aborts the transmission with 207and closes the file when done, or a sink that aborts the transmission with
205an error <tt>message</tt> 208the error <tt>message</tt>
206</p> 209</p>
207 210
208<p class=note> 211<p class=note>
@@ -258,7 +261,7 @@ efficiently concatenated into a single string.
258</p> 261</p>
259 262
260<p class=return> 263<p class=return>
261The function returns the sink and the table. 264The function returns the sink and the table used to store the chunks.
262</p> 265</p>
263 266
264<pre class=example> 267<pre class=example>
@@ -266,14 +269,14 @@ The function returns the sink and the table.
266local http = require("http") 269local http = require("http")
267local ltn12 = require("ltn12") 270local ltn12 = require("ltn12")
268 271
269-- the http.get function 272-- a simplified http.get function
270function get(u) 273function http.get(u)
271 local t = {} 274 local t = {}
272 local respt = request{ 275 local respt = request{
273 url = u, 276 url = u,
274 sink = ltn12.sink.table(t) 277 sink = ltn12.sink.table(t)
275 } 278 }
276 return table.concat(t), respt.headers, respt.code, respt.error 279 return table.concat(t), respt.headers, respt.code
277end 280end
278</pre> 281</pre>
279 282
@@ -334,7 +337,7 @@ ltn12.source.<b>error(</b>message<b>)</b>
334</p> 337</p>
335 338
336<p class=description> 339<p class=description>
337Creates and returns a source that aborts transmission with an error 340Creates and returns a source that aborts transmission with the error
338<tt>message</tt>. 341<tt>message</tt>.
339</p> 342</p>
340 343
@@ -357,7 +360,7 @@ Creates a source that produces the contents of a file.
357The function returns a source that reads chunks of data from 360The function returns a source that reads chunks of data from
358given <tt>handle</tt> and returns it to the user, 361given <tt>handle</tt> and returns it to the user,
359closing the file when done, or a source that aborts the transmission with 362closing the file when done, or a source that aborts the transmission with
360an error <tt>message</tt> 363the error <tt>message</tt>
361</p> 364</p>
362 365
363<p class=note> 366<p class=note>