Skip to main content

Sqlite

Struct Sqlite 

Source
pub struct Sqlite { /* private fields */ }
Expand description

§Capabilities

Depending on its configuration and the backing system, this service can expose:

  • create_dir
  • stat
  • read
  • write
  • delete
  • list
  • copy
  • rename
  • presign

Inspect the effective capability set with opendal_core::Operator::info and opendal_core::OperatorInfo::capability after building an operator.

§Configuration

Use crate::SqliteConfig for serializable configuration and this builder’s methods for direct construction. The field and method documentation defines accepted values, defaults, and environment interaction.

§Example

§Via Builder

use opendal_core::Operator;
use opendal_core::Result;
use opendal_service_sqlite::Sqlite;

#[tokio::main]
async fn main() -> Result<()> {
    let mut builder = Sqlite::default()
        .root("/")
        .connection_string("file//abc.db")
        .table("your_table")
        // key field type in the table should be compatible with Rust's &str like text
        .key_field("key")
        // value field type in the table should be compatible with Rust's Vec<u8> like bytea
        .value_field("value");

    let op = Operator::new(builder)?;
    Ok(())
}

Implementations§

Source§

impl SqliteBuilder

Source

pub fn connection_string(self, v: &str) -> Self

Set the connection_string of the sqlite service.

This connection string is used to connect to the sqlite service. There are url based formats:

§Url

This format resembles the url format of the sqlite client:

  • sqlite::memory:
  • sqlite:data.db
  • sqlite://data.db

For more information, please visit https://docs.rs/sqlx/latest/sqlx/sqlite/struct.SqliteConnectOptions.html.

Source

pub fn root(self, root: &str) -> Self

set the working directory, all operations will be performed under it.

default: “/”

Source

pub fn table(self, table: &str) -> Self

Set the table name of the sqlite service to read/write.

Source

pub fn key_field(self, key_field: &str) -> Self

Set the key field name of the sqlite service to read/write.

Default to key if not specified.

Source

pub fn value_field(self, value_field: &str) -> Self

Set the value field name of the sqlite service to read/write.

Default to value if not specified.

Trait Implementations§

Source§

impl Builder for SqliteBuilder

Source§

type Config = SqliteConfig

Associated configuration.
Source§

fn build(self) -> Result<impl Service>

Consume the builder to build a service.
Source§

impl Debug for SqliteBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SqliteBuilder

Source§

fn default() -> SqliteBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more