#[repr(C)]pub struct WKWebsiteDataStore { /* private fields */ }
WKWebsiteDataStore
only.Expand description
A WKWebsiteDataStore represents various types of data that a website might make use of. This includes cookies, disk and memory caches, and persistent data such as WebSQL, IndexedDB databases, and local storage.
See also Apple’s documentation
Implementations§
Source§impl WKWebsiteDataStore
impl WKWebsiteDataStore
pub unsafe fn defaultDataStore( mtm: MainThreadMarker, ) -> Retained<WKWebsiteDataStore>
Sourcepub unsafe fn nonPersistentDataStore(
mtm: MainThreadMarker,
) -> Retained<WKWebsiteDataStore>
pub unsafe fn nonPersistentDataStore( mtm: MainThreadMarker, ) -> Retained<WKWebsiteDataStore>
Returns a new non-persistent data store.
If a WKWebView is associated with a non-persistent data store, no data will be written to the file system. This is useful for implementing “private browsing” in a web view.
pub unsafe fn new(&self) -> Retained<Self>
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
Sourcepub unsafe fn isPersistent(&self) -> bool
pub unsafe fn isPersistent(&self) -> bool
Whether the data store is persistent or not.
Sourcepub unsafe fn allWebsiteDataTypes(
mtm: MainThreadMarker,
) -> Retained<NSSet<NSString>>
pub unsafe fn allWebsiteDataTypes( mtm: MainThreadMarker, ) -> Retained<NSSet<NSString>>
Returns a set of all available website data types.
Sourcepub unsafe fn fetchDataRecordsOfTypes_completionHandler(
&self,
data_types: &NSSet<NSString>,
completion_handler: &Block<dyn Fn(NonNull<NSArray<WKWebsiteDataRecord>>)>,
)
Available on crate features WKWebsiteDataRecord
and block2
only.
pub unsafe fn fetchDataRecordsOfTypes_completionHandler( &self, data_types: &NSSet<NSString>, completion_handler: &Block<dyn Fn(NonNull<NSArray<WKWebsiteDataRecord>>)>, )
WKWebsiteDataRecord
and block2
only.Fetches data records containing the given website data types.
Parameter dataTypes
: The website data types to fetch records for.
Parameter completionHandler
: A block to invoke when the data records have been fetched.
Sourcepub unsafe fn removeDataOfTypes_forDataRecords_completionHandler(
&self,
data_types: &NSSet<NSString>,
data_records: &NSArray<WKWebsiteDataRecord>,
completion_handler: &Block<dyn Fn()>,
)
Available on crate features WKWebsiteDataRecord
and block2
only.
pub unsafe fn removeDataOfTypes_forDataRecords_completionHandler( &self, data_types: &NSSet<NSString>, data_records: &NSArray<WKWebsiteDataRecord>, completion_handler: &Block<dyn Fn()>, )
WKWebsiteDataRecord
and block2
only.Removes website data of the given types for the given data records.
Parameter dataTypes
: The website data types that should be removed.
Parameter dataRecords
: The website data records to delete website data for.
Parameter completionHandler
: A block to invoke when the website data for the records has been removed.
Sourcepub unsafe fn removeDataOfTypes_modifiedSince_completionHandler(
&self,
data_types: &NSSet<NSString>,
date: &NSDate,
completion_handler: &Block<dyn Fn()>,
)
Available on crate feature block2
only.
pub unsafe fn removeDataOfTypes_modifiedSince_completionHandler( &self, data_types: &NSSet<NSString>, date: &NSDate, completion_handler: &Block<dyn Fn()>, )
block2
only.Removes all website data of the given types that has been modified since the given date.
Parameter dataTypes
: The website data types that should be removed.
Parameter date
: A date. All website data modified after this date will be removed.
Parameter completionHandler
: A block to invoke when the website data has been removed.
Sourcepub unsafe fn httpCookieStore(&self) -> Retained<WKHTTPCookieStore>
Available on crate feature WKHTTPCookieStore
only.
pub unsafe fn httpCookieStore(&self) -> Retained<WKHTTPCookieStore>
WKHTTPCookieStore
only.Returns the cookie store representing HTTP cookies in this website data store.
Sourcepub unsafe fn identifier(&self) -> Option<Retained<NSUUID>>
pub unsafe fn identifier(&self) -> Option<Retained<NSUUID>>
Get identifier for a data store.
Returns nil for default and non-persistent data store .
Sourcepub unsafe fn dataStoreForIdentifier(
identifier: &NSUUID,
mtm: MainThreadMarker,
) -> Retained<WKWebsiteDataStore>
pub unsafe fn dataStoreForIdentifier( identifier: &NSUUID, mtm: MainThreadMarker, ) -> Retained<WKWebsiteDataStore>
Get a persistent data store.
Parameter identifier
: An identifier that is used to uniquely identify the data store.
If a data store with this identifier does not exist yet, it will be created. Throws exception if identifier is 0.
Sourcepub unsafe fn removeDataStoreForIdentifier_completionHandler(
identifier: &NSUUID,
completion_handler: &Block<dyn Fn(*mut NSError)>,
mtm: MainThreadMarker,
)
Available on crate feature block2
only.
pub unsafe fn removeDataStoreForIdentifier_completionHandler( identifier: &NSUUID, completion_handler: &Block<dyn Fn(*mut NSError)>, mtm: MainThreadMarker, )
block2
only.Delete a persistent data store.
Parameter identifier
: An identifier that is used to uniquely identify the data store.
Parameter completionHandler
: A block to invoke with optional error when the operation completes.
This should be called when the data store is not used any more. Returns error if removal fails to complete. WKWebView using the data store must be released before removal.
Sourcepub unsafe fn fetchAllDataStoreIdentifiers(
completion_handler: &Block<dyn Fn(NonNull<NSArray<NSUUID>>)>,
mtm: MainThreadMarker,
)
Available on crate feature block2
only.
pub unsafe fn fetchAllDataStoreIdentifiers( completion_handler: &Block<dyn Fn(NonNull<NSArray<NSUUID>>)>, mtm: MainThreadMarker, )
block2
only.Fetch all data stores identifiers.
Parameter completionHandler
: A block to invoke with an array of identifiers when the operation completes.
Default or non-persistent data store do not have an identifier.
Source§impl WKWebsiteDataStore
Methods declared on superclass NSObject
.
impl WKWebsiteDataStore
Methods declared on superclass NSObject
.
pub unsafe fn new_class(mtm: MainThreadMarker) -> Retained<Self>
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Example
Check that an instance of NSObject
has the precise class NSObject
.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load
instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load
instead.Use Ivar::load
instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T
.
See Ivar::load_ptr
for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T
.
This is the reference-variant. Use Retained::downcast
if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString
.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString
to a NSMutableString
,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass:
for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject
.
§Panics
This works internally by calling isKindOfClass:
. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject
and
NSProxy
implement this method.
§Examples
Cast an NSString
back and forth from NSObject
.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();
Try (and fail) to cast an NSObject
to an NSString
.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());
Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();
This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}
Trait Implementations§
Source§impl AsRef<AnyObject> for WKWebsiteDataStore
impl AsRef<AnyObject> for WKWebsiteDataStore
Source§impl AsRef<NSObject> for WKWebsiteDataStore
impl AsRef<NSObject> for WKWebsiteDataStore
Source§impl AsRef<WKWebsiteDataStore> for WKWebsiteDataStore
impl AsRef<WKWebsiteDataStore> for WKWebsiteDataStore
Source§impl Borrow<AnyObject> for WKWebsiteDataStore
impl Borrow<AnyObject> for WKWebsiteDataStore
Source§impl Borrow<NSObject> for WKWebsiteDataStore
impl Borrow<NSObject> for WKWebsiteDataStore
Source§impl ClassType for WKWebsiteDataStore
impl ClassType for WKWebsiteDataStore
Source§const NAME: &'static str = "WKWebsiteDataStore"
const NAME: &'static str = "WKWebsiteDataStore"
Source§type ThreadKind = dyn MainThreadOnly
type ThreadKind = dyn MainThreadOnly
Source§impl Debug for WKWebsiteDataStore
impl Debug for WKWebsiteDataStore
Source§impl Deref for WKWebsiteDataStore
impl Deref for WKWebsiteDataStore
Source§impl Hash for WKWebsiteDataStore
impl Hash for WKWebsiteDataStore
Source§impl Message for WKWebsiteDataStore
impl Message for WKWebsiteDataStore
Source§impl NSCoding for WKWebsiteDataStore
impl NSCoding for WKWebsiteDataStore
Source§impl NSObjectProtocol for WKWebsiteDataStore
impl NSObjectProtocol for WKWebsiteDataStore
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass
directly, or cast your objects with AnyObject::downcast_ref
Source§fn isMemberOfClass(&self, cls: &AnyClass) -> bool
fn isMemberOfClass(&self, cls: &AnyClass) -> bool
Source§fn respondsToSelector(&self, aSelector: Sel) -> bool
fn respondsToSelector(&self, aSelector: Sel) -> bool
Source§fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
Source§fn debugDescription(&self) -> Retained<NSObject>
fn debugDescription(&self) -> Retained<NSObject>
Source§impl NSSecureCoding for WKWebsiteDataStore
impl NSSecureCoding for WKWebsiteDataStore
Source§impl PartialEq for WKWebsiteDataStore
impl PartialEq for WKWebsiteDataStore
Source§impl RefEncode for WKWebsiteDataStore
impl RefEncode for WKWebsiteDataStore
Source§const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF
const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF
impl DowncastTarget for WKWebsiteDataStore
impl Eq for WKWebsiteDataStore
Auto Trait Implementations§
impl !Freeze for WKWebsiteDataStore
impl !RefUnwindSafe for WKWebsiteDataStore
impl !Send for WKWebsiteDataStore
impl !Sync for WKWebsiteDataStore
impl !Unpin for WKWebsiteDataStore
impl !UnwindSafe for WKWebsiteDataStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<'a, T> MainThreadOnly for T
impl<'a, T> MainThreadOnly for T
Source§fn mtm(&self) -> MainThreadMarker
fn mtm(&self) -> MainThreadMarker
MainThreadMarker
from the main-thread-only object. Read more