Skip to main content

SyncHandle

Struct SyncHandle 

Source
pub struct SyncHandle<'db> { /* private fields */ }
Expand description

동기 핸들 — db.run_sync() 반환 타입 (명세 §5.0). 모든 작업은 read/write 통합 풀에서 커넥션을 체크아웃한다.

With the live feature, SQL classification is conservative. PRAGMA statements, including read-only forms, trigger full invalidation because SQLite state-changing forms cannot be distinguished reliably by the parser.

Implementations§

Source§

impl<'db> SyncHandle<'db>

Source

pub fn execute<P: Params>(&self, sql: &str, params: P) -> Result<u64>

쓰기 실행 (명세 §5.7)

Source

pub fn query_one<T: FromRow, P: Params>( &self, sql: &str, params: P, ) -> Result<T>

정확히 1건 조회 — 0건이면 Error::NotFound

Source

pub fn query_optional<T: FromRow, P: Params>( &self, sql: &str, params: P, ) -> Result<Option<T>>

0~1건 조회

Source

pub fn query_scalar<T: FromSql, P: Params>( &self, sql: &str, params: P, ) -> Result<T>

스칼라 1건 조회

Source

pub fn query_all<T: FromRow, P: Params>( &self, sql: &str, params: P, ) -> Result<Vec<T>>

N건 조회

Source

pub fn transaction<R>( &self, f: impl FnOnce(&mut Tx<'_>) -> Result<R>, ) -> Result<R>

클로저 트랜잭션 (명세 §5.5) — 에러 시 롤백, 성공 시 커밋

Source

pub fn begin(&self) -> Result<Tx<'db>>

RAII 트랜잭션 — drop 시 미커밋이면 롤백 (명세 §5.5)

Source

pub fn with_connection<R>( &self, f: impl FnOnce(&Connection) -> Result<R>, ) -> Result<R>

Runs a closure with one exclusively checked-out read/write connection.

Do not acquire another connection from the same database inside the closure when every pooled connection may already be checked out. Doing so can block indefinitely (or until the configured queue timeout) because the outer checkout cannot return.

With the live feature, direct writes are observed through SQLite’s update hook. SQLite does not invoke that hook for every change: notably, truncate-optimized DELETE statements and changes to WITHOUT ROWID tables may be missed. Use the handle’s SQL methods when live-query invalidation must be guaranteed.

Installing an SQLite preupdate_hook replaces roomrs’ live-query hook on that connection. With the live feature, call [Self::rearm_hooks] afterwards.

Trait Implementations§

Source§

impl<'db> Clone for SyncHandle<'db>

Source§

fn clone(&self) -> SyncHandle<'db>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'db> Copy for SyncHandle<'db>

Source§

impl Execute for SyncHandle<'_>

Source§

type Out<R: Send + 'static> = Result<R, Error>

실행 결과 컨테이너
Source§

fn run_all<T: FromRow + Send + 'static>( self, sql: String, params: Vec<Value>, ) -> Result<Vec<T>>

Source§

fn run_optional<T: FromRow + Send + 'static>( self, sql: String, params: Vec<Value>, ) -> Result<Option<T>>

Source§

fn run_one<T: FromRow + Send + 'static>( self, sql: String, params: Vec<Value>, ) -> Result<T>

Source§

fn run_scalar(self, sql: String, params: Vec<Value>) -> Result<i64>

Source§

fn fail<R: Send + 'static>(e: Error) -> Result<R>

빌드 단계 에러를 결과 컨테이너로
Source§

impl SqlContext for SyncHandle<'_>

Source§

fn ctx_transaction<R>(&self, f: impl FnOnce(&Tx<'_>) -> Result<R>) -> Result<R>

풀-바운드 트랜잭션 — BEGIN/COMMIT (에러 시 롤백)

Source§

fn ctx_execute<P: Params>(&self, sql: &str, params: P) -> Result<u64>

쓰기 실행 — 영향 행 수
Source§

fn ctx_insert<P: Params>(&self, sql: &str, params: P) -> Result<i64>

INSERT — 새 rowid
Source§

fn ctx_query_all<T: FromRow, P: Params>( &self, sql: &str, params: P, ) -> Result<Vec<T>>

N건 조회
Source§

fn ctx_query_optional<T: FromRow, P: Params>( &self, sql: &str, params: P, ) -> Result<Option<T>>

0~1건 조회
Source§

fn ctx_query_scalar<T: FromSql, P: Params>( &self, sql: &str, params: P, ) -> Result<T>

스칼라 1건 조회
Source§

fn ctx_query_one<T: FromRow, P: Params>( &self, sql: &str, params: P, ) -> Result<T>

정확히 1건 조회 (0건 = NotFound)

Auto Trait Implementations§

§

impl<'db> !RefUnwindSafe for SyncHandle<'db>

§

impl<'db> !UnwindSafe for SyncHandle<'db>

§

impl<'db> Freeze for SyncHandle<'db>

§

impl<'db> Send for SyncHandle<'db>

§

impl<'db> Sync for SyncHandle<'db>

§

impl<'db> Unpin for SyncHandle<'db>

§

impl<'db> UnsafeUnpin for SyncHandle<'db>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.