pub struct Header {
pub name: String,
/* private fields */
}
Expand description
Represents an RFC 822 Header [unstable]
Fields§
§name: String
The name of this header
Implementations§
Source§impl Header
impl Header
Sourcepub fn new(name: String, value: String) -> Header
pub fn new(name: String, value: String) -> Header
Creates a new Header for the given name
and value
[unstable]
Sourcepub fn new_with_value<T: ToFoldedHeader>(
name: String,
value: T,
) -> ParsingResult<Header>
pub fn new_with_value<T: ToFoldedHeader>( name: String, value: T, ) -> ParsingResult<Header>
Creates a new Header for the given name
and value
,
as converted through the ToHeader
or ToFoldedHeader
trait.
Returns None if the value failed to be converted. [unstable]
Examples found in repository?
examples/printing.rs (lines 18-34)
5fn main() {
6 let parts = vec![
7 MimeMessage::new("First part".to_string()),
8 MimeMessage::new("Second part".to_string()),
9 ];
10
11 let mut message = MimeMessage::new("Parent".to_string());
12
13 for part in parts.into_iter() {
14 message.children.push(part);
15 }
16
17 message.headers.insert(
18 Header::new_with_value(
19 "To".to_string(),
20 vec![
21 Address::new_mailbox_with_name(
22 "John Doe".to_string(),
23 "john@example.org".to_string(),
24 ),
25 Address::new_mailbox_with_name(
26 "Joe Blogs".to_string(),
27 "joe@example.org".to_string(),
28 ),
29 Address::new_mailbox_with_name(
30 "Mr Black".to_string(),
31 "mafia_black@example.org".to_string(),
32 ),
33 ],
34 )
35 .unwrap(),
36 );
37
38 message.update_headers();
39
40 println!("{}", message.as_string());
41}
Sourcepub fn get_value<T: FromHeader>(&self) -> ParsingResult<T>
pub fn get_value<T: FromHeader>(&self) -> ParsingResult<T>
Get the value represented by this header, as parsed
into whichever type T
[unstable]
Trait Implementations§
impl Eq for Header
impl StructuralPartialEq for Header
Auto Trait Implementations§
impl Freeze for Header
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnwindSafe for Header
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more