#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct Fts5Options {
pub prefix: Option<String>,
pub tokenize: Option<String>,
pub content: Option<String>,
pub content_rowid: Option<String>,
pub columnsize: Option<u8>,
pub detail: Option<String>,
}
impl Fts5Options {
#[must_use]
pub fn render(&self) -> Vec<String> {
let mut args = Vec::new();
push_text(&mut args, "prefix", self.prefix.as_deref());
push_text(&mut args, "tokenize", self.tokenize.as_deref());
push_text(&mut args, "content", self.content.as_deref());
push_text(&mut args, "content_rowid", self.content_rowid.as_deref());
if let Some(columnsize) = self.columnsize {
args.push(format!("columnsize = {columnsize}"));
}
push_text(&mut args, "detail", self.detail.as_deref());
args
}
}
fn push_text(args: &mut Vec<String>, key: &str, value: Option<&str>) {
if let Some(value) = value {
args.push(format!("{key} = '{}'", escape_literal(value)));
}
}
fn escape_literal(value: &str) -> String {
value.replace('\'', "''")
}