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
use glib::translate::*;
use glib::{GString, IntoGStr, IntoOptionalGStr};
use std::collections::HashMap;
use std::ptr;

use crate::MessageHeaders;

impl MessageHeaders {
    #[doc(alias = "soup_message_headers_get_content_disposition")]
    pub fn content_disposition(&self) -> Option<(GString, HashMap<String, String>)> {
        let mut disposition = ptr::null_mut();
        let mut params = ptr::null_mut();
        unsafe {
            if bool::from_glib(ffi::soup_message_headers_get_content_disposition(
                mut_override(self.to_glib_none().0),
                &mut disposition,
                &mut params,
            )) {
                let params = if !params.is_null() {
                    HashMap::from_glib_full(params)
                } else {
                    HashMap::new()
                };
                Some((GString::from_glib_full(disposition), params))
            } else {
                None
            }
        }
    }

    #[doc(alias = "soup_message_headers_set_content_disposition")]
    pub fn set_content_disposition(
        &self,
        disposition: Option<impl IntoGStr>,
        params: Option<HashMap<String, String>>,
    ) {
        disposition.run_with_gstr(|disposition| unsafe {
            ffi::soup_message_headers_set_content_disposition(
                self.to_glib_none().0,
                disposition.to_glib_none().0,
                params.to_glib_none().0,
            )
        })
    }

    #[doc(alias = "soup_message_headers_get_content_type")]
    pub fn content_type(&self) -> Option<(GString, HashMap<String, String>)> {
        let mut params = ptr::null_mut();
        unsafe {
            let content_type = ffi::soup_message_headers_get_content_type(
                mut_override(self.to_glib_none().0),
                &mut params,
            );
            if !content_type.is_null() {
                let params = if !params.is_null() {
                    HashMap::from_glib_full(params)
                } else {
                    HashMap::new()
                };
                Some((GString::from_glib_full(content_type), params))
            } else {
                None
            }
        }
    }

    #[doc(alias = "soup_message_headers_set_content_type")]
    pub fn set_content_type(
        &self,
        content_type: Option<impl IntoGStr>,
        params: Option<HashMap<String, String>>,
    ) {
        content_type.run_with_gstr(|content_type| unsafe {
            ffi::soup_message_headers_set_content_disposition(
                self.to_glib_none().0,
                content_type.to_glib_none().0,
                params.to_glib_none().0,
            )
        })
    }
}