Nerdbank.Streams
A that writes to a reassignable instance of .
Using this is much more memory efficient than a when writing to many different
because the same writer, with all its buffers, can be reused.
A buffer of written characters that have not yet been encoded.
The field tracks how many characters are represented in this buffer.
The internal buffer writer to use for writing encoded characters.
The last buffer received from .
The number of characters written to the buffer.
The number of characters written to the .
Whether the encoding preamble has been written since the last call to .
The encoding currently in use.
The preamble for the current .
We store this as a field to avoid calling repeatedly,
since the typical implementation allocates a new array for each call.
An encoder obtained from the current used for incrementally encoding written characters.
Initializes a new instance of the class.
When using this constructor, call
to associate the instance with the initial writer to use before using any write or flush methods.
Initializes a new instance of the class.
The buffer writer to write to.
The encoding to use.
Gets the number of uninitialized characters remaining in .
Prepares for writing to the specified buffer.
The buffer writer to write to.
The encoding to use.
Clears references to the set by a prior call to .
Encodes the written characters if the character buffer is full.
Encodes characters written so far to a buffer provided by the underyling .
to flush the characters in the encoder; useful when finalizing the output.
Commits any written bytes to the underlying .
Extension methods for the interface.
Copies the content of a into an .
The type of element to copy.
The to write to.
The sequence to read from.
A stream that writes to a of .
Initializes a new instance of the class.
The writer to write to.
A basic implementation of .
Initializes a new instance of the class.
The reader. If null, a completed reader will be emulated.
The writer. If null, a completed writer will be emulated.
Initializes a new instance of the class
that only allows reading. The property will reject writes.
The reader.
Initializes a new instance of the class
that only allows writing. The property will report completed reading.
The writer.
Checks whether the given is known to be already completed.
The reader to check.
if the is known to be completed; if the is not known to be completed.
This method may return for a completed .
Provides a full duplex stream which may be shared by two parties to
exchange messages.
Creates a pair of streams that can be passed to two parties
to allow for interaction with each other.
Pipe options to initialize the internal pipes with.
A pair of streams.
Creates a pair of duplex pipes that can be passed to two parties
to allow for interaction with each other.
Pipe options to initialize the internal pipes with.
A pair of objects.
Combines a readable with a writable into a new full-duplex
that reads and writes to the specified streams.
A readable stream.
A writable stream.
A new full-duplex stream.
A that acts as a queue for bytes, in that what gets written to it
can then be read from it, in order.
This is actually a "simplex" stream -- not a half duplex stream. Naming bug.
The pipe that does all the hard work.
Initializes a new instance of the class.
Initializes a new instance of the class.
The size the buffer must shrink to after hitting before writing is allowed to resume.
The maximum size the buffer is allowed to grow before write calls are blocked (pending a read that will release buffer space.
Signals that no more writing will take place, causing readers to receive 0 bytes when asking for any more data.
A that wraps another and reports all I/O taking place by raising events.
The underlying stream serving the I/O.
A value indicating whether the event has already been raised.
Initializes a new instance of the class.
The stream to wrap and monitor I/O for.
A delegate used for events that pass around.
The sender.
The span.
A delegate used for events that pass around.
The sender.
The span.
Occurs the first time a read method returns 0 bytes.
Occurs after is invoked.
Occurs before or is invoked.
The value is the maximum bytes that may be read.
Occurs after or is invoked.
The value is the actual bytes that were read.
Occurs before is invoked.
The value is the maximum bytes that may be read.
Occurs after is invoked.
Occurs before is invoked.
Occurs after is invoked.
Occurs before is invoked.
Occurs after is invoked.
Occurs before is invoked.
Occurs after is invoked.
Occurs before or is invoked.
Occurs after or is invoked.
Occurs before is invoked.
Occurs after is invoked.
Occurs before is invoked.
Occurs after is invoked.
Occurs before is invoked.
Occurs after is invoked.
Occurs after or is invoked.
Occurs when is invoked.
An exception that is thrown when an error occurs on the remote side of a multiplexed connection.
Initializes a new instance of the class.
Initializes a new instance of the class.
The message for the exception.
Initializes a new instance of the class.
The message for the exception.
The inner exception.
Initializes a new instance of the class
for use in deserialization.
The serialization info.
The serialization context.
Contains the nested type.
Contains the nested type.
Contains the nested type.
Contains the nested type.
Encodes multiple channels over a single transport.
Contains the nested type.
Contains the nested type.
Contains the nested type.
Contains the nested type.
An individual channel within a .
This task source completes when the channel has been accepted, rejected, or the offer is canceled.
The source for the property.
The source for a token that will be canceled when this channel has completed.
The source for the property. May be null if options were provided in ctor.
Tracks the end of any copying from the mxstream to this channel.
Gets a signal which indicates when the is non-zero.
The party-qualified id of the channel.
A semaphore that should be entered before using the .
The number of bytes transmitted from here but not yet acknowledged as processed from there,
and thus occupying some portion of the full .
All access to this field should be made within a lock on the object.
The number of bytes that may be transmitted before receiving acknowledgment that those bytes have been processed.
This field is set to the value of if we accepted the channel,
or the value of if we offered the channel.
The number of bytes that may be received and buffered for processing.
This field is set to the value of if we offered the channel,
or the value of if we accepted the channel.
Indicates whether the method has been called.
The original exception that led to faulting this channel.
This should only be set with a lock and after checking that it is .
The to use to get data to be transmitted over the .
A task that represents the completion of the ,
signifying the point where we will stop relaying data from the channel to the for transmission to the remote party.
The the underlying should use.
The I/O to expose on this channel if was not specified;
otherwise it is the buffering pipe we use as an intermediary with the specified .
The value of as it was when we received it.
We don't use this field, but we set it for diagnostic purposes later.
A value indicating whether this was created or accepted with a non-null value for .
Initializes a new instance of the class.
The owning .
The party-qualified ID of the channel.
The parameters of the channel from the offering party.
The channel options. Should only be null if the channel is created in response to an offer that is not immediately accepted.
Gets the unique ID for this channel.
This value is usually shared for an anonymous channel so the remote party
can accept it with or
reject it with .
Gets the unique ID for this channel.
This value is usually shared for an anonymous channel so the remote party
can accept it with or
reject it with .
Gets the mechanism used for tracing activity related to this channel.
A non-null value, once has been called.
Gets the reader used to receive data over the channel.
Thrown if the channel was created with a non-null value in .
Gets the writer used to transmit data over the channel.
Thrown if the channel was created with a non-null value in .
Gets a that completes when the channel is accepted, rejected, or canceled.
If the channel is accepted, this task transitions to state.
If the channel offer is canceled, this task transitions to a state.
If the channel offer is rejected, this task transitions to a state.
Gets a that completes when the channel is disposed,
which occurs when is invoked or when both sides
have indicated they are done writing to the channel.
Gets the underlying instance.
Gets a token that is canceled just before has transitioned to its final state.
Gets a that completes when options have been applied to this .
Gets an object that can be locked to make critical changes to this instance's fields.
We reuse an object we already have to avoid having to create a new System.Object instance just to lock with.
Gets the number of bytes that may be transmitted over this channel given the
remaining space in the .
Gets a value indicating whether backpressure support is enabled.
Immediately terminates the channel and shuts down any ongoing communication.
Because this method may terminate the channel immediately and thus can cause previously queued content to not actually be received by the remote party,
consider this method a "break glass" way of terminating a channel. The preferred method is that both sides "complete writing" and let the channel dispose itself.
Disposes the channel by releasing all resources associated with it.
The exception to dispose this channel with.
Receives content from the that is bound for this channel.
The content for this channel.
A token that is canceled if the overall gets disposed of.
A task that completes when content has been accepted.
All multiplexing stream reads are held up till this completes, so this should only pause in exceptional circumstances.
Faulting the returned will fault the whole multiplexing stream.
Called by the when it will not be writing any more data to the channel.
Accepts an offer made by the remote party.
The options to apply to the channel.
A value indicating whether the offer was accepted. It may fail if the channel was already closed or the offer rescinded.
Occurs when the remote party has accepted our offer of this channel.
The channel parameters provided by the accepting party.
A value indicating whether the acceptance went through; if the channel is already accepted, rejected or offer rescinded.
Invoked when the remote party acknowledges bytes we previously transmitted as processed,
thereby allowing us to consider that data removed from the remote party's "window"
and thus enables us to send more data to them.
The number of bytes processed by the remote party.
Gets the pipe writer to use when a message is received for this channel, so that the channel owner will notice and read it.
A .
Apply channel options to this channel, including setting up or linking to an user-supplied pipe writer/reader pair.
The channel options to apply.
Set up our own (buffering) Pipes if they have not been set up yet.
Relays data that the local channel owner wants to send to the remote party.
This method takes ownership of and guarantees that it will be completed by the time this method completes,
whether successfully or in a faulted state.
To protect thread-safety, this method replaces the field with an instance of
so no one else can mess with it and introduce thread-safety bugs. The field is restored as this method exits.
Invoked when we transmit data to the remote party
so we can track how much data we're sending them so we don't overrun their receiving buffer.
The number of bytes being transmitted.
Initializes a new instance of the class.
The name of the channel.
The maximum number of bytes that may be transmitted and not yet acknowledged as processed by the remote party.
When based on , this value should be -1 of that value in order
to avoid the actual pause that would be fatal to the read loop of the multiplexing stream.
Gets the name of the channel.
Gets the maximum number of bytes that may be transmitted and not yet acknowledged as processed by the remote party.
Initializes a new instance of the class.
The maximum number of bytes that may be transmitted and not yet acknowledged as processed by the remote party.
When based on , this value should be -1 of that value in order
to avoid the actual pause that would be fatal to the read loop of the multiplexing stream.
Gets the maximum number of bytes that may be transmitted and not yet acknowledged as processed by the remote party.
Describes an offer for a channel.
Initializes a new instance of the class.
The unique ID of the channel.
The name of the channel.
A value indicating whether the channel has already been accepted.
Gets the unique ID of the channel.
Gets the name of the channel.
Gets a value indicating whether the channel has already been accepted.
Describes local treatment of a channel.
Backing field for the property.
Initializes a new instance of the class.
Gets or sets the mechanism used for tracing activity related to this channel.
The trace source. May be null.
Gets or sets an existing instance used to exchange data with the channel.
The default is .
This property supports high throughput scenarios where channel data ultimately goes to a and that already exist.
This may remove the need for a memory copy of all bytes transferred over the channel by directing the to read and write directly an existing reader/writer pair.
When set, the and properties will throw
since their values are implementation details of the existing pipe set here.
The specified in *must* be created with that *exceeds*
the value of and .
Thrown if set to an that returns for either of its properties.
Gets or sets the options for the created to relay local reading from this channel.
Gets or sets the number of received bytes that may be buffered locally per channel (transmitted from the remote party but not yet processed).
This value should be at least the value of when the was created.
When the value is null or less than , the value from is used.
Signals what kind of frame is being transmitted.
A channel is proposed to the remote party.
A channel proposal has been accepted.
The payload of the frame is a payload intended for channel consumption.
Sent after all bytes have been transmitted on a given channel. Either or both sides may send this.
A channel may be automatically closed when each side has both transmitted and received this message.
Sent when a channel is closed, an incoming offer is rejected, or an outgoing offer is canceled.
Sent when a channel has finished processing data received from the remote party,
allowing them to send more data.
The channel id reserved for control frames.
The maximum length of a frame's payload.
The encoding used for characters in control frames.
The options to use for channels we create in response to incoming offers.
Whatever these settings are, they can be replaced when the channel is accepted.
A value indicating whether this is the "odd" party in the conversation (where the other one would be "even").
This value is only significant for parts of the protocol where it's useful to have the two parties behave slightly differently to avoid conflicts.
The formatter to use for serializing/deserializing multiplexing streams.
The object to lock when accessing internal fields.
A dictionary of channels being offered by the remote end but not yet accepted by us, keyed by name.
This does not include ephemeral channels (those without a name).
A dictionary of channels being accepted (but not yet offered).
A dictionary of all open channels (including those not yet accepted), keyed by their ID.
Contains the set of channels for which we have transmitted a frame
but for which we have not received the same frame.
A semaphore that must be entered to write to the underlying .
The source for the property.
A token that is canceled when this instance is disposed.
The major version of the protocol being used for this connection.
A value indicating whether any open channels should be faulted (i.e. their task will be faulted)
when the is disposed.
The last number assigned to a channel.
Each use of this should increment by two, if has a value.
A value indicating whether has been called.
Initializes a new instance of the class.
The formatter to use for the multiplexing frames.
A value indicating whether this party is the "odd" one. No value indicates this is the newer protocol version that no longer requires it.
The options for this instance.
Occurs when the remote party offers to establish a channel.
When adding a handler to this event, consider whether the stream has already started listening
and you may have already missed some incoming events.
If you want to receive *all* events from the start,
be sure to create the with
set to , then add handler(s) to this event before calling
.
A fatal error occurred at the overall multiplexing stream level, taking down the whole connection.
Raised when content arrives for a channel that has been disposed locally, resulting in discarding the content.
Raised when we are about to read (or wait for) the next frame.
Raised when we receive a message for an unknown or closed channel.
Raised when the protocol handshake is starting, to annouce the major version being used.
A fatal exception occurred that took down one channel.
Gets a task that completes when this instance is disposed, and may have captured a fault that led to its self-disposal.
Gets the logger used by this instance.
Never null.
Gets the default window size used for new channels that do not specify a value for .
This value can be set at the time of creation of the via .
Gets a token that is canceled when this instance is disposed.
Gets a factory for instances to attach to a newly opened
when its is .
Initializes a new instance of the class
with set to 3.
The stream to multiplex multiple channels over. Use if you have distinct input/output streams.
Options to define behavior for the multiplexing stream.
The multiplexing stream.
Initializes a new instance of the class.
The stream to multiplex multiple channels over. Use if you have distinct input/output streams.
A cancellation token.
The multiplexing stream, once the handshake is complete.
Thrown if the remote end disconnects before the handshake is complete.
Initializes a new instance of the class.
The stream to multiplex multiple channels over. Use if you have distinct input/output streams.
Options to define behavior for the multiplexing stream. If unspecified, the default options will include set to 1.
A cancellation token.
The multiplexing stream, once the handshake is complete.
Thrown if the remote end disconnects before the handshake is complete.
Starts reading from the stream.
This should only be done once, on an instance created with set to
and only after any required event handlers have been added so as to avoid a race where incoming messages lead to raising events
before handlers have been added.
Creates an anonymous channel that may be accepted by .
Its existance must be communicated by other means (typically another, existing channel) to encourage acceptance.
A set of options that describe local treatment of this channel.
The anonymous channel.
Note that while the channel is created immediately, any local write to that channel will be buffered locally
until the remote party accepts the channel.
Accepts a channel with a specific ID.
The of the channel to accept.
A set of options that describe local treatment of this channel.
The accepted .
Thrown if the channel is already accepted or is no longer offered by the remote party.
This method can be used to accept anonymous channels created with .
Unlike which will await
for a channel offer if a matching one has not been made yet, this method only accepts an offer
for a channel that has already been made.
Thrown when no channel with the specified exists.
Rejects an offer for the channel with a specified ID.
The ID of the channel whose offer should be rejected.
Thrown if the channel was already accepted.
Offers a new, named channel to the remote party so they may accept it with .
A name for the channel, which must be accepted on the remote end to complete creation.
It need not be unique, and may be empty but must not be null.
Any characters are allowed, and max length is determined by the maximum frame payload (based on UTF-8 encoding).
A cancellation token.
A task that completes with the if the offer is accepted on the remote end
or faults with if the remote end rejects the channel.
Thrown if is canceled before the channel is accepted by the remote end.
Offers a new, named channel to the remote party so they may accept it with .
A name for the channel, which must be accepted on the remote end to complete creation.
It need not be unique, and may be empty but must not be null.
Any characters are allowed, and max length is determined by the maximum frame payload (based on UTF-8 encoding).
A set of options that describe local treatment of this channel.
A cancellation token.
A task that completes with the if the offer is accepted on the remote end
or faults with if the remote end rejects the channel.
Thrown if is canceled before the channel is accepted by the remote end.
Accepts a channel that the remote end has attempted or may attempt to create.
The name of the channel to accept.
A token to indicate lost interest in accepting the channel.
The , after its offer has been received from the remote party and accepted.
If multiple offers exist with the specified , the first one received will be accepted.
Thrown if is canceled before a request to create the channel has been received.
Accepts a channel that the remote end has attempted or may attempt to create.
The name of the channel to accept.
A set of options that describe local treatment of this channel.
A token to indicate lost interest in accepting the channel.
The , after its offer has been received from the remote party and accepted.
If multiple offers exist with the specified , the first one received will be accepted.
Thrown if the channel is already accepted or is no longer offered by the remote party.
Thrown if is canceled before a request to create the channel has been received.
Immediately closes the underlying transport stream and releases all resources associated with this object and any open channels.
Disposes this multiplexing stream.
A task that indicates when disposal is complete.
Raises the event.
The arguments to pass to the event handlers.
Reads to fill a buffer.
The stream to read from.
The buffer to fill.
to throw if 0 bytes are read before the stream before the end of stream is encountered; to simply return when that happens.
A cancellation token.
if the buffer was filled as required; if the stream was empty and no bytes were read, if is .
Thrown if the end of the stream was reached before the buffer was filled (unless is false and 0 bytes were read).
Reads the specified number of bytes from a stream and discards everything read.
The stream to read from.
The number of bytes to read.
A cancellation token.
The result of the operation.
Thrown if the end of the stream was reached before bytes were read.
Occurs when the remote party has terminated a channel (including canceling an offer).
The ID of the terminated channel.
The payload sent from the remote side alongside the channel terminated frame.
Raised when is called and any local transmission is completed.
The channel that is closing down.
The exception to send to the remote side alongside the disposal.
Indicates that the local end will not be writing any more data to this channel,
leading to the transmission of a frame being sent for this channel.
The channel whose writing has finished.
Gets a unique number that can be used to represent a channel.
An unused channel number.
In protocol major versions 1-2, the channel numbers increase by two in order to maintain odd or even numbers, since each party is allowed to create only one or the other.
Gets or sets the result of the handshake regarding whether this endpoint is the "odd" one.
Only applicable and set in v1 and v2 of the protocol.
Writes the initial handshake.
An object that is passed to as the first parameter.
Reads the initial handshake.
The result of the call.
Configuration settings that should be shared with the remote party.
A cancellation token.
The result of the handshake.
The magic number to send at the start of communication when using v1 of the protocol.
Creates a payload for a frame.
The exception to send to the remote side if there is one.
The payload to send when a channel gets terminated.
Gets the error message in the payload if there is one.
The payload that could contain an error message.
The error message in this payload if there is one, null otherwise.
Gets or sets the kind of frame this is.
Gets the ID of the channel that this frame refers to or carries a payload for.
Thrown if is null.
Gets the text to display in the debugger when an instance of this struct is displayed.
Describes the options that a may be created with.
The default window size for a new channel,
which also serves as the minimum window size for any channel.
Using an integer multiple of ensures that the client can send full frames
instead of ending with a partial frame when the remote window limit is reached.
Backing field for the property.
Backing field for the property.
Backing field for the property.
Backing field for the property.
Backing field for the property.
Backing field for the property.
Backing field for the property.
Initializes a new instance of the class.
Initializes a new instance of the class
and copies the values from another instance into this one.
The instance to copy values from.
Initializes a new instance of the class
and copies the values from another instance into this one.
The instance to copy values from.
to freeze this copy.
Gets or sets the logger used by this instance.
Never null.
Gets or sets the number of received bytes that may be buffered locally per channel (transmitted from the remote party but not yet processed).
Must be a positive value.
Thrown if set to a non-positive value.
This value is ignored when is set to 1.
Gets or sets the protocol version to be used.
The default is 1.
1 is the original and default version.
2 is a protocol breaking change and adds backpressure support.
3 is a protocol breaking change that removes the initial handshake so no round-trip to establish the connection is necessary.
Gets or sets a factory for instances to attach to a newly opened
when its is .
The delegate receives a channel ID and name, and may return a or .
This delegate will not be invoked if has been set to a non-null value.
Gets or sets a factory for instances to attach to a newly opened
when its is .
The delegate receives a channel ID and name, and may return a or .
This delegate supersedes the obsolete as this one provides detail about whether the channel was offered locally or remotely.
Gets or sets a value indicating whether the should not start
reading from the stream immediately in order to provide time for the creator to add event handlers
such as .
The default value is .
When set to , the owner must use
after attaching event handlers to actually being reading from the stream.
Gets a list of options for channels that are to be "seeded" into a new .
Seeded channels avoid the need for a round-trip for an offer/accept packet exchange.
Seeded channels are accessed within the instance by calling
with the 0-based index into this list used as the channel ID.
They are only supported when is at least 3.
Gets or sets a value indicating whether any open channels should be faulted (i.e. their task will be faulted)
when the is disposed.
Gets a value indicating whether this instance is frozen.
Returns a frozen instance of this object.
This instance if already frozen, otherwise a frozen copy.
An enumeration of the possible sources of a channel.
The ordinal values are chosen so as to make flipping the perspective as easy as negating the value,
while leaving the value unchanged.
The channel was offered by this instance to the other party.
The channel was offered to this instance by the other party.
The channel was seeded during construction via the collection.
This channel is to be accepted by both parties.
The channel ID along with which party offered it.
Initializes a new instance of the struct.
The channel id.
A value indicating where the channel originated.
Gets the channel ID.
Gets a value indicating where the channel originated.
If the slice has not been fully read or if is non-null, this call propagates to the underlying .
But if the slice is fully read without errors, the call is suppressed so the underlying can continue to function.
A stream that allows for reading from another stream up to a given number of bytes.
The stream to read from.
The total length of the stream.
The remaining bytes allowed to be read.
Initializes a new instance of the class.
The stream to read from.
The number of bytes to read from the parent stream.
Stream extension methods.
The default buffer size to use for pipe readers.
Exposes a full-duplex pipe as a .
The pipe will be completed when the is disposed.
The pipe to wrap as a stream.
The wrapping stream.
Exposes a full-duplex pipe as a .
The pipe to wrap as a stream.
to complete the underlying reader and writer when the is disposed; to keep them open.
The wrapping stream.
Exposes a pipe reader as a .
The pipe to read from when is invoked.
The wrapping stream.
The reader will be completed when the is disposed.
Exposes a pipe reader as a after asynchronously reading all content
so the returned stream can be read synchronously without needlessly blocking a thread while waiting for more data.
The pipe to read from when is invoked.
A cancellation token.
The wrapping stream.
The reader will be completed when the is disposed.
Exposes a pipe writer as a .
The pipe to write to when is invoked.
The wrapping stream.
The writer will be completed when the is disposed.
Enables efficiently reading a stream using .
The stream to read from using a pipe.
A hint at the size of messages that are commonly transferred. Use 0 for a commonly reasonable default.
Optional pipe options to use.
A cancellation token that aborts reading from the .
A .
When the caller invokes on the result value,
this leads to the associated to be automatically called as well.
Creates a that reads from the specified exactly as told to do so.
It does *not* close the when completed.
The stream to read from using a pipe.
A hint at the size of messages that are commonly transferred. Use 0 for a commonly reasonable default.
A .
This reader may not be as efficient as the -based returned from ,
but its interaction with the underlying is closer to how a would typically be used which can ease migration from streams to pipes.
Enables writing to a stream using .
The stream to write to using a pipe. This stream is *not* closed automatically.
Optional pipe options to use.
A cancellation token that aborts writing to the .
A .
Creates a that writes to an underlying
when is called rather than asynchronously sometime later.
The stream to write to using a pipe.
A .
This writer may not be as efficient as the -based returned from ,
but its interaction with the underlying is closer to how a would typically be used which can ease migration from streams to pipes.
Enables reading and writing to a using and .
The stream to access using a pipe.
A hint at the size of messages that are commonly transferred. Use 0 for a commonly reasonable default.
Optional pipe options to use.
A token that may cancel async processes to read from and write to the .
An instance.
Enables reading and writing to a using and .
The stream to access using a pipe.
Obsolete. This value is ignored.
A hint at the size of messages that are commonly transferred. Use 0 for a commonly reasonable default.
Optional pipe options to use.
A token that may cancel async processes to read from and write to the .
An instance.
Enables efficiently reading a using .
The web socket to read from using a pipe.
A hint at the size of messages that are commonly transferred. Use 0 for a commonly reasonable default.
Optional pipe options to use.
A cancellation token that aborts reading from the .
A .
Enables efficiently writing to a using a .
The web socket to write to using a pipe.
Optional pipe options to use.
A cancellation token that aborts writing to the .
A .
Enables reading and writing to a using and .
The to access using a pipe.
A hint at the size of messages that may be transferred. Use 0 for a commonly reasonable default.
Optional pipe options to use.
A token that may cancel async processes to read from and write to the .
An instance.
Creates a that can read no more than a given number of bytes from an underlying reader.
The to read from.
The number of bytes to read from the parent .
A reader that ends after bytes are read.
Wraps a in another object that will report when is called.
The reader to be wrapped.
The callback to invoke when the method is called.
If this delegate throws an exception it will propagate to the caller of the method.
An optional state object to supply to the .
The wrapped which should be exposed to have its method called.
If the has already been completed, the provided may never be invoked.
Wraps a in another object that will report when is called.
The writer to be wrapped.
The callback to invoke when the method is called.
If this delegate throws an exception it will propagate to the caller of the method.
An optional state object to supply to the .
The wrapped which should be exposed to have its method called.
If the has already been completed, the provided may never be invoked.
Forwards all bytes coming from a to the specified .
The reader to get bytes from.
The writer to copy bytes to. will be called on this object when the reader completes or an error occurs.
A cancellation token.
A that completes when the has finished producing bytes, or an error occurs.
This never faults, since any exceptions are used to complete the .
If an error occurs during reading or writing, the and are completed with the exception.
Forwards all bytes coming from either to the other .
The first duplex pipe.
The second duplex pipe.
A cancellation token.
A that completes when both instances are finished producing bytes, or an error occurs.
This never faults, since any exceptions are used to complete the objects.
If an error occurs during reading or writing, both reader and writer are completed with the exception.
Enables efficiently reading a stream using .
The stream to read from using a pipe.
A hint at the size of messages that are commonly transferred. Use 0 for a commonly reasonable default.
Optional pipe options to use.
A task which, when complete, signals that this method should dispose of the .
A cancellation token that aborts reading from the .
A .
When the caller invokes on the result value,
this leads to the associated to be automatically called as well.
Copies a sequence of bytes to a .
The writer to use.
The sequence to read.
An that reserves some fixed size for a header.
The type of element written by this writer.
This type is used for inserting the length of list in the header when the length is not known beforehand.
It is optimized to minimize or avoid copying.
The value to use in place of when it is 0.
We choose ~4K, since 4K is the default size for buffers in a lot of corefx libraries.
We choose 4K - 4 specifically because length prefixing is so often for an value,
and if we ask for 1 byte more than 4K, memory pools tend to give us 8K.
The underlying buffer writer.
The length of the prefix to reserve space for.
The minimum space to reserve for the payload when first asked for a buffer.
This, added to , makes up the minimum size to request from
to minimize the chance that we'll need to copy buffers from to .
The pool to use when initializing .
The buffer writer to use for all buffers after the original one obtained from .
The buffer from reserved for the fixed-length prefix.
The memory being actively written to, which may have come from or .
The number of elements written to the original buffer obtained from .
A value indicating whether we're using in the current state.
Initializes a new instance of the class.
The underlying writer that should ultimately receive the prefix and payload.
The length of the header to reserve space for. Must be a positive number.
A hint at the expected max size of the payload. The real size may be more or less than this, but additional copying is avoided if it does not exceed this amount. If 0, a reasonable guess is made.
The memory pool to use for allocating additional memory when the payload exceeds .
Gets the sum of all values passed to since
the last call to .
Gets the memory reserved for the prefix.
Commits all the elements written and the prefix to the underlying writer
and advances the underlying writer past the prefix and payload.
This instance is safe to reuse after this call.
Extension methods for the type.
Copies the content of one to another that is backed by its own
memory buffers.
The type of element in the sequence.
The sequence to copy from.
A shallow copy of the sequence, backed by buffers which will never be recycled.
This method is useful for retaining data that is backed by buffers that will be reused later.
Polyfill method used by the .
The type of element kept by the sequence.
The sequence to retrieve.
The first span in the sequence.
The next position.
A reusable task if two consecutive reads return the same number of bytes.
A that reads from a reassignable instance of .
Using this is much more memory efficient than a when reading from many different
instances because the same reader, with all its buffers, can be reused.
A buffer of written characters that have not yet been encoded.
The field tracks how many characters are represented in this buffer.
The number of characters already read from .
The number of characters decoded into .
The sequence to be decoded and read.
The position of the next byte to decode in .
The encoding to use while decoding bytes into characters.
The decoder.
The preamble for the in use.
Initializes a new instance of the class
without associating it with an initial .
When using this constructor, call
to associate the instance with the initial byte sequence to be read.
Initializes a new instance of the class.
The sequence to read from.
The encoding to use.
Initializes or reinitializes this instance to read from a given .
The sequence to read from.
The encoding to use.
Clears references to the set by a prior call to .
Manages a sequence of elements, readily castable as a .
The type of element stored by the sequence.
Instance members are not thread-safe.
Initializes a new instance of the class
that uses a private for recycling arrays.
Initializes a new instance of the class.
The pool to use for recycling backing arrays.
Initializes a new instance of the class.
The pool to use for recycling backing arrays.
Gets or sets the minimum length for any array allocated as a segment in the sequence.
Any non-positive value allows the pool to determine the length of the array.
The default value is 0.
Each time or is called,
previously allocated memory is used if it is large enough to satisfy the length demand.
If new memory must be allocated, the argument to one of these methods typically dictate
the length of array to allocate. When the caller uses very small values (just enough for its immediate need)
but the high level scenario can predict that a large amount of memory will be ultimately required,
it can be advisable to set this property to a value such that just a few larger arrays are allocated
instead of many small ones.
The in use may itself have a minimum array length as well,
in which case the higher of the two minimums dictate the minimum array size that will be allocated.
If is , this value may be automatically increased as the length of a sequence grows.
Gets or sets a value indicating whether the should be
intelligently increased as the length of the sequence grows.
This can help prevent long sequences made up of many very small arrays.
Gets this sequence expressed as a .
A read only sequence representing the data in this object.
Gets the length of the sequence.
Gets the value to display in a debugger datatip.
Expresses this sequence as a .
The sequence to convert.
Removes all elements from the sequence from its beginning to the specified position,
considering that data to have been fully processed.
The position of the first element that has not yet been processed.
This is typically after reading all elements from that instance.
Advances the sequence to include the specified number of elements initialized into memory
returned by a prior call to .
The number of elements written into memory.
Gets writable memory that can be initialized and added to the sequence via a subsequent call to .
The size of the memory required, or 0 to just get a convenient (non-empty) buffer.
The requested memory.
Gets writable memory that can be initialized and added to the sequence via a subsequent call to .
The size of the memory required, or 0 to just get a convenient (non-empty) buffer.
The requested memory.
Adds an existing memory location to this sequence without copying.
The memory to add.
This *may* leave significant slack space in a previously allocated block if calls to
follow calls to or .
Clears the entire sequence, recycles associated memory into pools,
and resets this instance for reuse.
This invalidates any previously produced by this instance.
Clears the entire sequence and recycles associated memory into pools.
This invalidates any previously produced by this instance.
A value indicating whether the element may contain references (and thus must be cleared).
Gets the backing array, when using an instead of a .
Gets the position within where the data starts.
This may be nonzero as a result of calling .
Gets the position within where the data ends.
Gets the tail of memory that has not yet been committed.
Gets the tail of memory that has not yet been committed.
Gets the tracker for the underlying array for this segment, which can be used to recycle the array when we're disposed of.
Will be if using an array pool, in which case the memory is held by .
Gets the full memory owned by the .
Gets the number of elements that are committed in this segment.
Gets the amount of writable bytes in this segment.
It is the amount of bytes between and .
Gets or sets the next segment in the singly linked list of segments.
Gets a value indicating whether this segment refers to memory that came from outside and that we cannot write to nor recycle.
Assigns this (recyclable) segment a new area in memory.
The memory and a means to recycle it.
Assigns this (recyclable) segment a new area in memory.
An array drawn from an .
Assigns this (recyclable) segment a new area in memory.
A memory block obtained from outside, that we do not own and should not recycle.
Clears all fields in preparation to recycle this instance.
Adds a new segment after this one.
The next segment in the linked list.
Commits more elements as written in this segment.
The number of elements written.
Removes some elements from the start of this segment.
The number of elements to ignore from the start of the underlying array.
A that acts as a queue for bytes, in that what gets written to it
can then be read from it, in order.
The pipe that does all the hard work.
Initializes a new instance of the class.
Initializes a new instance of the class.
The size the buffer must shrink to after hitting before writing is allowed to resume.
The maximum size the buffer is allowed to grow before write calls are blocked (pending a read that will release buffer space.
Signals that no more writing will take place, causing readers to receive 0 bytes when asking for any more data.
Stream extension methods.
Creates a that can read no more than a given number of bytes from an underlying stream.
The stream to read from.
The number of bytes to read from the parent stream.
A stream that ends after bytes are read.
Exposes a as a .
The to use as a transport for the returned .
A bidirectional .
Exposes a of as a .
The sequence of bytes to expose as a stream.
The readable stream.
Exposes a of as a .
The sequence of bytes to expose as a stream.
A delegate to invoke when the returned stream is disposed. This might be useful to recycle the buffers backing the .
The argument to pass to .
The readable stream.
Creates a writable that can be used to add to a of .
The buffer writer the stream should write to.
A .
Create a new that can be used to write a byte sequence of undetermined length to some underlying ,
such that it can later be read back as if it were a of its own that ends at the end of this particular sequence.
The underlying stream to write to.
The buffer size to use.
The new .
Write to the returned until the sub-stream is complete. Call
when done and resume writing to the parent stream as needed.
Create a new that will read a sequence previously written to this stream using .
The underlying stream to read from.
A stream that will read just to the end of the substream and then end.
Fills a given buffer with bytes from the specified .
The stream to read from.
The buffer to fill from the .
A cancellation token.
A task that represents the asynchronous read operation. Its resulting value contains the total number of bytes read into the buffer.
The result value can be less than the length of the given buffer if the end of the stream has been reached.
May be thrown if is canceled before reading has completed.
The returned task does not complete until either the is filled or the end of the has been reached.
Fills a given buffer with bytes from the specified
or throws if the end of the stream is reached first.
The stream to read from.
The buffer to fill from the .
A cancellation token.
A task that represents the asynchronous read operation.
May be thrown if is canceled before reading has completed.
Thrown if the end of the stream is encountered before filling the buffer.
The returned task does not complete until either the is filled or the end of the has been reached.
A that reads from an underlying exactly when told to do so
rather than constantly reading from the stream and buffering up the results.
May be 0 for a reasonable default as determined by the method.
Indicates when we have drained the underlying stream of all bytes.
The will be disposed of when the reader is completed.
Initializes a new instance of the class.
The stream to read from.
A hint at the size of messages that are commonly transferred. Use 0 for a commonly reasonable default.
to leave the underlying open after calling ; to close the stream.
Reads a sequence of bytes from the from the buffer or underlying using synchronous APIs.
The read buffer.
A that writes to an underlying
when is called rather than asynchronously sometime later.
Initializes a new instance of the class.
The stream to write to.
A strongly-typed resource class, for looking up localized strings, etc.
Returns the cached ResourceManager instance used by this class.
Overrides the current thread's CurrentUICulture property for all
resource lookups using this strongly typed resource class.
Looks up a localized string similar to ExistingPipe's PipeWriter created with PipeOptions.PauseWriterThreshold that does not exceed the channel's receiving window size..
Looks up a localized string similar to This instance has been frozen. No mutations are allowed..
Looks up a localized string similar to Invalid seek origin..
Looks up a localized string similar to This operation is only valid before listening has started..
Looks up a localized string similar to This operation is only valid after listening has started..
Looks up a localized string similar to No channel with that ID found..
Looks up a localized string similar to This operation is not allowed on a seeded channel..
Looks up a localized string similar to This operation is not supported when the Channel is created with ChannelOptions.ExistingPipe set..
Looks up a localized string similar to The PipeReader was canceled..
Looks up a localized string similar to The PipeWriter flush was canceled..
Looks up a localized string similar to Reading not allowed after reader is completed..
Looks up a localized string similar to Seeded channels must be empty unless the protocol version is 3 or later..
Looks up a localized string similar to An attempt was made to move the position before the beginning of the stream..
Looks up a localized string similar to The underlying stream does not support seeking..
A stream that writes substreams of arbitrary length.
Created with
and later read with .
Flushes any buffers, and writes the bytes required to indicate that this substream is at its end.
A cancellation token.
A task to represent the async operation.
A stream that reads substreams of arbitrary length.
Initializes a new instance of the class.
The stream to read from.
A substitute that throws for nearly every call, notifying the caller that they don't own this object.
The only allowed call is to because that is assumed to be thread-safe.
This can be useful to set on a field that contains a while some async method "owns" it.
One example is at disposal, the 'owning' object may be tempted to call on it,
but this can cause thread-safety bugs and data corruption when the async reader loop is still using it.
Instead, such a Dispose method should cancel the reader loop in a thread-safe fashion, and then either that read method
or the Dispose method can Complete the reader.
Internal utilities.
A completed task.
Validates that a buffer is not null and that its index and count refer to valid positions within the buffer.
The type of element stored in the array.
The array to check.
The starting position within the buffer.
The number of elements to process in the buffer.
Removes an element from the middle of a queue without disrupting the other elements.
The element to remove.
The queue to modify.
The value to remove.
if the value was found and removed; if no match was found.
If a value appears multiple times in the queue, only its first entry is removed.
Reads an value from a buffer using big endian.
The buffer to read from. Must be at most 4 bytes long.
The read value.
Writes an value to a buffer using big endian.
The buffer to write to. Must be at least 4 bytes long.
The value to write.
Writes an value to a buffer using big endian.
The buffer to write to. Must be at least 2 bytes long.
The value to write.
Removes the memory from that may have been recycled by a call to .
The to scrub.
The and values are preserved, but the is made empty by this call.
Exposes a as a .
A completed task.
The socket wrapped by this stream.
Initializes a new instance of the class.
The web socket to wrap in a stream.
Does nothing, since web sockets do not need to be flushed.
Does nothing, since web sockets do not need to be flushed.
An ignored cancellation token.
A completed task.
A fast access struct that wraps .
The underlying .
The result of the last call to , less any bytes already "consumed" with .
Backing field for the property.
The result of the last call to , less any bytes already "consumed" with .
The number of uncommitted bytes (all the calls to since the last call to ).
The total number of bytes written with this writer.
Backing field for the property.
Initializes a new instance of the struct.
The to be wrapped.
Initializes a new instance of the struct.
The pool from which to draw an if required..
An array to start with so we can avoid accessing the if possible.
Gets the result of the last call to .
Gets the total number of bytes written with this writer.
Gets the underlying this instance.
Calls on the underlying writer
with the number of uncommitted bytes.
Used to indicate that part of the buffer has been written to.
The number of bytes written to.
Copies the caller's buffer into this writer and calls with the length of the source buffer.
The buffer to copy in.
Acquires a new buffer if necessary to ensure that some given number of bytes can be written to a single buffer.
The number of bytes that must be allocated in a single buffer.
Gets the span to the bytes written if they were never committed to the underlying buffer writer.
Gets a fresh span to write to, with an optional minimum size.
The minimum size for the next requested buffer.
Copies the caller's buffer into this writer, potentially across multiple buffers from the underlying writer.
The buffer to copy into this writer.
https://github.com/msgpack/msgpack/blob/master/spec.md#serialization-type-to-format-conversion.
The core type codes as defined by msgpack.
Checks whether a given messagepack code represents an integer that might include a sign (i.e. might be a negative number).
The messagepack code.
A boolean value.
The officially defined messagepack extension type codes.
A primitive types reader for the MessagePack format.
The MessagePack spec..
Thrown when reading methods fail due to invalid data.
Thrown by reading methods when there are not enough bytes to read the required value.
The reader over the sequence.
Initializes a new instance of the struct.
The buffer to read from.
Initializes a new instance of the struct.
The sequence to read from.
Gets or sets the cancellation token for this deserialization operation.
Gets or sets the present depth of the object graph being deserialized.
Gets the originally supplied to the constructor.
Gets the current position of the reader within .
Gets the number of bytes consumed by the reader.
Gets a value indicating whether the reader is at the end of the sequence.
Gets a value indicating whether the reader position is pointing at a nil value.
Thrown if the end of the sequence provided to the constructor is reached before the expected end of the data.
Gets the next message pack type to be read.
Gets the type of the next MessagePack block.
Thrown if the end of the sequence provided to the constructor is reached before the expected end of the data.
See for valid message pack codes and ranges.
Initializes a new instance of the struct,
with the same settings as this one, but with its own buffer to read from.
The sequence to read from.
The new reader.
Creates a new at this reader's current position.
The two readers may then be used independently without impacting each other.
A new .
Since this is a struct, copying it completely is as simple as returning itself
from a property that isn't a "ref return" property.
Advances the reader to the next MessagePack primitive to be read.
The entire primitive is skipped, including content of maps or arrays, or any other type with payloads.
To get the raw MessagePack sequence that was skipped, use instead.
Advances the reader to the next MessagePack primitive to be read.
true if the entire structure beginning at the current is found in the ; false otherwise.
The entire primitive is skipped, including content of maps or arrays, or any other type with payloads.
To get the raw MessagePack sequence that was skipped, use instead.
WARNING: when false is returned, the position of the reader is undefined.
Reads a value.
A nil value.
Reads nil if it is the next token.
true if the next token was nil; false otherwise.
Thrown if the end of the sequence provided to the constructor is reached before the expected end of the data.
Reads a sequence of bytes without any decoding.
The number of bytes to read.
The sequence of bytes read.
Reads the next MessagePack primitive.
The raw MessagePack sequence.
The entire primitive is read, including content of maps or arrays, or any other type with payloads.
Read an array header from
,
, or
some built-in code between and .
Thrown if the header cannot be read in the bytes left in the
or if it is clear that there are insufficient bytes remaining after the header to include all the elements the header claims to be there.
Thrown if a code other than an array header is encountered.
Reads an array header from
,
, or
some built-in code between and
if there is sufficient buffer to read it.
Receives the number of elements in the array if the entire array header could be read.
true if there was sufficient buffer and an array header was found; false if the buffer incompletely describes an array header.
Thrown if a code other than an array header is encountered.
When this method returns false the position of the reader is left in an undefined position.
The caller is expected to recreate the reader (presumably with a longer sequence to read from) before continuing.
Read a map header from
,
, or
some built-in code between and .
The number of key=value pairs in the map.
Thrown if the header cannot be read in the bytes left in the
or if it is clear that there are insufficient bytes remaining after the header to include all the elements the header claims to be there.
Thrown if a code other than an map header is encountered.
Reads a map header from
,
, or
some built-in code between and
if there is sufficient buffer to read it.
Receives the number of key=value pairs in the map if the entire map header can be read.
true if there was sufficient buffer and a map header was found; false if the buffer incompletely describes an map header.
Thrown if a code other than an map header is encountered.
When this method returns false the position of the reader is left in an undefined position.
The caller is expected to recreate the reader (presumably with a longer sequence to read from) before continuing.
Reads a boolean value from either a or .
The value.
Reads a from any of:
,
,
or anything between and .
A character.
Reads an value from any value encoded with:
,
,
,
,
,
,
,
,
,
or some value between and ,
or some value between and .
The value.
Reads an value from any value encoded with:
,
,
,
,
,
,
,
,
,
,
or some value between and ,
or some value between and .
The value.
Reads a from a value encoded with
,
, or
.
Expects extension type code .
The value.
Reads a from a value encoded with
,
,
.
Expects extension type code .
The extension header that was already read.
The value.
Reads a span of bytes, whose length is determined by a header of one of these types:
,
,
,
or to support OldSpec compatibility:
,
,
or something between and .
A sequence of bytes, or null if the read token is .
The data is a slice from the original sequence passed to this reader's constructor.
Reads a string of bytes, whose length is determined by a header of one of these types:
,
,
,
or a code between and .
The sequence of bytes, or null if the read token is .
The data is a slice from the original sequence passed to this reader's constructor.
Reads a string of bytes, whose length is determined by a header of one of these types:
,
,
,
or a code between and .
Receives the span to the string.
true if the string is contiguous in memory such that it could be set as a single span.
false if the read token is or the string is not in a contiguous span.
Callers should generally be prepared for a false result and failover to calling
which can represent a null result and handle strings that are not contiguous in memory.
Reads a string, whose length is determined by a header of one of these types:
,
,
,
or a code between and .
A string, or null if the current msgpack token is .
Reads an extension format header, based on one of these codes:
,
,
,
,
,
,
, or
.
The extension header.
Thrown if the header cannot be read in the bytes left in the
or if it is clear that there are insufficient bytes remaining after the header to include all the bytes the header claims to be there.
Thrown if a code other than an extension format header is encountered.
Reads an extension format header, based on one of these codes:
,
,
,
,
,
,
, or
if there is sufficient buffer to read it.
Receives the extension header if the remaining bytes in the fully describe the header.
The number of key=value pairs in the map.
Thrown if a code other than an extension format header is encountered.
When this method returns false the position of the reader is left in an undefined position.
The caller is expected to recreate the reader (presumably with a longer sequence to read from) before continuing.
Reads an extension format header and data, based on one of these codes:
,
,
,
,
,
,
, or
.
The extension format.
The data is a slice from the original sequence passed to this reader's constructor.
Throws an exception indicating that there aren't enough bytes remaining in the buffer to store
the promised data.
Throws an exception indicating that there aren't enough bytes remaining in the buffer to store
the promised data.
Throws an explaining an unexpected code was encountered.
The code that was encountered.
Nothing. This method always throws.
Throws if a condition is false.
A boolean value.
Thrown if is false.
Gets the length of the next string.
Receives the length of the next string, if there were enough bytes to read it.
true if there were enough bytes to read the length of the next string; false otherwise.
Gets the length of the next string.
The length of the next string.
Reads a string assuming that it is spread across multiple spans in the .
The length of the string to be decoded, in bytes.
The decoded string.
Reads an value from:
Some value between and ,
Some value between and ,
or any of the other MsgPack integer types.
The value.
Thrown when the value exceeds what can be stored in the returned type.
Reads an value from:
Some value between and ,
Some value between and ,
or any of the other MsgPack integer types.
The value.
Thrown when the value exceeds what can be stored in the returned type.
Reads an value from:
Some value between and ,
Some value between and ,
or any of the other MsgPack integer types.
The value.
Thrown when the value exceeds what can be stored in the returned type.
Reads an value from:
Some value between and ,
Some value between and ,
or any of the other MsgPack integer types.
The value.
Thrown when the value exceeds what can be stored in the returned type.
Reads an value from:
Some value between and ,
Some value between and ,
or any of the other MsgPack integer types.
The value.
Thrown when the value exceeds what can be stored in the returned type.
Reads an value from:
Some value between and ,
Some value between and ,
or any of the other MsgPack integer types.
The value.
Thrown when the value exceeds what can be stored in the returned type.
Reads an value from:
Some value between and ,
Some value between and ,
or any of the other MsgPack integer types.
The value.
Thrown when the value exceeds what can be stored in the returned type.
Reads an value from:
Some value between and ,
Some value between and ,
or any of the other MsgPack integer types.
The value.
Thrown when the value exceeds what can be stored in the returned type.
An exception thrown during serializing an object graph or deserializing a messagepack sequence.
Initializes a new instance of the class.
Initializes a new instance of the class.
The exception message.
Initializes a new instance of the class.
The exception message.
The inner exception.
Initializes a new instance of the class.
Serialization info.
Serialization context.
A primitive types writer for the MessagePack format.
The MessagePack spec..
The writer to use.
Initializes a new instance of the struct.
The writer to use.
Initializes a new instance of the struct.
The pool from which to draw an if required..
An array to start with so we can avoid accessing the if possible.
Gets or sets the cancellation token for this serialization operation.
Gets or sets a value indicating whether to write in old spec compatibility mode.
Initializes a new instance of the struct,
with the same settings as this one, but with its own buffer writer.
The writer to use for the new instance.
The new writer.
Ensures everything previously written has been flushed to the underlying .
Writes a value.
Copies bytes directly into the message pack writer.
The span of bytes to copy from.
Copies bytes directly into the message pack writer.
The span of bytes to copy from.
Write the length of the next array to be written in the most compact form of
,
, or
.
The number of elements that will be written in the array.
Write the length of the next array to be written in the most compact form of
,
, or
.
The number of elements that will be written in the array.
Write the length of the next map to be written in the most compact form of
,
, or
.
The number of key=value pairs that will be written in the map.
Write the length of the next map to be written in the most compact form of
,
, or
.
The number of key=value pairs that will be written in the map.
Writes a value using a 1-byte code when possible, otherwise as .
The value.
Writes a value using .
The value.
Writes an 8-bit value using a 1-byte code when possible, otherwise as .
The value.
Writes an 8-bit value using .
The value.
Writes a value using a 1-byte code when possible, otherwise as or .
The value.
Writes a value using .
The value.
Writes a using a built-in 1-byte code when within specific MessagePack-supported ranges,
or the most compact of
,
,
, or
.
The value to write.
Writes a using .
The value to write.
Writes an using a built-in 1-byte code when within specific MessagePack-supported ranges,
or the most compact of
,
, or
.
The value to write.
Writes an using .
The value to write.
Writes an using a built-in 1-byte code when within specific MessagePack-supported ranges,
or the most compact of
,
,
,
,
,
.
The value to write.
Writes an using .
The value to write.
Writes an using a built-in 1-byte code when within specific MessagePack-supported ranges,
or the most compact of
,
,
,
,
,
.
The value to write.
Writes an using .
The value to write.
Writes an using a built-in 1-byte code when within specific MessagePack-supported ranges,
or the most compact of
,
,
,
,
,
,
,
.
The value to write.
Writes a using .
The value to write.
Writes a value using either or .
The value.
Writes a value using a 1-byte code when possible, otherwise as or .
The value.
Writes a value.
The value.
Writes a value.
The value.
Writes a using the message code .
The value to write.
Thrown when is true because the old spec does not define a format.
Writes a [], prefixed with a length encoded as the smallest fitting from:
,
,
,
or if is null.
The array of bytes to write. May be null.
Writes a span of bytes, prefixed with a length encoded as the smallest fitting from:
,
, or
.
The span of bytes to write.
When is true, the msgpack code used is , or instead.
Writes a sequence of bytes, prefixed with a length encoded as the smallest fitting from:
,
, or
.
The span of bytes to write.
When is true, the msgpack code used is , or instead.
Writes the header that precedes a raw binary sequence with a length encoded as the smallest fitting from:
,
, or
.
The length of bytes that will be written next.
The caller should use or
after calling this method to actually write the content.
Alternatively a single call to or will take care of the header and content in one call.
When is true, the msgpack code used is , or instead.
Writes out an array of bytes that (may) represent a UTF-8 encoded string, prefixed with the length using one of these message codes:
,
,
, or
.
The bytes to write.
Writes out an array of bytes that (may) represent a UTF-8 encoded string, prefixed with the length using one of these message codes:
,
,
, or
.
The bytes to write.
Writes out the header that may precede a UTF-8 encoded string, prefixed with the length using one of these message codes:
,
,
, or
.
The number of bytes in the string that will follow this header.
The caller should use or
after calling this method to actually write the content.
Alternatively a single call to or will take care of the header and content in one call.
Writes out a , prefixed with the length using one of these message codes:
,
,
,
,
or if the is null.
The value to write. May be null.
Writes out a , prefixed with the length using one of these message codes:
,
,
,
.
The value to write.
Writes the extension format header, using the smallest one of these codes:
,
,
,
,
,
,
, or
.
The extension header.
Writes an extension format, using the smallest one of these codes:
,
,
,
,
,
,
, or
.
The extension data.
Gets memory where raw messagepack data can be written.
The size of the memory block required.
The span of memory to write to. This *may* exceed .
After initializing the resulting memory, always follow up with a call to .
This is similar in purpose to
but provides uninitialized memory for the caller to write to instead of copying initialized memory from elsewhere.
Commits memory previously returned from as initialized.
The number of bytes initialized with messagepack data from the previously returned span.
Writes a 16-bit integer in big endian format.
The integer.
Writes a 32-bit integer in big endian format.
The integer.
Writes a 64-bit integer in big endian format.
The integer.
Estimates the length of the header required for a given string.
The length of the string to be written, in characters.
Receives the guaranteed length of the returned buffer.
Receives the offset within the returned buffer to write the encoded string to.
A reference to the first byte in the buffer.
Finalizes an encoding of a string.
A pointer obtained from a prior call to .
The offset obtained from a prior call to .
The number of bytes used to actually encode the string.
A thread-safe, alloc-free reusable object pool.
A thread-safe pool of reusable objects.
We use a that allows every processor to be involved in messagepack serialization concurrently,
plus one nested serialization per processor (since LZ4 and sometimes other nested serializations may exist).
The value to use for .
Individual users that want a different value for this can modify the setting on the rented
or by supplying their own .
We use 32KB so that when LZ4Codec.MaximumOutputLength is used on this length it does not require a
buffer that would require the Large Object Heap.
The array pool which we share with all objects created by this instance.
We allow 100 arrays to be shared (instead of the default 50) and reduce the max array length from the default 1MB to something more reasonable for our expected use.
Initializes a new instance of the class.
The maximum size to allow the pool to grow.
Gets an instance of
This is taken from the recycled pool if one is available; otherwise a new one is created.
The rental tracker that provides access to the object as well as a means to return it.
Gets the recyclable object.
Returns the recyclable object to the pool.
The instance is cleaned first, if a clean delegate was provided.
It is dropped instead of being returned to the pool if the pool is already at its maximum size.
A value indicating whether we're using (as opposed to .
Backing for the entire sequence when we're not using .
The position at the start of the .
The position at the end of the .
Backing for the entire sequence when we're not using .
A value indicating whether there is unread data remaining.
The total number of elements in the sequence.
Initializes a new instance of the struct
over the given .
Initializes a new instance of the struct
over the given .
Gets a value indicating whether there is no more data in the .
Gets the underlying for the reader.
Gets the current position in the .
Gets the current segment in the as a span.
Gets the index in the .
Gets the unread portion of the .
Gets the total number of 's processed by the reader.
Gets remaining 's in the reader's .
Gets count of in the reader's .
Peeks at the next value without advancing the reader.
The next value or default if at the end.
False if at the end of the reader.
Read the next value and advance the reader.
The next value or default if at the end.
False if at the end of the reader.
Move the reader back the specified number of items.
Get the next segment with available data, if any.
Move the reader ahead the specified number of items.
Unchecked helper to avoid unnecessary checks where you know count is valid.
Only call this helper if you know that you are advancing in the current span
with valid count and there is no need to fetch the next one.
Move the reader ahead the specified number of items
if there are enough elements remaining in the sequence.
true if there were enough elements to advance; otherwise false.
Copies data from the current to the given span.
Destination to copy to.
True if there is enough data to copy to the .
Try to read the given type out of the buffer if possible. Warning: this is dangerous to use with arbitrary
structs- see remarks for full details.
IMPORTANT: The read is a straight copy of bits. If a struct depends on specific state of its members to
behave correctly this can lead to exceptions, etc. If reading endian specific integers, use the explicit
overloads such as .
True if successful. will be default if failed (due to lack of space).
Reads an from the next position in the sequence.
The reader to read from.
Receives the value read.
true if there was another byte in the sequence; false otherwise.
Reads an as big endian.
False if there wasn't enough data for an .
Reads an as big endian.
False if there wasn't enough data for an .
Reads an as big endian.
False if there wasn't enough data for an .
Reads an as big endian.
False if there wasn't enough data for an .
Reads an as big endian.
False if there wasn't enough data for an .
Reads an as big endian.
False if there wasn't enough data for an .
Reads a as big endian.
False if there wasn't enough data for a .
Reads a as big endian.
False if there wasn't enough data for a .
Internal utilities and extension methods for various external types.
A value indicating whether we're running on mono.
Reads one or more messagepack data structures from a .
This class is *not* thread-safe. Do not call more than one member at once and be sure any call completes (including asynchronous tasks)
before calling the next one.
Initializes a new instance of the class.
The stream to read from. This stream will be disposed of when this is disposed.
Initializes a new instance of the class.
The stream to read from.
If true, leaves the stream open after this is disposed; otherwise, false.
Gets any bytes that have been read since the last complete message returned from .
Gets the sequence that we read data from the into.
Reads the next whole (top-level) messagepack data structure.
A cancellation token.
A task whose result is the next whole data structure from the stream, or null if the stream ends.
The returned sequence is valid until this is disposed or
until this method is called again, whichever comes first.
When null is the result of the returned task,
any extra bytes read (between the last complete message and the end of the stream) will be available via the property.
Arranges for the next read operation to start by reading from the underlying
instead of any data buffered from a previous read.
This is appropriate if the underlying has been repositioned such that
any previously buffered data is no longer applicable to what the caller wants to read.
Recycle memory from a previously returned message.
Read more data from the stream into the buffer.
A cancellation token.
true if more data was read; false if the end of the stream had already been reached.
Checks whether the content in include a complete messagepack structure.
Receives the sequence of the first complete data structure found, if any.
true if a complete data structure was found; false otherwise.