Struct shredder::Gc[][src]

pub struct Gc<T: Scan + ?Sized> { /* fields omitted */ }
Expand description

A smart-pointer for data tracked by shredder garbage collector

This lets you store arbitrary Scan data on the heap, even if that data has cycles. If you want to understand Scan and implement it for your type, see the documentation of Scan and the provided Scan derive.

Implementations

Create a new Gc containing the given data.

When this data is garbage collected, its drop implementation will be run.

T: GcDrop in order to create a Gc<T> with this method. If your T is not GcDrop, consider new_with_finalizer.

It is possible for this data not to be collected before the program terminates, or for the program to terminate before the background thread runs its destructor. So be careful when relying on this guarantee.

Create a new Gc containing the given data. (But specifying not to run its destructor.) This is useful because T: GcDrop is no longer necessary!

When this data is garbage collected, its drop implementation will NOT be run. Be careful using this method! It can lead to memory leaks!

Create a new Gc containing the given data. (But specifying to call finalize on it instead of running its destructor.)

This is useful because T: GcDrop is no longer necessary! (See the documentation of GcDrop to understand why a piece of data may not be GcDrop.)

As long as finalize does what you think it does, this is probably what you want for non-'static/non-GcDrop data!

It is possible for this data not to be collected before the program terminates, or for the program to terminate before the background thread runs finalize. So be careful not to rely on this guarantee!

Create a new Gc using the given Box<T>.

This function does not allocate anything - rather, it uses the Box<T> and releases its memory appropriately. This is useful since it removes the requirement for types to be sized.

get lets you get a GcGuard, which will deref to the underlying data.

get is used to get a GcGuard. This is usually what you want when accessing non-Sync data in a Gc. The API is very analogous to the Mutex API. It may block if the data is being scanned.

If you wish to avoid this, consider GcDeref as an alternative.

Attempt to downcast this Gc<T> to a Gc<S>

For implementation reasons this returns a new Gc<T> on success On failure (if there was not an S in the Gc<T>) then None is returned

Call the underlying borrow method on the RefCell.

This is just a nice method so you don’t have to call get manually.

Call the underlying try_borrow method on the RefCell.

This is just a nice method so you don’t have to call get manually.

Errors

Propagates a BorrowError if the underlying RefCell is already borrowed mutably

Call the underlying borrow_mut method on the RefCell.

This is just a nice method so you don’t have to call get manually.

Call the underlying try_borrow_mut method on the RefCell.

This is just a nice method so you don’t have to call get manually.

Errors

Propagates a BorrowError if the underlying RefCell is already borrowed

Call the underlying lock method on the inner Mutex

This is just a nice method so you don’t have to get manually

Errors

Returns a GcPoisonError if the underlying .lock method returns a poison error. You may use into_inner in order to recover the guard from that error.

Call the underlying try_lock method on the inner Mutex

This is just a nice method so you don’t have to get manually

Errors

Returns a GcTryLockError if the underlying .try_lock method returns an error

Call the underlying read method on the inner RwLock

This is just a nice method so you don’t have to get manually

Errors

Returns a GcPoisonError if the underlying read method returns a poison error. You may use into_inner in order to recover the guard from that error.

Call the underlying write method on the inner RwLock

This is just a nice method so you don’t have to get manually

Errors

Returns a GcPoisonError if the underlying write method returns a poison error. You may use into_inner in order to recover the guard from that error.

Call the underlying try_read method on the inner RwLock

This is just a nice method so you don’t have to get manually

Errors

Returns a GcTryLockError if the underlying try_read method returns an error

Call the underlying try_write method on the inner RwLock

This is just a nice method so you don’t have to get manually

Errors

Returns a GcTryLockError if the underlying try_write method returns an error

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Do cleanup on this data, potentially leaving it in an invalid state. (See trait documentation for the rules for implementing this method.) Read more

Feeds this value into the given Hasher. Read more

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

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Formats the value using the given formatter.

scan should use the scanner to scan all of its directly owned data

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.