Skip to content

Commit 096be5c

Browse files
committed
Merge pull request #14 from reem/fix/static-linking
(fix) Define RawMediaType in content_type for static linking.
2 parents 5c417bd + ea1270b commit 096be5c

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

generator/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ use download::{download_mimes, parse_mimes};
3535

3636
mod download;
3737

38-
pub struct RawMediaType {
39-
pub type_: &'static str,
40-
pub subtype: &'static str
41-
}
42-
43-
4438
#[plugin_registrar]
4539
#[doc(hidden)]
4640
pub fn plugin_registrar(reg: &mut Registry) {

src/lib.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,24 @@
1212
#[phase(plugin)] extern crate phf_mac;
1313

1414
extern crate http;
15-
extern crate generator;
1615
extern crate phf;
1716

18-
use generator::RawMediaType;
1917
use http::headers::content_type::MediaType;
2018

2119
static MIMES: phf::Map<&'static str, RawMediaType>
2220
= mime_map!("http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types");
2321

22+
// Generator uses RawMediaType unhygiencally. We could create another
23+
// crate and put it there, but sticking the definition here is much
24+
// easier.
25+
//
26+
// That said, this is a hack to avoid having to link against generator
27+
// after compile-time.
28+
struct RawMediaType {
29+
pub type_: &'static str,
30+
pub subtype: &'static str
31+
}
32+
2433
/// Get the rust-http MediaType associated with this extension.
2534
pub fn get_content_type(ext: &str) -> Option<MediaType> {
2635
MIMES.find_equiv(ext)
@@ -40,3 +49,4 @@ fn test_basic() {
4049
assert_eq!(get_content_type("flv").unwrap(),
4150
MediaType { type_: "video".to_string(), subtype: "x-flv".to_string(), parameters: vec![] });
4251
}
52+

0 commit comments

Comments
 (0)