* @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:----RWunFMYPck+kqbmPCFOqp9rtQhU2ssgxuNrojY9u+9+LrsOpwPJmUWmKPsCeNb9xsqUgE/Lg8u6/QlbXdLaRtNvLVsGTCUtOF/KfIyqpGWjKa86TR0U1Am8RWSIqQNWY6qMfEggU54bw6fTw0/oezDYIKeIAwwDp8A7hrVaauJBsZpwJjJWlWoeuU8BbQeS8LK4gMTJ2ehQVZyYjw0r1SGOv4W28MxIuhl9+NfA7mAFcrF3+gLzCCHIduSbnHpwqCJ5iE7NLG9SDR3Q42qQhk2E+WO8gyOSlxZemyzI/61/uxtSYFV/OuR1mFCkBDDUSqpb42GCgn6Z3nniV97oSRT0sqgbLVzFgXSmlZsZczaIujqlP8z0WQ4MLT7iU4hMmA3uZ5DYpb/5oulT8KP1+X15rI8YGhwdaFAjmv1B5z70UejV8AHymxSIs91xt14OQ8r7Aw7/kgit09QW6ITG18im2NNm4u0we+maHtIg3n8VEiC3DVtTiK7h7EGqE1KJpi4Fu8DPWrJnXrmDHAbpPJ7gM4KpDTT72a4llDaP7M+iinFswcNknTRz5JV74iYnyz7MeBqkjUeDW83DowirZp7haiG60v4t8BcYfDHiofkyfrR9mJ/QXEFapsdoBUKmCtYCilNfqj24PTJRSQ6oVwMj1E++RD4Hd0EIQntCV0A4=----ATTACHMENT:----MjE2MDMyNjYyOTYzNjMyMCA1ODQ0NTcyNTYwMTUxNDI3IDMwOTkyMzMyMjUzMjgyNjE=