Overview
The Conversor interface is defined using ZeroC ICE’s Slice language. Slice (Specification Language for ICE) is an interface definition language (IDL) that allows you to define language-agnostic interfaces for distributed applications.Conversor.ice File
The complete interface definition is located inbackend/Conversor.ice:
backend/Conversor.ice
Module and Exception
The main module that encapsulates all interface definitions and exceptions.
Custom exception thrown when invalid units or categories are provided.Fields:
mensaje(string): Descriptive error message explaining what went wrong
ICE exceptions are type-safe and can be caught specifically on the client side, allowing for proper error handling in distributed systems.
Interface Methods
TheConversorUnidades interface defines five remote methods:
convertirTemperatura
The temperature value to convert
Source unit:
celsius, fahrenheit, or kelvinTarget unit:
celsius, fahrenheit, or kelvindouble
convertirLongitud
The length/distance value to convert
Source unit:
m (meters), km (kilometers), mi (miles), or ft (feet)Target unit:
m, km, mi, or ftdouble
convertirPeso
The weight/mass value to convert
Source unit:
kg (kilograms), lb (pounds), or g (grams)Target unit:
kg, lb, or gdouble
convertirVelocidad
The velocity/speed value to convert
Source unit:
kmh (km/hour), mph (miles/hour), or ms (meters/second)Target unit:
kmh, mph, or msdouble
unidadesDisponibles
The category name:
temperatura, longitud, peso, or velocidadCode Generation
Once the Slice file is defined, use theslice2py compiler to generate Python stubs:
Conversor module with:
- Interface proxies for client-side calls
- Servant base classes for server-side implementation
- Exception classes
- Marshaling/unmarshaling code
Next Steps
Server Implementation
Learn how to implement the servant class
Client Usage
See how to connect and make remote calls