Skip to main content

Arc

Struct Arc 

Source
pub struct Arc<T>
where T: ?Sized,
{ /* private fields */ }
Expand description

Arc wrapper used by Stylo. An atomically reference counted shared pointer

See the documentation for Arc in the standard library. Unlike the standard library Arc, this Arc does not support weak reference counting.

See the discussion in https://github.com/rust-lang/rust/pull/60594 for the usage of PhantomData.

cbindgen:derive-eq=false cbindgen:derive-neq=false

Implementations§

Source§

impl<T> Arc<T>

Source

pub fn new(data: T) -> Arc<T>

Construct an Arc<T>

Source

pub fn new_leaked(data: T) -> Arc<T>

Construct an intentionally-leaked arc.

Source

pub fn into_raw(this: Arc<T>) -> *const T

Convert the Arc to a raw pointer, suitable for use across FFI

Note: This returns a pointer to the data T, which is offset in the allocation.

Source

pub unsafe fn from_raw(ptr: *const T) -> Arc<T>

Reconstruct the Arc from a raw pointer obtained from into_raw()

Note: This raw pointer will be offset in the allocation and must be preceded by the atomic count.

Source

pub unsafe fn from_raw_addrefed(ptr: *const T) -> Arc<T>

Like from_raw, but returns an addrefed arc instead.

Source

pub unsafe fn new_static<F>(alloc: F, data: T) -> Arc<T>
where F: FnOnce(Layout) -> *mut u8,

Create a new static Arc (one that won’t reference count the object) and place it in the allocation provided by the specified alloc function.

alloc must return a pointer into a static allocation suitable for storing data with the Layout passed into it. The pointer returned by alloc will not be freed.

Source

pub fn borrow_arc<'a>(&'a self) -> ArcBorrow<'a, T>

Produce a pointer to the data that can be converted back to an Arc. This is basically an &Arc<T>, without the extra indirection. It has the benefits of an &T but also knows about the underlying refcount and can be converted into more Arc<T>s if necessary.

Source

pub fn heap_ptr(&self) -> *const c_void

Returns the address on the heap of the Arc itself – not the T within it – for memory reporting.

If this is a static reference, this returns null.

Source§

impl<T> Arc<T>
where T: ?Sized,

Source

pub fn mark_as_intentionally_leaked(&self)

Marks this Arc as intentionally leaked for the purposes of refcount logging.

It’s a logic error to call this more than once, but it’s not unsafe, as it’d just report negative leaks.

Source

pub fn ptr_eq(this: &Arc<T>, other: &Arc<T>) -> bool

Test pointer equality between the two Arcs, i.e. they must be the same allocation

Source

pub fn raw_ptr(&self) -> NonNull<()>

Returns a raw ptr to the underlying allocation.

Source§

impl<T> Arc<T>
where T: Clone,

Source

pub fn make_mut(this: &mut Arc<T>) -> &mut T

Makes a mutable reference to the Arc, cloning if necessary

This is functionally equivalent to Arc::make_mut from the standard library.

If this Arc is uniquely owned, make_mut() will provide a mutable reference to the contents. If not, make_mut() will create a new Arc with a copy of the contents, update this to point to it, and provide a mutable reference to its contents.

This is useful for implementing copy-on-write schemes where you wish to avoid copying things if your Arc is not shared.

Source§

impl<T> Arc<T>
where T: ?Sized,

Source

pub fn get_mut(this: &mut Arc<T>) -> Option<&mut T>

Provides mutable access to the contents if the Arc is uniquely owned.

Source

pub fn is_static(&self) -> bool

Whether or not the Arc is a static reference.

Source

pub fn is_unique(&self) -> bool

Whether or not the Arc is uniquely owned (is the refcount 1?) and not a static reference.

Source§

impl<H, T> Arc<HeaderSlice<H, T>>

Source

