Skip to content

Commit

Permalink
Merge pull request #982 from Svisstack/ref-msg-memory
Browse files Browse the repository at this point in the history
Issue #978 expose internal buffer as memory<byte> #1
  • Loading branch information
drewnoakes authored Jul 1, 2021
2 parents 10b1d4b + 8f83c7a commit 4a80a4a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/NetMQ/Msg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,18 @@ public Span<byte> Slice()

return new Span<byte>(m_data, m_offset, Size);
}

/// <summary>
/// Return the internal buffer as Memory
/// </summary>
/// <returns>The memory</returns>
public Memory<byte> SliceAsMemory()
{
if (m_data == null)
return Memory<byte>.Empty;

return new Memory<byte>(m_data, m_offset, Size);
}

/// <summary>
/// Returns a slice of the internal buffer.
Expand Down

0 comments on commit 4a80a4a

Please sign in to comment.