8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
+ //! Really Bad Markup Language (rbml) is a temporary measure until we migrate
12
+ //! the rust object metadata to a better serialization format. It is not
13
+ //! intended to be used by users.
14
+ //!
15
+ //! It is loosely based on the Extensible Binary Markup Language (ebml):
16
+ //! http://www.matroska.org/technical/specs/rfc/index.html
17
+
18
+ #![ crate_name = "rbml" ]
19
+ #![ experimental]
20
+ #![ crate_type = "rlib" ]
21
+ #![ crate_type = "dylib" ]
22
+ #![ license = "MIT/ASL2" ]
23
+ #![ doc( html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png" ,
24
+ html_favicon_url = "http://www.rust-lang.org/favicon.ico" ,
25
+ html_root_url = "http://doc.rust-lang.org/master/" ,
26
+ html_playground_url = "http://play.rust-lang.org/" ) ]
27
+ #![ feature( macro_rules, phase) ]
11
28
#![ allow( missing_doc) ]
12
29
30
+ extern crate serialize;
31
+
32
+ #[ phase( plugin, link) ] extern crate log;
33
+ #[ cfg( test) ] extern crate test;
34
+
13
35
use std:: io;
14
36
use std:: str;
15
37
16
- // Simple Extensible Binary Markup Language (ebml) reader and writer on a
17
- // cursor model. See the specification here:
18
- // http://www.matroska.org/technical/specs/rfc/index.html
19
38
20
- // Common data structures
39
+ /// Common data structures
21
40
#[ deriving( Clone ) ]
22
41
pub struct Doc < ' a > {
23
42
pub data : & ' a [ u8 ] ,
@@ -107,7 +126,7 @@ pub mod reader {
107
126
Expected } ;
108
127
109
128
pub type DecodeResult < T > = Result < T , Error > ;
110
- // ebml reading
129
+ // rbml reading
111
130
112
131
macro_rules! try_or(
113
132
( $e: expr, $r: expr) => (
@@ -637,7 +656,7 @@ pub mod writer {
637
656
638
657
pub type EncodeResult = io:: IoResult < ( ) > ;
639
658
640
- // ebml writing
659
+ // rbml writing
641
660
pub struct Encoder < ' a , W > {
642
661
pub writer : & ' a mut W ,
643
662
size_positions : Vec < uint > ,
@@ -671,7 +690,7 @@ pub mod writer {
671
690
} )
672
691
}
673
692
674
- // FIXME (#2741): Provide a function to write the standard ebml header.
693
+ // FIXME (#2741): Provide a function to write the standard rbml header.
675
694
impl < ' a , W : Writer + Seek > Encoder < ' a , W > {
676
695
pub fn new ( w : & ' a mut W ) -> Encoder < ' a , W > {
677
696
Encoder {
@@ -1018,10 +1037,8 @@ pub mod writer {
1018
1037
1019
1038
#[ cfg( test) ]
1020
1039
mod tests {
1021
- use super :: Doc ;
1022
- use ebml:: reader;
1023
- use ebml:: writer;
1024
- use { Encodable , Decodable } ;
1040
+ use super :: { Doc , reader, writer} ;
1041
+ use serialize:: { Encodable , Decodable } ;
1025
1042
1026
1043
use std:: io:: { IoError , IoResult , SeekStyle } ;
1027
1044
use std:: io;
@@ -1196,11 +1213,11 @@ mod tests {
1196
1213
debug ! ( "v == {}" , v) ;
1197
1214
let mut wr = SeekableMemWriter :: new ( ) ;
1198
1215
{
1199
- let mut ebml_w = writer:: Encoder :: new ( & mut wr) ;
1200
- let _ = v. encode ( & mut ebml_w ) ;
1216
+ let mut rbml_w = writer:: Encoder :: new ( & mut wr) ;
1217
+ let _ = v. encode ( & mut rbml_w ) ;
1201
1218
}
1202
- let ebml_doc = Doc :: new ( wr. get_ref ( ) ) ;
1203
- let mut deser = reader:: Decoder :: new ( ebml_doc ) ;
1219
+ let rbml_doc = Doc :: new ( wr. get_ref ( ) ) ;
1220
+ let mut deser = reader:: Decoder :: new ( rbml_doc ) ;
1204
1221
let v1 = Decodable :: decode ( & mut deser) . unwrap ( ) ;
1205
1222
debug ! ( "v1 == {}" , v1) ;
1206
1223
assert_eq ! ( v, v1) ;
@@ -1215,9 +1232,8 @@ mod tests {
1215
1232
#[ cfg( test) ]
1216
1233
mod bench {
1217
1234
#![ allow( non_snake_case_functions) ]
1218
- extern crate test;
1219
- use self :: test:: Bencher ;
1220
- use ebml:: reader;
1235
+ use test:: Bencher ;
1236
+ use super :: reader;
1221
1237
1222
1238
#[ bench]
1223
1239
pub fn vuint_at_A_aligned ( b : & mut Bencher ) {
0 commit comments