(
&mut self,
tag: u8,
ty: PsqlType,
name: Option<&str>,
value: ValueWithType<AlgebraicValue>,
)
| 140 | } |
| 141 | |
| 142 | fn write_variant( |
| 143 | &mut self, |
| 144 | tag: u8, |
| 145 | ty: PsqlType, |
| 146 | name: Option<&str>, |
| 147 | value: ValueWithType<AlgebraicValue>, |
| 148 | ) -> Result<(), Self::Error> { |
| 149 | // Is a simple enum? |
| 150 | if let AlgebraicType::Sum(sum) = &ty.field.algebraic_type |
| 151 | && sum.is_simple_enum() |
| 152 | && let Some(variant_name) = name |
| 153 | { |
| 154 | self.encoder.encode_field(&variant_name)?; |
| 155 | return Ok(()); |
| 156 | } |
| 157 | |
| 158 | let PsqlChars { start, sep, end, quote } = ty.client.format_chars(); |
| 159 | let name = name.map(Cow::from).unwrap_or_else(|| Cow::from(tag.to_string())); |
| 160 | let json = format!( |
| 161 | "{start}{quote}{name}{quote}{sep} {}{end}", |
| 162 | satn::PsqlWrapper { ty, value } |
| 163 | ); |
| 164 | self.encoder.encode_field(&json)?; |
| 165 | Ok(()) |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | #[cfg(test)] |
nothing calls this directly
no test coverage detected