Search Results for

    Show / Hide Table of Contents

    Class ByteString

    A rope-like immutable data structure containing bytes. The goal of this structure is to reduce copying of arrays when concatenating and slicing sequences of bytes, and also providing a thread safe way of working with bytes.

    Inheritance
    object
    ByteString
    Implements
    IEquatable<ByteString>
    IEnumerable<byte>
    IEnumerable
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Akka.IO
    Assembly: Akka.dll
    Syntax
    public sealed class ByteString : IEquatable<ByteString>, IEnumerable<byte>, IEnumerable

    Properties

    | Edit this page View Source

    Count

    Gets a total number of bytes stored inside this ByteString.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    Empty

    An empty ByteString.

    Declaration
    public static ByteString Empty { get; }
    Property Value
    Type Description
    ByteString
    | Edit this page View Source

    IsCompact

    Determines if current ByteString has compact representation. Compact byte strings represent bytes stored inside single, continuous block of memory.

    Declaration
    public bool IsCompact { get; }
    Property Value
    Type Description
    bool

    TBD

    | Edit this page View Source

    IsEmpty

    Determines if current ByteString is empty.

    Declaration
    public bool IsEmpty { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    this[int]

    Gets a byte stored under a provided index.

    Declaration
    public byte this[int index] { get; }
    Parameters
    Type Name Description
    int index

    TBD

    Property Value
    Type Description
    byte

    Methods

    | Edit this page View Source

    Compact()

    Compacts current ByteString, potentially copying its content underneat into new byte array.

    Declaration
    public ByteString Compact()
    Returns
    Type Description
    ByteString

    TBD

    | Edit this page View Source

    Concat(ByteString)

    Appends other ByteString at the tail of a current one, creating a new ByteString in result. Contents of byte strings are NOT copied.

    Declaration
    public ByteString Concat(ByteString other)
    Parameters
    Type Name Description
    ByteString other
    Returns
    Type Description
    ByteString

    TBD

    | Edit this page View Source

    CopyFrom(ArraySegment<byte>)

    Creates a new ByteString by copying a byte array range from provided buffer.

    Declaration
    public static ByteString CopyFrom(ArraySegment<byte> buffer)
    Parameters
    Type Name Description
    ArraySegment<byte> buffer

    Buffer specifying a byte array range to copy.

    Returns
    Type Description
    ByteString

    A byte string representation of array of bytes.

    | Edit this page View Source

    CopyFrom(byte[])

    Creates a new ByteString by copying a provided byte array.

    Declaration
    public static ByteString CopyFrom(byte[] array)
    Parameters
    Type Name Description
    byte[] array

    Array of bytes to copy

    Returns
    Type Description
    ByteString

    A byte string representation of array of bytes.

    | Edit this page View Source

    CopyFrom(byte[], int, int)

    Creates a new ByteString by copying a byte array.

    Declaration
    public static ByteString CopyFrom(byte[] array, int offset, int count)
    Parameters
    Type Name Description
    byte[] array

    Array of bytes to copy

    int offset

    Index in provided array, at which copy should start.

    int count

    Number of bytes to copy.

    Returns
    Type Description
    ByteString

    TBD

    | Edit this page View Source

    CopyFrom(IEnumerable<ArraySegment<byte>>)

    Creates a new ByteString by copying segments of bytes.

    Declaration
    public static ByteString CopyFrom(IEnumerable<ArraySegment<byte>> buffers)
    Parameters
    Type Name Description
    IEnumerable<ArraySegment<byte>> buffers
    Returns
    Type Description
    ByteString
    | Edit this page View Source

    CopyFrom(Memory<byte>)

    Creates a new ByteString by copying a Memory<T>.

    Declaration
    public static ByteString CopyFrom(Memory<byte> memory)
    Parameters
    Type Name Description
    Memory<byte> memory

    The Memory<T> to copy

    Returns
    Type Description
    ByteString

    The new ByteString

    | Edit this page View Source

    CopyFrom(Memory<byte>, int, int)

    Creates a new ByteString by copying a Memory<T>.

    Declaration
    public static ByteString CopyFrom(Memory<byte> memory, int offset, int count)
    Parameters
    Type Name Description
    Memory<byte> memory

    The Memory<T> to copy

    int offset

    Index in provided memory, at which copy should start.

    int count

    Number of bytes to copy.

    Returns
    Type Description
    ByteString

    The new ByteString

    | Edit this page View Source

    CopyFrom(Span<byte>)

    Creates a new ByteString by copying a Span<T>.

    Declaration
    public static ByteString CopyFrom(Span<byte> span)
    Parameters
    Type Name Description
    Span<byte> span

    The Span<T> to copy

    Returns
    Type Description
    ByteString

    The new ByteString

    | Edit this page View Source

    CopyFrom(Span<byte>, int, int)

    Creates a new ByteString by copying a Span<T>.

    Declaration
    public static ByteString CopyFrom(Span<byte> span, int offset, int count)
    Parameters
    Type Name Description
    Span<byte> span

    The Span<T> to copy

    int offset

    Index in provided span, at which copy should start.

    int count

    Number of bytes to copy.

    Returns
    Type Description
    ByteString

    The new ByteString

    | Edit this page View Source

    CopyTo(byte[], int, int)

    Copies content of a current ByteString into a provided buffer starting from index in that buffer and copying a count number of bytes.

    Declaration
    public int CopyTo(byte[] buffer, int index, int count)
    Parameters
    Type Name Description
    byte[] buffer
    int index
    int count
    Returns
    Type Description
    int

    TBD

    | Edit this page View Source

    CopyTo(ref Memory<byte>)

    Copies content of a current ByteString into a provided Memory<T> buffer

    Declaration
    public int CopyTo(ref Memory<byte> buffer)
    Parameters
    Type Name Description
    Memory<byte> buffer
    Returns
    Type Description
    int

    The number of bytes copied

    | Edit this page View Source

    CopyTo(ref Memory<byte>, int, int)

    Copies content of a current ByteString into a provided Memory<T> buffer starting from index in that buffer and copying a count number of bytes.

    Declaration
    public int CopyTo(ref Memory<byte> buffer, int index, int count)
    Parameters
    Type Name Description
    Memory<byte> buffer
    int index
    int count
    Returns
    Type Description
    int

    The number of bytes copied

    | Edit this page View Source

    CopyTo(ref Span<byte>)

    Copies content of a current ByteString into a provided Span<T> buffer.

    Declaration
    public int CopyTo(ref Span<byte> buffer)
    Parameters
    Type Name Description
    Span<byte> buffer
    Returns
    Type Description
    int

    The number of bytes copied

    | Edit this page View Source

    CopyTo(ref Span<byte>, int, int)

    Copies content of a current ByteString into a provided Span<T> buffer starting from index in that buffer and copying a count number of bytes.

    Declaration
    public int CopyTo(ref Span<byte> buffer, int index, int count)
    Parameters
    Type Name Description
    Span<byte> buffer
    int index
    int count
    Returns
    Type Description
    int

    The number of bytes copied

    | Edit this page View Source

    Equals(ByteString)

    Declaration
    public bool Equals(ByteString other)
    Parameters
    Type Name Description
    ByteString other
    Returns
    Type Description
    bool
    | Edit this page View Source

    Equals(object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj
    Returns
    Type Description
    bool
    Overrides
    object.Equals(object)
    | Edit this page View Source

    FromBytes(ArraySegment<byte>)

    Creates a new ByteString by wrapping raw range over array of bytes. WARNING: this method doesn't copy underlying array, but expects that represented range should not be modified once attached to byte string.

    Declaration
    public static ByteString FromBytes(ArraySegment<byte> buffer)
    Parameters
    Type Name Description
    ArraySegment<byte> buffer

    TBD

    Returns
    Type Description
    ByteString

    TBD

    | Edit this page View Source

    FromBytes(byte[])

    Creates a new ByteString by wrapping raw array of bytes. WARNING: this method doesn't copy underlying array, but expects that it should not be modified once attached to byte string.

    Declaration
    public static ByteString FromBytes(byte[] array)
    Parameters
    Type Name Description
    byte[] array

    TBD

    Returns
    Type Description
    ByteString

    TBD

    | Edit this page View Source

    FromBytes(byte[], int, int)

    Creates a new ByteString by wrapping raw range over array of bytes. WARNING: this method doesn't copy underlying array, but expects that represented range should not be modified once attached to byte string.

    Declaration
    public static ByteString FromBytes(byte[] array, int offset, int count)
    Parameters
    Type Name Description
    byte[] array

    TBD

    int offset

    TBD

    int count

    TBD

    Returns
    Type Description
    ByteString

    TBD

    | Edit this page View Source

    FromBytes(IEnumerable<ArraySegment<byte>>)

    Creates a new ByteString by wrapping raw collection of byte segements. WARNING: this method doesn't copy underlying arrays, but expects that represented range should not be modified once attached to byte string.

    Declaration
    public static ByteString FromBytes(IEnumerable<ArraySegment<byte>> buffers)
    Parameters
    Type Name Description
    IEnumerable<ArraySegment<byte>> buffers
    Returns
    Type Description
    ByteString
    | Edit this page View Source

    FromString(string)

    Creates a new ByteString which will contain the UTF-8 representation of the given String

    Declaration
    public static ByteString FromString(string str)
    Parameters
    Type Name Description
    string str

    TBD

    Returns
    Type Description
    ByteString

    TBD

    | Edit this page View Source

    FromString(string, Encoding)

    Creates a new ByteString which will contain the representation of the given String in the given charset encoding.

    Declaration
    public static ByteString FromString(string str, Encoding encoding)
    Parameters
    Type Name Description
    string str

    TBD

    Encoding encoding

    TBD

    Returns
    Type Description
    ByteString

    TBD

    | Edit this page View Source

    GetEnumerator()

    Declaration
    public IEnumerator<byte> GetEnumerator()
    Returns
    Type Description
    IEnumerator<byte>
    | Edit this page View Source

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    object.GetHashCode()
    | Edit this page View Source

    HasSubstring(ByteString, int)

    Checks if a subsequence determined by the other byte string is can be found in current one, starting from provided index.

    Declaration
    public bool HasSubstring(ByteString other, int index)
    Parameters
    Type Name Description
    ByteString other
    int index
    Returns
    Type Description
    bool
    | Edit this page View Source

    IndexOf(byte)

    Returns an index of the first occurence of provided byte starting from the beginning of the ByteString.

    Declaration
    public int IndexOf(byte b)
    Parameters
    Type Name Description
    byte b
    Returns
    Type Description
    int
    | Edit this page View Source

    IndexOf(byte, int)

    Returns an index of the first occurence of provided byte starting from the provided index.

    Declaration
    public int IndexOf(byte b, int from)
    Parameters
    Type Name Description
    byte b
    int from
    Returns
    Type Description
    int
    | Edit this page View Source

    Slice(int)

    Slices current ByteString, creating a new ByteString which contains a specified range of data from the original. This is non-copying operation.

    Declaration
    public ByteString Slice(int index)
    Parameters
    Type Name Description
    int index

    index inside current ByteString, from which slicing should start

    Returns
    Type Description
    ByteString
    | Edit this page View Source

    Slice(int, int)

    Slices current ByteString, creating a new ByteString which contains a specified range of data from the original. This is non-copying operation.

    Declaration
    public ByteString Slice(int index, int count)
    Parameters
    Type Name Description
    int index

    index inside current ByteString, from which slicing should start

    int count

    Number of bytes to fit into new ByteString.

    Returns
    Type Description
    ByteString
    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If index or count result in an invalid ByteString.

    | Edit this page View Source

    ToArray()

    Copies content of a current ByteString into a single byte array.

    Declaration
    public byte[] ToArray()
    Returns
    Type Description
    byte[]

    TBD

    | Edit this page View Source

    ToReadOnlySpan()

    Returns a ReadOnlySpan over the contents of this ByteString. This is a non-copying operation, when the ByteString is compact. When it is not compact, the contents are copied into a new array.

    Declaration
    public ReadOnlySpan<byte> ToReadOnlySpan()
    Returns
    Type Description
    ReadOnlySpan<byte>

    A ReadOnlySpan over the byte data.

    | Edit this page View Source

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    object.ToString()
    | Edit this page View Source

    ToString(Encoding)

    Declaration
    public string ToString(Encoding encoding)
    Parameters
    Type Name Description
    Encoding encoding
    Returns
    Type Description
    string
    | Edit this page View Source

    WriteTo(Stream)

    Copies content of the current ByteString to a provided writeable stream.

    Declaration
    public void WriteTo(Stream stream)
    Parameters
    Type Name Description
    Stream stream
    | Edit this page View Source

    WriteToAsync(Stream)

    Asynchronously copies content of the current ByteString to a provided writeable stream.

    Declaration
    public Task WriteToAsync(Stream stream)
    Parameters
    Type Name Description
    Stream stream
    Returns
    Type Description
    Task

    Operators

    | Edit this page View Source

    operator +(ByteString, ByteString)

    Declaration
    public static ByteString operator +(ByteString x, ByteString y)
    Parameters
    Type Name Description
    ByteString x
    ByteString y
    Returns
    Type Description
    ByteString
    | Edit this page View Source

    operator ==(ByteString, ByteString)

    Declaration
    public static bool operator ==(ByteString x, ByteString y)
    Parameters
    Type Name Description
    ByteString x
    ByteString y
    Returns
    Type Description
    bool
    | Edit this page View Source

    explicit operator byte[](ByteString)

    Declaration
    public static explicit operator byte[](ByteString byteString)
    Parameters
    Type Name Description
    ByteString byteString
    Returns
    Type Description
    byte[]
    | Edit this page View Source

    explicit operator ByteString(byte[])

    Declaration
    public static explicit operator ByteString(byte[] bytes)
    Parameters
    Type Name Description
    byte[] bytes
    Returns
    Type Description
    ByteString
    | Edit this page View Source

    operator !=(ByteString, ByteString)

    Declaration
    public static bool operator !=(ByteString x, ByteString y)
    Parameters
    Type Name Description
    ByteString x
    ByteString y
    Returns
    Type Description
    bool

    Implements

    IEquatable<T>
    IEnumerable<T>
    IEnumerable

    Extension Methods

    ObjectExtensions.IsDefaultForType<T>(T)
    ObjectExtensions.AsOption<T>(T)
    EnumerableExtensions.Grouped<T>(IEnumerable<T>, int)
    Extensions.Concat<T>(IEnumerable<T>?, T)
    Extensions.Drop<T>(IEnumerable<T>, int)
    Extensions.ForEach<T>(IEnumerable<T>, Action<T>)
    Extensions.Head<T>(IEnumerable<T>)
    Extensions.TakeRight<T>(IEnumerable<T>, int)
    Extensions.AsInstanceOf<T>(object)
    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET