pub struct BlockSession { /* private fields */ }Expand description
The datasource, scope id, and session of one running transacted block.
A segment builds one per block entry and installs it for the body task
through BlockSession::enter; joined steps then read it with
current_block_session. Cloning is cheap: the datasource is shared and
the session is an Arc (the block keeps its own handle for commit or
rollback).
Implementations§
Source§impl BlockSession
impl BlockSession
Sourcepub fn new(
datasource: impl Into<Arc<str>>,
scope: JoinScope,
session: Arc<dyn TransactionSession>,
) -> Self
pub fn new( datasource: impl Into<Arc<str>>, scope: JoinScope, session: Arc<dyn TransactionSession>, ) -> Self
Build the binding for a block on datasource in scope scope.
session is the block’s owned session handle, the same allocation the
block later commits or rolls back.
Sourcepub fn datasource(&self) -> &str
pub fn datasource(&self) -> &str
Datasource the block is transacted on.
Sourcepub fn scope(&self) -> JoinScope
pub fn scope(&self) -> JoinScope
Scope id of the enclosing block.
A joined step compares this with its own baked JoinScope; equality
proves the step belongs to this block.
Sourcepub fn session(&self) -> Arc<dyn TransactionSession> ⓘ
pub fn session(&self) -> Arc<dyn TransactionSession> ⓘ
The block’s transaction session.
Returned as a clone of the shared handle; the caller must still go
through the port (lazy begin, rollback-only marking) and must not
finalize it.
Sourcepub async fn enter<F: Future>(self, fut: F) -> F::Output
pub async fn enter<F: Future>(self, fut: F) -> F::Output
Install self as BLOCK_SESSION for the task that polls fut.
The binding ends when fut completes or is dropped, so nested blocks
shadow and unwrap without touching the outer binding.