[src]
pub fn to_string(self): string {
return (self as _Mime).to_string();
}
Format a Mime type.
[src]
pub fn to_string(self): string {
return (self as _Mime).to_string();
}
Format a Mime type.
Format a Mime type.
Example
use std.mime.{self, Mime};
assert_eq mime.TEXT_PLAIN.to_string(), "text/plain";
[src]
pub fn guess(path: string): Mime? {
return _Mime.guess(path).map(|mime| mime as Mime);
}
Guess the MIME type of path
by its extension.
No disk access is performed.
The search is case-insensitive.
[src]
pub fn guess(path: string): Mime? {
return _Mime.guess(path).map(|mime| mime as Mime);
}
Guess the MIME type of path
by its extension.
No disk access is performed.
The search is case-insensitive.
Guess the MIME type of path
by its extension.
No disk access is performed.
The search is case-insensitive.
Note
Guess is the operative word here, as there are no guarantees that the contents of the
file that path
points to match the MIME type associated with the path's extension.
Take care when processing files with assumptions based on the return value of this function.
Example
use std.mime.{self, Mime};
let m = Mime.guess("some_file.gif");
assert_eq m, mime.IMAGE_GIF;
[src]
pub fn parse(s: string): Mime throws MimeError {
return try _Mime.parse(s) as Mime;
}
Parses string into a Mime type.
[src]
pub fn parse(s: string): Mime throws MimeError {
return try _Mime.parse(s) as Mime;
}
Parses string into a Mime type.
Parses string into a Mime type.
Example
use std.mime.Mime;
let mime = try! Mime.parse("text/plain; charset=utf-8");
[src]
pub fn type_(self): string {
return (self as _Mime).type_();
}
Get the top level media type for this Mime
.
[src]
pub fn type_(self): string {
return (self as _Mime).type_();
}
Get the top level media type for this Mime
.
Get the top level media type for this Mime
.
Example
use std.mime.Mime;
let mime = try! Mime.parse("text/plain; charset=utf-8");
assert_eq mime.type_(), "text";
[src]
pub fn subtype(self): string {
return (self as _Mime).subtype();
}
Get the top level media type for this Mime
.
[src]
pub fn subtype(self): string {
return (self as _Mime).subtype();
}
Get the top level media type for this Mime
.
Get the top level media type for this Mime
.
Example
use std.mime.Mime;
let mime = try! Mime.parse("text/plain; charset=utf-8");
assert_eq mime.subtype(), "plain";
[src]
pub fn suffix(self): string? {
return (self as _Mime).suffix();
}
Get the optional +suffix for this Mime
.
[src]
pub fn suffix(self): string? {
return (self as _Mime).suffix();
}
Get the optional +suffix for this Mime
.
Get the optional +suffix for this Mime
.
Example
use std.mime.Mime;
let mime = try! Mime.parse("text/plain; charset=utf-8");
assert_eq mime.suffix(), nil;
let mime = try! Mime.parse("image/svg+xml; charset=utf-8");
assert_eq mime.suffix(), "xml";
[src]
pub fn get_param(self, attr: string): string? {
return (self as _Mime).get_param(attr);
}
Look up a parameter by name.
[src]
pub fn get_param(self, attr: string): string? {
return (self as _Mime).get_param(attr);
}
Look up a parameter by name.
Look up a parameter by name.
Example
use std.mime.Mime;
let mime = try! Mime.parse("text/plain; charset=utf-8");
assert_eq mime.get_param("boundary"), nil;
let mime = try! Mime.parse("multipart/form-data; boundary=ABCDEFG");
assert_eq mime.get_param("boundary"), "ABCDEFG";
[src]
pub fn params(self): <string, string> {
return (self as _Mime).params();
}
Returns a map of the parameters.
[src]
pub fn params(self): <string, string> {
return (self as _Mime).params();
}
Returns a map of the parameters.
Returns a map of the parameters.
Example
use std.mime.Mime;
let mime = try! Mime.parse("text/plain");
assert_eq mime.params(), {:};
let mime = try! Mime.parse("text/plain; charset=utf-8");
assert_eq mime.params(), {"charset": "utf-8"};
let mime = try! Mime.parse("multipart/form-data; boundary=ABCDEFG");
assert_eq mime.params()["boundary"], "ABCDEFG";
essence_string
pub fn essence_string(self): string
[src]
pub fn essence_string(self): string {
return (self as _Mime).essence_string();
}
Return a string of the Mime's ["essence"][essence].
essence_string
pub fn essence_string(self): string
[src]
pub fn essence_string(self): string {
return (self as _Mime).essence_string();
}
Return a string of the Mime's ["essence"][essence].
Return a string of the Mime's "essence".
Example
use std.mime.Mime;
let mime = try! Mime.parse("text/plain; charset=utf-8");
assert_eq mime.essence_string(), "text/plain";