Create new instance wrapping the given data.
Create a new instance with given size/capacity. Capacity defaults to size.
Create a new instance slicing all of the given wrapper's contents.
Append data to this Data. Unlike concatenation (a ~ b), appending (a ~= b) will preallocate.
Unreference contents, freeing it if this was the last reference.
Create a new Data containing the concatenation of this and data. Does not preallocate for successive appends.
This used to be an unsafe method which deleted the wrapped data. Now that Data is refcounted, this simply calls clear() and additionally asserts that this Data is the only Data holding a reference to the wrapper.
Returns a Data pointing at a slice of this Data's contents.
Return a new Data for the first size bytes, and slice this instance from size to end.
Create a new Data containing the concatenation of data and this. Does not preallocate for successive appends.
Return maximum value that can be set to length without causing a reallocation
Get contents
Create a copy of the data
True if contents is unset
Size in bytes of contents
Resize contents
Get mutable contents
Get pointer to mutable contents
Get pointer to contents
Put a copy of the data on D's managed heap, and return it.
Create a new Data containing the concatenation of this and data. Does not preallocate for successive appends.
Create a new Data containing the concatenation of data and this. Does not preallocate for successive appends.
Append data to this Data. Unlike concatenation (a ~ b), appending (a ~= b) will preallocate.
Wrapper for data located in external memory, to prevent faux references. Represents a slice of data, which may or may not be in unmanaged memory. Data in unmanaged memory is bound to a DataWrapper class instance.
All operations on this class should be safe, except for accessing contents directly. All operations on contents must be accompanied by a live reference to the Data object, to keep a GC anchor towards the unmanaged data.
Concatenations and appends to Data contents will cause reallocations on the heap, consider using Data instead.
Be sure not to lose Data references while using their contents! For example, avoid code like this:
The Data return value may be unreachable once .contents is evaluated. Use .toHeap instead of .contents in such cases to get a safe heap copy.