tiberius/tds/codec/column_data/
xml.rs
1use std::{borrow::Cow, sync::Arc};
2
3use crate::{
4 sql_read_bytes::SqlReadBytes,
5 xml::{XmlData, XmlSchema},
6 ColumnData, VarLenType,
7};
8
9pub(crate) async fn decode<R>(
10 src: &mut R,
11 len: usize,
12 schema: Option<Arc<XmlSchema>>,
13) -> crate::Result<ColumnData<'static>>
14where
15 R: SqlReadBytes + Unpin,
16{
17 let xml = super::string::decode(src, VarLenType::Xml, len, None)
18 .await?
19 .map(|data| {
20 let mut data = XmlData::new(data);
21
22 if let Some(schema) = schema {
23 data.set_schema(schema);
24 }
25
26 Cow::Owned(data)
27 });
28
29 Ok(ColumnData::Xml(xml))
30}