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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff+)
// from gir-files (https://github.com/gtk-rs/gir-files @ b215ee8)
// DO NOT EDIT

use ParamEncodingMethod;
use ffi;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::mem;
use std::ptr;

glib_wrapper! {
    /// A parameter name/value pair as used in the Content-Type and Content-Disposition headers.
    ///
    /// # Implements
    ///
    /// [`ParamExt`](trait.ParamExt.html)
    pub struct Param(Object<ffi::GMimeParam, ffi::GMimeParamClass>);

    match fn {
        get_type => || ffi::g_mime_param_get_type(),
    }
}

/// Trait containing all `Param` methods.
///
/// # Implementors
///
/// [`Param`](struct.Param.html)
pub trait ParamExt {
    /// Gets the charset used for encoding the parameter.
    ///
    /// # Returns
    ///
    /// the charset used for encoding the parameter.
    fn get_charset(&self) -> Option<String>;

    /// Gets the encoding method used for encoding the parameter.
    ///
    /// # Returns
    ///
    /// the encoding method used for encoding the parameter.
    fn get_encoding_method(&self) -> ParamEncodingMethod;

    /// Gets the language specifier used for encoding the parameter.
    ///
    /// # Returns
    ///
    /// the language specifier used for encoding the parameter.
    fn get_lang(&self) -> Option<String>;

    /// Gets the name of the parameter.
    ///
    /// # Returns
    ///
    /// the name of the parameter.
    fn get_name(&self) -> Option<String>;

    /// Gets the value of the parameter.
    ///
    /// # Returns
    ///
    /// the value of the parameter.
    fn get_value(&self) -> Option<String>;

    /// Sets the parameter charset used for encoding the value.
    /// ## `charset`
    /// the charset or `None` to use the default
    fn set_charset(&self, charset: &str);

    /// Sets the encoding method used for encoding the value.
    /// ## `method`
    /// a `ParamEncodingMethod`
    fn set_encoding_method(&self, method: ParamEncodingMethod);

    /// Sets the parameter language specifier used for encoding the value.
    /// ## `lang`
    /// the language specifier
    fn set_lang(&self, lang: &str);

    /// Sets the parameter value to `value`.
    /// ## `value`
    /// the new parameter value
    fn set_value(&self, value: &str);
}

impl<O: IsA<Param>> ParamExt for O {
    fn get_charset(&self) -> Option<String> {
        unsafe {
            from_glib_none(ffi::g_mime_param_get_charset(self.to_glib_none().0))
        }
    }

    fn get_encoding_method(&self) -> ParamEncodingMethod {
        unsafe {
            from_glib(ffi::g_mime_param_get_encoding_method(self.to_glib_none().0))
        }
    }

    fn get_lang(&self) -> Option<String> {
        unsafe {
            from_glib_none(ffi::g_mime_param_get_lang(self.to_glib_none().0))
        }
    }

    fn get_name(&self) -> Option<String> {
        unsafe {
            from_glib_none(ffi::g_mime_param_get_name(self.to_glib_none().0))
        }
    }

    fn get_value(&self) -> Option<String> {
        unsafe {
            from_glib_none(ffi::g_mime_param_get_value(self.to_glib_none().0))
        }
    }

    fn set_charset(&self, charset: &str) {
        unsafe {
            ffi::g_mime_param_set_charset(self.to_glib_none().0, charset.to_glib_none().0);
        }
    }

    fn set_encoding_method(&self, method: ParamEncodingMethod) {
        unsafe {
            ffi::g_mime_param_set_encoding_method(self.to_glib_none().0, method.to_glib());
        }
    }

    fn set_lang(&self, lang: &str) {
        unsafe {
            ffi::g_mime_param_set_lang(self.to_glib_none().0, lang.to_glib_none().0);
        }
    }

    fn set_value(&self, value: &str) {
        unsafe {
            ffi::g_mime_param_set_value(self.to_glib_none().0, value.to_glib_none().0);
        }
    }
}