pub fn from_header_and_iter_alloc<F, I>( alloc: F, header: H, items: I, num_items: usize, is_static: bool, ) -> Arc<HeaderSlice<H, T>>
where F: FnOnce(Layout) -> *mut u8, I: Iterator<Item = T>,

Creates an Arc for a HeaderSlice using the given header struct and iterator to generate the slice.

is_static indicates whether to create a static Arc.

alloc is used to get a pointer to the memory into which the dynamically sized ArcInner<HeaderSlice<H, T>> value will be written. If is_static is true, then alloc must return a pointer into some static memory allocation. If it is false, then alloc must return an allocation that can be dellocated by calling Box::from_raw::<ArcInner<HeaderSlice<H, T>>> on it.

Source

pub fn from_header_and_iter_with_size<I>( header: H, items: I, num_items: usize, ) -> Arc<HeaderSlice<H, T>>
where I: Iterator<Item = T>,

Creates an Arc for a HeaderSlice using the given header struct and iterator to generate the slice. Panics if num_items doesn’t match the number of items.

Source

pub fn from_header_and_iter<I>(header: H, items: I) -> Arc<HeaderSlice<H, T>>
where I: Iterator<Item = T> + ExactSizeIterator,

Creates an Arc for a HeaderSlice using the given header struct and iterator to generate the slice. The resulting Arc will be fat.

Trait Implementations§

Source§

impl<T> AsRef<T> for Arc<T>
where T: ?Sized,

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T> Borrow<T> for Arc<T>
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> Clone for Arc<T>
where T: ?Sized,

Source§

fn clone(&self) -> Arc<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for Arc<T>
where T: Debug + ?Sized,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T> Default for Arc<T>
where T: Default,

Source§

fn default() -> Arc<T>

Returns the “default value” for a type. Read more
Source§

impl<T> Deref for Arc<T>
where T: ?Sized,

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<'de, T> Deserialize<'de> for Arc<T>
where T: Deserialize<'de>,

Available on crate feature servo only.
Source§

fn deserialize<D>( deserializer: D, ) -> Result<Arc<T>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> Display for Arc<T>
where T: Display + ?Sized,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T> Drop for Arc<T>
where T: ?Sized,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T> From<T> for Arc<T>

Source§

fn from(t: T) -> Arc<T>

Converts to this type from the input type.
Source§

impl<T> Hash for Arc<T>
where T: Hash + ?Sized,

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> MallocConditionalShallowSizeOf for Arc<T>

Source§

fn conditional_shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize

conditional_size_of combined with shallow_size_of.
Source§

impl<T> MallocConditionalSizeOf for Arc<T>
where T: MallocSizeOf,

Source§

fn conditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all heap-allocated descendant structures, but not the space taken up by the value itself, and only if that heap usage hasn’t already been measured.
Source§

impl<T> MallocUnconditionalShallowSizeOf for Arc<T>

Source§

fn unconditional_shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize

unconditional_size_of combined with shallow_size_of.
Source§

impl<T> MallocUnconditionalSizeOf for Arc<T>
where T: MallocSizeOf,

Source§

fn unconditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all heap-allocated descendant structures, but not the space taken up by the value itself.
Source§

impl<T> Ord for Arc<T>
where T: Ord + ?Sized,

Source§

