IDL Types & Fields

PulseRPC supports a rich type system for defining your service contracts.

Built-in Types

IDL Type Description Go Java C# Python TypeScript
string Text/UTF-8 strings string String string str string
int Signed 64-bit integers ([-9223372036854775808, 9223372036854775807]) int64 long/Long long int number (safe integers only)
float 64-bit floating point float64 double/Double double float number
bool Boolean values bool boolean/Boolean bool bool boolean

int is signed 64-bit (D1). Java, C#, Go, and Python runtimes support the full range. TypeScript types int as number, and JavaScript numbers can represent integers exactly only up to 2^53-1 (9007199254740991), so the TypeScript runtime validates the safe-integer range. This is a breaking change from the earlier signed 32-bit int.

A JSON number written in decimal or exponent form (1.0, 1e3) is accepted for int when its value is integral. Go parses those tokens exactly and rejects one whose fractional part a float64 would lose; the other runtimes validate the parsed number. See the Go reference for the cross-runtime caveat.

Arrays

Ordered lists of a type:

struct Cart {
    items []CartItem
    tags  []string
}

Language mapping:

Maps

Key-value dictionaries (keys are always strings):

struct Metadata {
    tags map[string]string
    headers map[string]string
}

Language mapping:

Optional Fields

Fields marked [optional] can be null or omitted:

struct User {
    userId    string
    email     string
    phone     string  [optional]  // Can be null
    bio       string  [optional]  // Can be omitted
}

Validation rules:

Struct Inheritance

Extend existing structs to reuse fields:

struct BaseResponse {
    status string
    message string
}

struct UserResponse extends BaseResponse {
    user User
}

// UserResponse has: status, message, user

Rules:

Complex Example

namespace ecommerce

enum ContactType {
    email
    phone
    sms
}

struct Contact {
    type  ContactType
    value string
}

struct Address {
    street     string
    city       string
    state      string
    zipCode    string
    country    string
    isPrimary  bool  [optional]
}

struct User {
    userId      string
    name        string
    email       string
    contacts    []Contact
    metadata    map[string]string
    address     Address  [optional]
    createdAt   int
    verified    bool
}

Type Validation

PulseRPC runtimes automatically validate:

See Validation for details.

Next Steps