4 min read

Slice components

An overview of each Slice component.

Slice is made of several related components:

  • the Slice language
    The Slice language is a computer language designed for RPCs, but not tied to a specific RPC framework. You use Slice to specify RPCs and types used by these RPCs. It's a simple language without any execution logic: no if, no while, no print. While you specify your RPCs in Slice, you implement the actual "business logic" using the programming language of your choice (C#, Rust, Python...). The Slice language is an Interface Definition Language or IDL.

  • the Slice encoding
    The Slice encoding specifies how Slice language constructs such as string, int32, float64, struct, and operation arguments are encoded into streams of bytes. The Slice encoding is a simple, compact, binary serialization format. Most Slice users don't need to know the details of this encoding.

  • the Slice compiler
    The Slice compiler (slicec) parses files containing Slice definitions, ensures the Slice syntax is correct, and calls code generators to generate code for these files.

Then, for each programming language that Slice supports (currently C#, and soon Rust, Python and more), Slice provides:

  • a Slice language mapping
    A language mapping is a set of rules that specifies how Slice language constructs are represented in that language. For instance, a Slice struct is mapped to a record struct in C#. The C# language mapping specifies the name of this record struct, its fields, its constructors, etc.

  • a code generator
    A language mapping is implemented by a code generator spawned by the Slice compiler. The code generator generates code from your Slice definitions to a "mapped" programming language. In C#, ZeroC.Slice.Generator is the base, RPC-agnostic code generator; for example, when a Slice file defines a (Slice) struct, ZeroC.Slice.Generator produces a C# record struct.

  • a Slice Codec library
    The code generated by the code generator relies on a Slice Codec library in the target programming language. For example, the C# code generated by ZeroC.Slice.Generator relies on SliceEncoder and SliceDecoder, two C# structs defined in namespace ZeroC.Slice.Codec that can encode resp. decode a variety of types to or from byte buffers. These structs are provided by the ZeroC.Slice.Codec assembly.

And lastly, an RPC framework that supports Slice adds:

  • a language mapping for Slice interfaces and operations
    The RPC framework defines how Slice interfaces and operations are mapped in the target programming language. For example, the IceRPC + Slice integration for C# maps each Slice interface to two C# interfaces and one C# struct.

  • an RPC-specific code generator
    This code generator generates code for Slice interfaces and operations in the target language.

  • a support library
    The code generated by the RPC-specific code generator uses both the Slice Codec library, the RPC framework, and an additional library that assists this integration. For example, the IceRPC + Slice integration in C# relies on the IceRpc.Slice assembly.

All these Slice components work together to help you make RPCs without having to worry about encoding intricacies. With IceRPC + Slice, your primary responsibility is to use the same Slice definitions in your client and server applications; the code generated by the IceRPC-specific code generator encodes and decodes your arguments and return values, and exposes an easy-to-use typed API.

Was this page helpful?

CookiesYour privacy
This website uses cookies to analyze traffic and improve your experience.
By clicking "Accept," you consent to the use of these cookies. You can learn more about our cookies policy in our Privacy Policy.