#[repr(C)]pub struct WebBackForwardList { /* private fields */ }
WebBackForwardList
only.Expand description
WebBackForwardList holds an ordered list of WebHistoryItems that comprises the back and forward lists.
Note that the methods which modify instances of this class do not cause navigation to happen in other layers of the stack; they are only for maintaining this data structure.
See also Appleโs documentation
Implementationsยง
Sourceยงimpl WebBackForwardList
impl WebBackForwardList
Sourcepub unsafe fn addItem(&self, item: Option<&WebHistoryItem>)
๐DeprecatedAvailable on crate feature WebHistoryItem
only.
pub unsafe fn addItem(&self, item: Option<&WebHistoryItem>)
WebHistoryItem
only.Adds an entry to the list.
Parameter item
: The entry to add.
The added entry is inserted immediately after the current entry. If the current position in the list is not at the end of the list, elements in the forward list will be dropped at this point. In addition, entries may be dropped to keep the size of the list within the maximum size.
Sourcepub unsafe fn goBack(&self)
๐Deprecated
pub unsafe fn goBack(&self)
Move the current pointer back to the entry before the current entry.
Sourcepub unsafe fn goForward(&self)
๐Deprecated
pub unsafe fn goForward(&self)
Move the current pointer ahead to the entry after the current entry.
Sourcepub unsafe fn goToItem(&self, item: Option<&WebHistoryItem>)
๐DeprecatedAvailable on crate feature WebHistoryItem
only.
pub unsafe fn goToItem(&self, item: Option<&WebHistoryItem>)
WebHistoryItem
only.Move the current pointer to the given entry.
Parameter item
: The history item to move the pointer to
Sourcepub unsafe fn backItem(&self) -> Option<Retained<WebHistoryItem>>
๐DeprecatedAvailable on crate feature WebHistoryItem
only.
pub unsafe fn backItem(&self) -> Option<Retained<WebHistoryItem>>
WebHistoryItem
only.The entry right before the current entry, or nil if there isnโt one.
Sourcepub unsafe fn currentItem(&self) -> Option<Retained<WebHistoryItem>>
๐DeprecatedAvailable on crate feature WebHistoryItem
only.
pub unsafe fn currentItem(&self) -> Option<Retained<WebHistoryItem>>
WebHistoryItem
only.Returns the current entry.
Sourcepub unsafe fn forwardItem(&self) -> Option<Retained<WebHistoryItem>>
๐DeprecatedAvailable on crate feature WebHistoryItem
only.
pub unsafe fn forwardItem(&self) -> Option<Retained<WebHistoryItem>>
WebHistoryItem
only.The entry right after the current entry, or nil if there isnโt one.
Sourcepub unsafe fn backListWithLimit(
&self,
limit: c_int,
) -> Option<Retained<NSArray>>
๐Deprecated
pub unsafe fn backListWithLimit( &self, limit: c_int, ) -> Option<Retained<NSArray>>
Returns a portion of the list before the current entry.
Parameter limit
: A cap on the size of the array returned.
Returns: An array of items before the current entry, or nil if there are none. The entries are in the order that they were originally visited.
Sourcepub unsafe fn forwardListWithLimit(
&self,
limit: c_int,
) -> Option<Retained<NSArray>>
๐Deprecated
pub unsafe fn forwardListWithLimit( &self, limit: c_int, ) -> Option<Retained<NSArray>>
Returns a portion of the list after the current entry.
Parameter limit
: A cap on the size of the array returned.
Returns: An array of items after the current entry, or nil if there are none. The entries are in the order that they were originally visited.
Sourcepub unsafe fn setCapacity(&self, capacity: c_int)
๐Deprecated
pub unsafe fn setCapacity(&self, capacity: c_int)
Setter for capacity
.
Sourcepub unsafe fn backListCount(&self) -> c_int
๐Deprecated
pub unsafe fn backListCount(&self) -> c_int
The number of items in the list.
Sourcepub unsafe fn forwardListCount(&self) -> c_int
๐Deprecated
pub unsafe fn forwardListCount(&self) -> c_int
Returns: The number of items in the list.
Sourcepub unsafe fn containsItem(&self, item: Option<&WebHistoryItem>) -> bool
๐DeprecatedAvailable on crate feature WebHistoryItem
only.
pub unsafe fn containsItem(&self, item: Option<&WebHistoryItem>) -> bool
WebHistoryItem
only.Parameter item
: The item that will be checked for presence in the WebBackForwardList.
Returns: Returns YES if the item is in the list.
Sourcepub unsafe fn itemAtIndex(
&self,
index: c_int,
) -> Option<Retained<WebHistoryItem>>
๐DeprecatedAvailable on crate feature WebHistoryItem
only.
pub unsafe fn itemAtIndex( &self, index: c_int, ) -> Option<Retained<WebHistoryItem>>
WebHistoryItem
only.Returns an entry the given distance from the current entry.
Parameter index
: Index of the desired list item relative to the current item; 0 is current item, -1 is back item, 1 is forward item, etc.
Returns: The entry the given distance from the current entry. If index exceeds the limits of the list, nil is returned.
Sourceยงimpl WebBackForwardList
Methods declared on superclass NSObject
.
impl WebBackForwardList
Methods declared on superclass NSObject
.
Sourceยงimpl WebBackForwardList
WebBackForwardListDeprecated.
impl WebBackForwardList
WebBackForwardListDeprecated.
Sourcepub unsafe fn setPageCacheSize(&self, size: NSUInteger)
๐Deprecated
pub unsafe fn setPageCacheSize(&self, size: NSUInteger)
The size passed to this method determines whether the WebView associated with this WebBackForwardList will use the shared page cache.
Parameter size
: If size is 0, the WebView associated with this WebBackForwardList
will not use the shared page cache. Otherwise, it will.
Sourcepub unsafe fn pageCacheSize(&self) -> NSUInteger
๐Deprecated
pub unsafe fn pageCacheSize(&self) -> NSUInteger
Returns the size of the shared page cache, or 0.
Returns: The size of the shared page cache (in pages), or 0 if the WebView associated with this WebBackForwardList will not use the shared page cache.
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 WebBackForwardList
impl AsRef<AnyObject> for WebBackForwardList
Sourceยงimpl AsRef<NSObject> for WebBackForwardList
impl AsRef<NSObject> for WebBackForwardList
Sourceยงimpl Borrow<AnyObject> for WebBackForwardList
impl Borrow<AnyObject> for WebBackForwardList
Sourceยงimpl Borrow<NSObject> for WebBackForwardList
impl Borrow<NSObject> for WebBackForwardList
Sourceยงimpl ClassType for WebBackForwardList
impl ClassType for WebBackForwardList
Sourceยงconst NAME: &'static str = "WebBackForwardList"
const NAME: &'static str = "WebBackForwardList"
Sourceยงtype ThreadKind = <<WebBackForwardList as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<WebBackForwardList as ClassType>::Super as ClassType>::ThreadKind
Sourceยงimpl Debug for WebBackForwardList
impl Debug for WebBackForwardList
Sourceยงimpl Deref for WebBackForwardList
impl Deref for WebBackForwardList
Sourceยงimpl Hash for WebBackForwardList
impl Hash for WebBackForwardList
Sourceยงimpl Message for WebBackForwardList
impl Message for WebBackForwardList
Sourceยงimpl NSObjectProtocol for WebBackForwardList
impl NSObjectProtocol for WebBackForwardList
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