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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
use crate::MessageHeaders;
use glib::translate::*;
use std::ptr;
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Multipart(Boxed<ffi::SoupMultipart>);
match fn {
copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::soup_multipart_get_type(), ptr as *mut _) as *mut ffi::SoupMultipart,
free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::soup_multipart_get_type(), ptr as *mut _),
type_ => || ffi::soup_multipart_get_type(),
}
}
impl Multipart {
#[doc(alias = "soup_multipart_new")]
pub fn new(mime_type: &str) -> Multipart {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::soup_multipart_new(mime_type.to_glib_none().0)) }
}
#[doc(alias = "soup_multipart_new_from_message")]
#[doc(alias = "new_from_message")]
pub fn from_message(headers: &MessageHeaders, body: &glib::Bytes) -> Option<Multipart> {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::soup_multipart_new_from_message(
headers.to_glib_none().0,
body.to_glib_none().0,
))
}
}
#[doc(alias = "soup_multipart_append_form_file")]
pub fn append_form_file(
&mut self,
control_name: &str,
filename: &str,
content_type: &str,
body: &glib::Bytes,
) {
unsafe {
ffi::soup_multipart_append_form_file(
self.to_glib_none_mut().0,
control_name.to_glib_none().0,
filename.to_glib_none().0,
content_type.to_glib_none().0,
body.to_glib_none().0,
);
}
}
#[doc(alias = "soup_multipart_append_form_string")]
pub fn append_form_string(&mut self, control_name: &str, data: &str) {
unsafe {
ffi::soup_multipart_append_form_string(
self.to_glib_none_mut().0,
control_name.to_glib_none().0,
data.to_glib_none().0,
);
}
}
#[doc(alias = "soup_multipart_append_part")]
pub fn append_part(&mut self, headers: &MessageHeaders, body: &glib::Bytes) {
unsafe {
ffi::soup_multipart_append_part(
self.to_glib_none_mut().0,
headers.to_glib_none().0,
body.to_glib_none().0,
);
}
}
#[doc(alias = "soup_multipart_get_length")]
#[doc(alias = "get_length")]
pub fn length(&mut self) -> i32 {
unsafe { ffi::soup_multipart_get_length(self.to_glib_none_mut().0) }
}
#[doc(alias = "soup_multipart_get_part")]
#[doc(alias = "get_part")]
pub fn part(&mut self, part: i32) -> Option<(MessageHeaders, glib::Bytes)> {
unsafe {
let mut headers = ptr::null_mut();
let mut body = ptr::null_mut();
let ret = from_glib(ffi::soup_multipart_get_part(
self.to_glib_none_mut().0,
part,
&mut headers,
&mut body,
));
if ret {
Some((from_glib_none(headers), from_glib_none(body)))
} else {
None
}
}
}
#[doc(alias = "soup_multipart_to_message")]
pub fn to_message(&mut self, dest_headers: &MessageHeaders) -> glib::Bytes {
unsafe {
let mut dest_body = ptr::null_mut();
ffi::soup_multipart_to_message(
self.to_glib_none_mut().0,
dest_headers.to_glib_none().0,
&mut dest_body,
);
from_glib_full(dest_body)
}
}
}