mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-28 14:08:25 +01:00
first
This commit is contained in:
parent
bd62d51ec9
commit
b578433e37
1 changed files with 784842 additions and 0 deletions
17
Brutal.Slang/ISlangBlobExtensions.cs
Normal file
17
Brutal.Slang/ISlangBlobExtensions.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
namespace Brutal.SlangApi;
|
||||
|
||||
/// <summary>
|
||||
/// Hand-written ergonomic helpers on top of the generated <see cref="ISlangBlob"/>
|
||||
/// COM interface. The interface itself only exposes a raw <c>void*</c> + size pair;
|
||||
/// callers shouldn't have to assemble a span by hand to read the contents.
|
||||
/// </summary>
|
||||
public static unsafe partial class ISlangBlobExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the blob's contents as a <see cref="ReadOnlySpan{Byte}"/>. The span is
|
||||
/// valid for the lifetime of the underlying blob. Copy if you need the bytes
|
||||
/// to outlive it.
|
||||
/// </summary>
|
||||
public static ReadOnlySpan<byte> AsSpan(this ISlangBlob self) =>
|
||||
new(self.GetBufferPointer(), checked((int)self.GetBufferSize()));
|
||||
}
|
||||
Loading…
Reference in a new issue