fn cmp(&self, other: &Arc<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl Parse for Arc<VariableValue>

Source§

fn parse<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't>, ) -> Result<Arc<VariableValue>, ParseError<'i, StyleParseErrorKind<'i>>>

Parse a value of this type. Read more
Source§

impl<T> PartialEq for Arc<T>
where T: PartialEq + ?Sized,

Source§

fn eq(&self, other: &Arc<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, other: &Arc<T>) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> PartialOrd for Arc<T>
where T: PartialOrd + ?Sized,

Source§

fn partial_cmp(&self, other: &Arc<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
Source§

fn lt(&self, other: &Arc<T>) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
Source§

fn le(&self, other: &Arc<T>) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
Source§

fn gt(&self, other: &Arc<T>) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
Source§

fn ge(&self, other: &Arc<T>) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T> Pointer for Arc<T>
where T: ?Sized,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T> Serialize for Arc<T>
where T: Serialize,

Available on crate feature servo only.
Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> SpecifiedValueInfo for Arc<T>

Source§

const SUPPORTED_TYPES: u8 = T::SUPPORTED_TYPES

Supported CssTypes by the given value type. Read more
Source§

fn collect_completion_keywords(f: &mut dyn FnMut(&[&'static str]))

Collect value starting words for the given specified value type. This includes keyword and function names which can appear at the beginning of a value of this type. Read more
Source§

impl<T> ToComputedValue for Arc<T>
where T: ToComputedValue<ComputedValue = T>,

Source§

type ComputedValue = Arc<T>

The computed value type we’re going to be converted to.
Source§

fn to_computed_value(&self, _: &Context<'_>) -> Arc<T>

Convert a specified value to a computed value, using itself and the data inside the Context.
Source§

fn from_computed_value(computed: &Arc<T>) -> Arc<T>

Convert a computed value to specified value form. Read more
Source§

impl<T> ToCss for Arc<T>
where T: ToCss + ?Sized,

Source§

fn to_css<W>(&self, dest: &mut CssWriter<'_, W>) -> Result<(), Error>
where W: Write,

Serialize self in CSS syntax, writing to dest.
Source§

fn to_css_string(&self) -> String

Serialize self in CSS syntax and return a string. Read more
Source§

fn to_css_cssstring(&self) -> String

Serialize self in CSS syntax and return a CssString. Read more
Source§

impl<T> ToResolvedValue for Arc<T>
where T: ToResolvedValue<ResolvedValue = T>,

Source§

type ResolvedValue = Arc<T>

The resolved value type we’re going to be converted to.
Source§

fn to_resolved_value(self, _: &Context<'_>) -> Arc<T>

Convert a resolved value to a resolved value.
Source§

fn from_resolved_value(resolved: Arc<T>) -> Arc<T>

Convert a resolved value to resolved value form.
Source§

impl<H, T> ToShmem for Arc<HeaderSlice<H, T>>
where H: ToShmem, T: ToShmem,

Available on crate feature servo_arc only.
Source§

fn to_shmem( &self, builder: &mut SharedMemoryBuilder, ) -> Result<ManuallyDrop<Arc<HeaderSlice<H, T>>>, String>

Clones this value into a form suitable for writing into a SharedMemoryBuilder. Read more
Source§

impl<T> ToShmem for Arc<T>
where T: ToShmem,

Available on crate feature servo_arc only.
Source§

fn to_shmem( &self, builder: &mut SharedMemoryBuilder, ) -> Result<ManuallyDrop<Arc<T>>, String>

Clones this value into a form suitable for writing into a SharedMemoryBuilder. Read more
Source§

impl<T> CloneStableDeref for Arc<T>
where T: ?Sized,

Source§

impl<T> Eq for Arc<T>
where T: Eq + ?Sized,

Source§

impl<T> Send for Arc<T>
where T: Sync + Send + ?Sized,

Source§

impl<T> StableDeref for Arc<T>
where T: ?Sized,

Source§

impl<T> Sync for Arc<T>
where T: Sync + Send + ?Sized,

Auto Trait Implementations§

§

impl<T> Freeze for Arc<T>
where T: ?Sized,

§

impl<T> RefUnwindSafe for Arc<T>
where T: RefUnwindSafe + ?Sized,

§

impl<T> Unpin for Arc<T>
where T: Unpin + ?Sized,

§

impl<T> UnsafeUnpin for Arc<T>
where T: ?Sized,

§

impl<T> UnwindSafe for Arc<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeBoxed<Box<T>> for T

Source§

fn maybe_boxed(self) -> Box<T>

Convert
Source§

impl<T> MaybeBoxed<T> for T

Source§

fn maybe_boxed(self) -> T

Convert
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Brush for T
where T: Clone + PartialEq + Default + Debug,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,