We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Here's a quick fix for supporting interleaved text (see #257).
diff --git a/src/de/var.rs b/src/de/var.rs index 781c7d9..c05fefe 100644 --- a/src/de/var.rs +++ b/src/de/var.rs @@ -17,6 +17,8 @@ impl<'a, R: BufRead> EnumAccess<'a, R> { } } +const TEXT_VARIANT: &[u8] = b"$text"; + impl<'de, 'a, R: 'a + BufRead> de::EnumAccess<'de> for EnumAccess<'a, R> { type Error = DeError; type Variant = VariantAccess<'a, R>; @@ -27,7 +29,7 @@ impl<'de, 'a, R: 'a + BufRead> de::EnumAccess<'de> for EnumAccess<'a, R> { ) -> Result<(V::Value, VariantAccess<'a, R>), DeError> { let decoder = self.de.reader.decoder(); let de = match self.de.peek()? { - Some(Event::Text(t)) => EscapedDeserializer::new(t.to_vec(), decoder, true), + Some(Event::Text(_)) => EscapedDeserializer::new(TEXT_VARIANT.to_vec(), decoder, false), Some(Event::Start(e)) => EscapedDeserializer::new(e.name().to_vec(), decoder, false), Some(e) => return Err(DeError::InvalidEnum(e.to_owned())), None => return Err(DeError::Eof),
Let's say I have the following TTML where the Text variant represents interleaved text:
Text
#[derive(Debug, Deserialize)] struct Div { #[serde(rename = "p")] pub paragraphs: Vec<Paragraph>, } #[derive(Debug, Deserialize)] struct Paragraph { #[serde(rename = "$value")] pub content: Vec<Content>, } #[derive(Debug, Deserialize)] enum Content { #[serde(rename = "br")] Br, #[serde(rename = "span")] Span { #[serde(rename = "tts:fontWeight")] font_weight: Option<String>, #[serde(rename = "tts:fontStyle")] font_style: Option<String>, #[serde(rename = "$value")] text: String, }, #[serde(rename = "$text")] Text(String), }
The text was updated successfully, but these errors were encountered:
Thanks for the sharing your code, I'll investigate it in its time. Closed as duplicate of #257
Sorry, something went wrong.
No branches or pull requests
Here's a quick fix for supporting interleaved text (see #257).
Let's say I have the following TTML where the
Text
variant represents interleaved text:The text was updated successfully, but these errors were encountered: