MCPcopy Index your code
hub / github.com/github/copilot-sdk / emitRustConstStringEnum

Function emitRustConstStringEnum

scripts/codegen/rust.ts:1018–1045  ·  view source on GitHub ↗
(
	enumName: string,
	value: string,
	ctx: RustCodegenCtx,
	description?: string,
)

Source from the content-addressed store, hash-verified

1016}
1017
1018function emitRustConstStringEnum(
1019 enumName: string,
1020 value: string,
1021 ctx: RustCodegenCtx,
1022 description?: string,
1023): void {
1024 if (ctx.generatedNames.has(enumName)) return;
1025 ctx.generatedNames.add(enumName);
1026
1027 const lines: string[] = [];
1028 if (description) {
1029 for (const line of description.split(/\r?\n/)) {
1030 lines.push(`/// ${line}`);
1031 }
1032 }
1033 lines.push(
1034 "#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]",
1035 );
1036 lines.push(`pub enum ${enumName} {`);
1037 const variantName = toRustPascalIdentifier(value, "Value");
1038 if (variantName !== value) {
1039 lines.push(` #[serde(rename = "${value}")]`);
1040 }
1041 lines.push(" #[default]");
1042 lines.push(` ${variantName},`);
1043 lines.push("}");
1044 ctx.enums.push(lines.join("\n"));
1045}
1046
1047// ── Session events generation ───────────────────────────────────────────────
1048

Callers 1

resolveRustTypeFunction · 0.85

Calls 4

toRustPascalIdentifierFunction · 0.85
joinMethod · 0.80
addMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…