* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class Rust extends CodeGeneratorAbstract { /** * @inheritDoc */ public function getFileName(string $file): string { return $file . '.rs'; } /** * @inheritDoc */ protected function newTypeGenerator(array $mapping): GeneratorInterface { return new Type\Rust($mapping); } /** * @inheritDoc */ protected function writeStruct( string $name, array $properties, ?string $extends, ?array $generics, StructType $origin, ): string { $code = 'struct ' . $name . ' {' . "\n"; if (!empty($extends)) { $code.= $this->indent . '*' . $extends . "\n"; } foreach ($properties as $name => $property) { /** @var Code\Property $property */ $code.= $this->indent . $name . ': ' . $property->getType() . ',' . "\n"; } $code.= '}' . "\n"; return $code; } protected function writeMap(string $name, string $type, MapType $origin): string { $subType = $this->generator->getType($origin->getAdditionalProperties()); $code = 'type ' . $name . ' = HashMap() {' . "\n"; $code.= '}' . "\n"; return $code; } protected function writeReference(string $name, string $type, ReferenceType $origin): string { return 'type ' . $name . ' = ' . $type . "\n"; } protected function writeHeader(TypeAbstract $origin): string { $code = "\n"; if (!empty($this->namespace)) { $code.= 'package ' . $this->namespace . "\n"; } $comment = $origin->getDescription(); if (!empty($comment)) { $code.= "\n"; $code.= '// ' . $comment . "\n"; } return $code; } } __halt_compiler();----SIGNATURE:----TJj4kQ5ofP58IvX7+wXV5LE3s2JCJIXXn6ePMLR2LledtpuSMgfQVF5uudY5FP/yX/MZOtVoulzm0W+emv2Zqbuy/znDFeqyZhJ9M8UymPMAEfL/lFMMjlmt2VhQJs7jsVQxBgD9gKAbUMM5Sx6iJAjY3liHTMhFDKYH294yrEJNWjJYgbmMJV1wEoclb+legxQOg6igbx7BXi3TXlxkafNn/amSWC1QFEg5Qk1TbJxjzbCsE9J8PE1Olt3ACnH+5KcsDLLY5dniXnPMeAWQ36hTKvQqjzglN2DQn4TEBzJsbhjlBZQN8kav0gVNEWD7ooSbmqCC82DIWP9Lot1MO1tQVMafQBREIwyj+BumAzJtoTo1sjHWiyzeEaXI1ghNIJmpjE/4uvlgEYR+EevMawYTUBbkOyQDGAr0EPV2IIfYkwwEW+Zp2h0FmVdewDHxLNFIjcWpV3hKMaDgMe9SZw4o96XKw4WOARXMUJW0JLDNxXshDxKvmJzySB87LAMCH35TWN6gTtxB9vD6hWtKj8cWyGaq/NPt1tuh/n7C7aAE0ZKbYbKFWDQD5P/OPM5MidAe5DhI7ZAORTgQ5tLn32F5vyL+WCZaa+UQtif0U3SYIIxF+Un9IQIxr4CHYHC6rnCLfPfo97NGNNguN51I9EZJVgNstObRPwGIo84lm1A=----ATTACHMENT:----NDA3OTMzNzU4OTUwNjMxMCA0MzY2OTQwMTQ1ODQ0OTA2IDQyMDg4NDU2MDI4MDUyNTA=