Add casting function for coral::fixed_buffer to coral::slice
This commit is contained in:
parent
2dd7946b88
commit
c3a49eed7f
|
@ -10,6 +10,16 @@ export namespace coral {
|
||||||
template<usize capacity> struct fixed_buffer : public writer, public reader {
|
template<usize capacity> struct fixed_buffer : public writer, public reader {
|
||||||
fixed_buffer(coral::u8 fill_value) : data{fill_value} {}
|
fixed_buffer(coral::u8 fill_value) : data{fill_value} {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a mutable [slice] ranging from the head to the last-filled element.
|
||||||
|
*
|
||||||
|
* *Note*: The lifetime and validity of the returned slice is only guaranteed for as long
|
||||||
|
* as the source [fixed_buffer] is not mutated or out-of-scope.
|
||||||
|
*/
|
||||||
|
slice<u8 const> as_slice() const {
|
||||||
|
return {0, this->filled};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the base pointer of the buffer data.
|
* Returns the base pointer of the buffer data.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue