Table of Contents

Class SliceFeature

Namespace
IceRpc.Features
Assembly
IceRpc.Slice.dll

Default implementation of ISliceFeature.

public sealed class SliceFeature : ISliceFeature
Inheritance
SliceFeature
Implements
Inherited Members

Constructors

SliceFeature(SliceEncodeOptions?, int, int, ISliceProxy?, ISliceFeature?)

Constructs a Slice feature.

public SliceFeature(SliceEncodeOptions? encodeOptions = null, int maxCollectionAllocation = -1, int maxSegmentSize = -1, ISliceProxy? baseProxy = null, ISliceFeature? defaultFeature = null)

Parameters

encodeOptions SliceEncodeOptions

The encode options.

maxCollectionAllocation int

The maximum collection allocation. Use -1 to get the default value: 8 times maxSegmentSize if set, otherwise the value provided by defaultFeature.

maxSegmentSize int

The maximum segment size. Use -1 to get the default value.

baseProxy ISliceProxy

The base proxy, used when decoding service addresses into proxies.

defaultFeature ISliceFeature

A feature that provides default values for all parameters. null is equivalent to Default.

Exceptions

ArgumentOutOfRangeException

Thrown when maxCollectionAllocation is a negative value other than -1, when maxSegmentSize is 0 or a negative value other than -1, or when maxSegmentSize is greater than int.MaxValue / 8 (256 MB) while maxCollectionAllocation is -1.

Properties

BaseProxy

Gets the base proxy used when decoding a service address into a proxy.

public ISliceProxy? BaseProxy { get; }

Property Value

ISliceProxy

The base proxy. A decoded proxy inherits the invoker and encode options of the base proxy, and a decoded relative service address is resolved against the service address of the base proxy. When null, the proxy that sent the request serves as the base proxy for a proxy decoded from an incoming response, while a proxy decoded from an incoming request receives Instance as its invoker and keeps its relative service address as is.

Default

Gets a ISliceFeature with default values for all properties.

public static ISliceFeature Default { get; }

Property Value

ISliceFeature

EncodeOptions

Gets the options to use when encoding the payload of an outgoing response.

public SliceEncodeOptions? EncodeOptions { get; }

Property Value

SliceEncodeOptions

The Slice encode options. null is equivalent to Default.

MaxCollectionAllocation

Gets the maximum collection allocation when decoding a payload, in bytes.

public int MaxCollectionAllocation { get; }

Property Value

int

The maximum collection allocation.

Remarks

This value is a cumulative budget for the decoding of one Slice payload segment, not a limit on the size of each collection: the decoder charges the estimated memory size of each string, sequence, and dictionary against this budget before decoding it, based on the size or element count found in the encoded data, and throws InvalidDataException when the charge exceeds the remaining budget. Implementations must return a value greater than or equal to 0.

MaxSegmentSize

Gets the maximum size of a Slice payload segment, in bytes. A Slice payload segment corresponds to the encoded arguments of an operation, the encoded return values of an operation, or a portion of a stream of variable-size elements.

public int MaxSegmentSize { get; }

Property Value

int

The maximum size of a Slice payload segment, in bytes.

Remarks

This limit applies only when decoding the payload of an incoming request or response: the decoding throws InvalidDataException when the size encoded in the size prefix of a segment exceeds this maximum, before decoding any byte of the segment. It does not restrict the size of the segments encoded by the application. The segment size does not include the size of its size prefix. Implementations must return a value greater than 0.