use crate::connection::DatabaseConnection;
use crate::lowlevel;
pub struct ConnectionString<'a> {
filename: &'a str,
readonly: bool,
}
impl<'a> ConnectionString<'a> {
pub fn connect(&self) -> crate::Result<DatabaseConnection> {
DatabaseConnection::connect(self)
}
}
impl<'a> ConnectionString<'a> {
pub fn new(filename: &'a str) -> Self {
Self {
filename,
readonly: false,
}
}
pub fn readonly(&mut self, readonly: bool) -> &mut Self {
self.readonly = readonly;
self
}
}
#[repr(C)]
pub(crate) struct ConnectionStringFFI {
filename: lowlevel::FFISlice,
readonly: bool,
}
impl ConnectionStringFFI {
pub fn from(cs: &ConnectionString) -> Self {
Self {
filename: lowlevel::FFISlice::from_byte_slice(cs.filename.as_bytes()),
readonly: cs.readonly,
}
}
}