soup/auto/
cookie_jar_text.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{ffi, CookieJar, CookieJarAcceptPolicy, SessionFeature};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    #[doc(alias = "SoupCookieJarText")]
11    pub struct CookieJarText(Object<ffi::SoupCookieJarText, ffi::SoupCookieJarTextClass>) @extends CookieJar, @implements SessionFeature;
12
13    match fn {
14        type_ => || ffi::soup_cookie_jar_text_get_type(),
15    }
16}
17
18impl CookieJarText {
19    #[doc(alias = "soup_cookie_jar_text_new")]
20    pub fn new(filename: &str, read_only: bool) -> CookieJarText {
21        assert_initialized_main_thread!();
22        unsafe {
23            CookieJar::from_glib_full(ffi::soup_cookie_jar_text_new(
24                filename.to_glib_none().0,
25                read_only.into_glib(),
26            ))
27            .unsafe_cast()
28        }
29    }
30
31    // rustdoc-stripper-ignore-next
32    /// Creates a new builder-pattern struct instance to construct [`CookieJarText`] objects.
33    ///
34    /// This method returns an instance of [`CookieJarTextBuilder`](crate::builders::CookieJarTextBuilder) which can be used to create [`CookieJarText`] objects.
35    pub fn builder() -> CookieJarTextBuilder {
36        CookieJarTextBuilder::new()
37    }
38
39    pub fn filename(&self) -> Option<glib::GString> {
40        ObjectExt::property(self, "filename")
41    }
42}
43
44impl Default for CookieJarText {
45    fn default() -> Self {
46        glib::object::Object::new::<Self>()
47    }
48}
49
50// rustdoc-stripper-ignore-next
51/// A [builder-pattern] type to construct [`CookieJarText`] objects.
52///
53/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
54#[must_use = "The builder must be built to be used"]
55pub struct CookieJarTextBuilder {
56    builder: glib::object::ObjectBuilder<'static, CookieJarText>,
57}
58
59impl CookieJarTextBuilder {
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    // rustdoc-stripper-ignore-next
85    /// Build the [`CookieJarText`].
86    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
87    pub fn build(self) -> CookieJarText {
88        self.builder.build()
89    }
90}