1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use std::vec::Vec;

/// A struct which can either store byte information or a url
#[derive (Eq, PartialEq, Debug)]
pub enum Uri {
	Url {
		url : String
	},
	Bytes {
		val : Vec<u8>,
		mime : String
	},
}

impl Uri {
	/// Creates a new url from a string
	pub fn new_url (string : String) -> Uri {
		Uri::Url{url : string}
	}

	/// Creates a new bytes from a vec
	pub fn new_bytes (bytes : Vec<u8>, mime : String) -> Uri {
		Uri::Bytes{val : bytes, mime : mime}
	}
	
	/// Creates a new bytes from a &[u8]
	pub fn new_bytes_array (bytes : &[u8], mime : String) -> Uri {
		Uri::Bytes{val : bytes.to_vec(), mime : mime}
	}
}