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
// 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 ContentEncoding; use EncodingConstraint; use Filter; use FilterBestFlags; use ffi; use glib::object::Downcast; use glib::object::IsA; use glib::translate::*; use glib_ffi; use gobject_ffi; use std::mem; use std::ptr; glib_wrapper! { /// A filter for calculating the best encoding and/or charset to encode /// the data passed through it. /// /// # Implements /// /// [`FilterBestExt`](trait.FilterBestExt.html), [`FilterExt`](trait.FilterExt.html) pub struct FilterBest(Object<ffi::GMimeFilterBest, ffi::GMimeFilterBestClass>): Filter; match fn { get_type => || ffi::g_mime_filter_best_get_type(), } } impl FilterBest { /// Creates a new GMimeFilterBest filter. `flags` are used to determine /// which information to keep statistics of. If the /// `FilterBestFlags::Charset` bit is set, the filter will be able to /// compute the best charset for encoding the stream of data /// filtered. If the `FilterBestFlags::Encoding` bit is set, the filter /// will be able to compute the best Content-Transfer-Encoding for use /// with the stream being filtered. /// /// Note: In order for the `FilterBestExt::charset` function to /// work, the stream being filtered MUST already be encoded in UTF-8. /// ## `flags` /// filter flags /// /// # Returns /// /// a new best filter with flags `flags`. pub fn new(flags: FilterBestFlags) -> FilterBest { unsafe { Filter::from_glib_full(ffi::g_mime_filter_best_new(flags.to_glib())).downcast_unchecked() } } } /// Trait containing all `FilterBest` methods. /// /// # Implementors /// /// [`FilterBest`](struct.FilterBest.html) pub trait FilterBestExt { /// Calculates the best charset for encoding the stream filtered /// through the `self` filter. /// /// # Returns /// /// a pointer to a string containing the name of the charset /// best suited for the text filtered through `self`. fn charset(&self) -> Option<String>; /// Calculates the most efficient Content-Transfer-Encoding for the /// stream filtered through `self` that fits within the encoding /// `constraint`. /// ## `constraint` /// a `EncodingConstraint` /// /// # Returns /// /// the best encoding for the stream filtered by `self`. fn encoding(&self, constraint: EncodingConstraint) -> ContentEncoding; } impl<O: IsA<FilterBest>> FilterBestExt for O { fn charset(&self) -> Option<String> { unsafe { from_glib_none(ffi::g_mime_filter_best_charset(self.to_glib_none().0)) } } fn encoding(&self, constraint: EncodingConstraint) -> ContentEncoding { unsafe { from_glib(ffi::g_mime_filter_best_encoding(self.to_glib_none().0, constraint.to_glib())) } } }