]> gitweb.factorcode.org Git - factor.git/blob - basis/io/streams/null/null.factor
040301013a5245d7d37ed1aa07672be8be51d31a
[factor.git] / basis / io / streams / null / null.factor
1 ! Copyright (C) 2007, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel io destructors io.streams.plain ;
4 IN: io.streams.null
5
6 SINGLETONS: null-reader null-writer ;
7 UNION: null-stream null-reader null-writer ;
8 INSTANCE: null-writer plain-writer
9
10 M: null-stream dispose drop ;
11
12 M: null-reader stream-element-type drop +byte+ ;
13 M: null-reader stream-readln drop f ;
14 M: null-reader stream-read1 drop f ;
15 M: null-reader stream-read-until 2drop f f ;
16 M: null-reader stream-read 2drop f ;
17 M: null-reader stream-peek1 drop f ;
18 M: null-reader stream-peek 2drop f ;
19
20 M: null-writer stream-element-type drop +byte+ ;
21 M: null-writer stream-write1 2drop ;
22 M: null-writer stream-write 2drop ;
23 M: null-writer stream-flush drop ;
24
25 : with-null-reader ( quot -- )
26     null-reader swap with-input-stream* ; inline
27
28 : with-null-writer ( quot -- )
29     null-writer swap with-output-stream* ; inline