title: Overview sidebar_position: 1 id: index license: | Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
This document explains generated code for each target language.
Fory IDL generated types are idiomatic in host languages and can be used directly as domain objects. Generated types also include to/from bytes helpers and schema modules or registration helpers, depending on the target language.
Generated schema modules are named from the schema source file, not from the package or namespace. In targets that expose the module directly in a language package or namespace, names such as AddressbookForyModule or ComplexPbForyModule let multiple IDL files target the same package or namespace without producing colliding ForyModule types.
The examples below use two real schemas:
addressbook.fdl (explicit type IDs)auto_id.fdl (no explicit type IDs)addressbook.fdl Excerptpackage addressbook; option go_package = "github.com/myorg/myrepo/gen/addressbook;addressbook"; message Person [id=100] { string name = 1; int32 id = 2; enum PhoneType [id=101] { PHONE_TYPE_MOBILE = 0; PHONE_TYPE_HOME = 1; PHONE_TYPE_WORK = 2; } message PhoneNumber [id=102] { string number = 1; PhoneType phone_type = 2; } list<PhoneNumber> phones = 7; Animal pet = 8; } message Dog [id=104] { string name = 1; int32 bark_volume = 2; } message Cat [id=105] { string name = 1; int32 lives = 2; } union Animal [id=106] { Dog dog = 1; Cat cat = 2; } message AddressBook [id=103] { list<Person> people = 1; map<string, Person> people_by_name = 2; }
auto_id.fdl Excerptpackage auto_id; enum Status { UNKNOWN = 0; OK = 1; } message Envelope { string id = 1; message Payload { int32 value = 1; } union Detail { Payload payload = 1; string note = 2; } Payload payload = 2; Detail detail = 3; Status status = 4; } union Wrapper { Envelope envelope = 1; string raw = 2; }
[id=...] values are used directly by generated module installation or registration helpers.auto_id.* outputs).option enable_auto_type_id = false; is set, generated module installation or registration helpers use name-based APIs instead of numeric IDs.| Language | Nested type form |
|---|---|
| Java | Person.PhoneNumber |
| Python | Person.PhoneNumber |
| Rust | person::PhoneNumber |
| C++ | Person::PhoneNumber |
| Go | Person_PhoneNumber (default) |
| C# | Person.PhoneNumber |
| JavaScript/TypeScript | Person.PhoneNumber |
| Swift | Person.PhoneNumber |
| Dart | Person_PhoneNumber |
| Kotlin | PersonPhoneNumber |
| Scala | Person.PhoneNumber |
| Language | Helpers |
|---|---|
| Java | toBytes / fromBytes |
| Kotlin | toBytes / fromBytes |
| Scala | toBytes / fromBytes |
| Python | to_bytes / from_bytes |
| Rust | to_bytes / from_bytes |
| C++ | to_bytes / from_bytes |
| Go | ToBytes / FromBytes |
| C# | ToBytes / FromBytes |
| JavaScript/TypeScript | (via fory.serialize()) |
| Swift | toBytes / fromBytes |
| Dart | (via fory.serialize()) |
Choose the generated-code reference for the target language. Generated models remain ordinary language-native types and use the supported Fory serialization APIs for that language.
| Language | Generated-code reference |
|---|---|
| Java | Java |
| Python | Python |
| C++ | C++ |
| Go | Go |
| Rust | Rust |
| JavaScript/TypeScript | JavaScript/TypeScript |
| C# | C# |
| Swift | Swift |
| Dart | Dart |
| Scala | Scala |
| Kotlin | Kotlin |