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
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from webkit-gir-files
// DO NOT EDIT

use crate::{ffi, WebsiteDataTypes};
use glib::translate::*;

glib::wrapper! {
    /// Data stored locally by a web site.
    ///
    /// WebKitWebsiteData represents data stored in the client by a particular website.
    /// A website is normally a set of URLs grouped by domain name. You can get the website name,
    /// which is usually the domain, with webkit_website_data_get_name().
    /// Documents loaded from the file system, like file:// URIs, are all grouped in the same WebKitWebsiteData
    /// with the name "Local files".
    ///
    /// A website can store different types of data in the client side. #WebKitWebsiteDataTypes is an enum containing
    /// all the possible data types; use webkit_website_data_get_types() to get the bitmask of data types.
    /// It's also possible to know the size of the data stored for some of the #WebKitWebsiteDataTypes by using
    /// webkit_website_data_get_size().
    ///
    /// A list of WebKitWebsiteData can be retrieved with webkit_website_data_manager_fetch(). See #WebKitWebsiteDataManager
    /// for more information.
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct WebsiteData(Shared<ffi::WebKitWebsiteData>);

    match fn {
        ref => |ptr| ffi::webkit_website_data_ref(ptr),
        unref => |ptr| ffi::webkit_website_data_unref(ptr),
        type_ => || ffi::webkit_website_data_get_type(),
    }
}

impl WebsiteData {
    /// Gets the name of #WebKitWebsiteData.
    ///
    /// This is the website name, normally represented by
    /// a domain or host name. All local documents are grouped in the same #WebKitWebsiteData using
    /// the name "Local files".
    ///
    /// # Returns
    ///
    /// the website name of @self.
    #[doc(alias = "webkit_website_data_get_name")]
    #[doc(alias = "get_name")]
    pub fn name(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::webkit_website_data_get_name(self.to_glib_none().0)) }
    }

    /// Gets the size of the data of types @types in a #WebKitWebsiteData.
    ///
    /// Note that currently the data size is only known for [`WebsiteDataTypes::DISK_CACHE`][crate::WebsiteDataTypes::DISK_CACHE] data type
    /// so for all other types 0 will be returned.
    /// ## `types`
    /// a bitmask  of #WebKitWebsiteDataTypes
    ///
    /// # Returns
    ///
    /// the size of @self for the given @types.
    #[doc(alias = "webkit_website_data_get_size")]
    #[doc(alias = "get_size")]
    pub fn size(&self, types: WebsiteDataTypes) -> u64 {
        unsafe { ffi::webkit_website_data_get_size(self.to_glib_none().0, types.into_glib()) }
    }

    /// Gets the types of data stored in the client for a #WebKitWebsiteData.
    ///
    /// These are the
    /// types actually present, not the types queried with webkit_website_data_manager_fetch().
    ///
    /// # Returns
    ///
    /// a bitmask of #WebKitWebsiteDataTypes in @self
    #[doc(alias = "webkit_website_data_get_types")]
    #[doc(alias = "get_types")]
    pub fn types(&self) -> WebsiteDataTypes {
        unsafe { from_glib(ffi::webkit_website_data_get_types(self.to_glib_none().0)) }
    }
}