soup/auto/
cookie_jar_db.rs1use crate::{ffi, CookieJar, CookieJarAcceptPolicy, SessionFeature};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10 #[doc(alias = "SoupCookieJarDB")]
11 pub struct CookieJarDB(Object<ffi::SoupCookieJarDB, ffi::SoupCookieJarDBClass>) @extends CookieJar, @implements SessionFeature;
12
13 match fn {
14 type_ => || ffi::soup_cookie_jar_db_get_type(),
15 }
16}
17
18impl CookieJarDB {
19 #[doc(alias = "soup_cookie_jar_db_new")]
20 pub fn new(filename: &str, read_only: bool) -> CookieJarDB {
21 assert_initialized_main_thread!();
22 unsafe {
23 CookieJar::from_glib_full(ffi::soup_cookie_jar_db_new(
24 filename.to_glib_none().0,
25 read_only.into_glib(),
26 ))
27 .unsafe_cast()
28 }
29 }
30
31 pub fn builder() -> CookieJarDBBuilder {
36 CookieJarDBBuilder::new()
37 }
38
39 pub fn filename(&self) -> Option<glib::GString> {
40 ObjectExt::property(self, "filename")
41 }
42}
43
44impl Default for CookieJarDB {
45 fn default() -> Self {
46 glib::object::Object::new::<Self>()
47 }
48}
49
50#[must_use = "The builder must be built to be used"]
55pub struct CookieJarDBBuilder {
56 builder: glib::object::ObjectBuilder<'static, CookieJarDB>,
57}
58
59impl CookieJarDBBuilder {
60 fn new() -> Self {
61 Self {
62 builder: glib::object::Object::builder(),
63 }
64 }
65
66 pub fn filename(self, filename: impl Into<glib::GString>) -> Self {
67 Self {
68 builder: self.builder.property("filename", filename.into()),
69 }
70 }
71
72 pub fn accept_policy(self, accept_policy: CookieJarAcceptPolicy) -> Self {
73 Self {
74 builder: self.builder.property("accept-policy", accept_policy),
75 }
76 }
77
78 pub fn read_only(self, read_only: bool) -> Self {
79 Self {
80 builder: self.builder.property("read-only", read_only),
81 }
82 }
83
84 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
87 pub fn build(self) -> CookieJarDB {
88 self.builder.build()
89 }
90}