pub struct User {
pub id: Uuid,
}Fields§
§id: UuidImplementations§
Source§impl User
impl User
pub async fn add_account(&self, script: &[u8]) -> Result<Account, ServerError>
pub async fn create_account( &self, name: &str, parent: Option<Uuid>, ) -> Result<Account, ServerError>
pub async fn set_account_tag( &self, a: &Account, t: &Tag, ) -> Result<(), ServerError>
pub async fn list_transaction_ids_by_account( &self, account_id: Uuid, ) -> Result<Vec<Uuid>, ServerError>
pub async fn get_account_tag( &self, a: &Account, tag: &String, ) -> Result<Tag, ServerError>
Source§impl User
impl User
Sourcepub async fn account_snapshot(
&self,
account_id: Uuid,
) -> Result<Option<StoredAccount>, ServerError>
pub async fn account_snapshot( &self, account_id: Uuid, ) -> Result<Option<StoredAccount>, ServerError>
The account’s parent and tags as of one instant; None when the user
has no such account.
§Errors
The connection or a query failing.
Source§impl User
impl User
pub async fn list_scripts(&self) -> Result<Vec<ScriptInfo>, ServerError>
pub async fn get_script(&self, id: Uuid) -> Result<ScriptDetail, ServerError>
Sourcepub async fn create_script(
&self,
bytecode: Vec<u8>,
name: Option<String>,
) -> Result<Uuid, ServerError>
pub async fn create_script( &self, bytecode: Vec<u8>, name: Option<String>, ) -> Result<Uuid, ServerError>
A script stored as bytecode alone, the shape a pre-source script has.
Sourcepub async fn create_script_from_source(
&self,
source: String,
bytecode: Vec<u8>,
name: Option<String>,
enabled: bool,
) -> Result<Uuid, ServerError>
pub async fn create_script_from_source( &self, source: String, bytecode: Vec<u8>, name: Option<String>, enabled: bool, ) -> Result<Uuid, ServerError>
Store a script with the bytecode compiled from its source.
Sourcepub async fn update_script_source(
&self,
id: Uuid,
source: String,
bytecode: Vec<u8>,
) -> Result<(), ServerError>
pub async fn update_script_source( &self, id: Uuid, source: String, bytecode: Vec<u8>, ) -> Result<(), ServerError>
Replace a script’s source and its bytecode in one statement.
§Errors
A missing script, or a failing write.
Sourcepub async fn update_script(
&self,
id: Uuid,
revision: &str,
name: Option<String>,
enabled: bool,
code: (&str, &[u8]),
) -> Result<(), ServerError>
pub async fn update_script( &self, id: Uuid, revision: &str, name: Option<String>, enabled: bool, code: (&str, &[u8]), ) -> Result<(), ServerError>
Replace the script’s name, enabled state, source and bytecode in one
transaction under the name and enabled keys, refusing with
ServerError::StaleScript when it no longer matches revision.
§Errors
A missing script, a stale revision, or a failing write.
Sourcepub async fn delete_script(&self, id: Uuid) -> Result<bool, ServerError>
pub async fn delete_script(&self, id: Uuid) -> Result<bool, ServerError>
Whether the script existed.
pub async fn set_script_enabled( &self, id: Uuid, enabled: bool, ) -> Result<(), ServerError>
pub async fn update_script_name( &self, id: Uuid, name: Option<String>, ) -> Result<(), ServerError>
pub async fn list_templates(&self) -> Result<Vec<TemplateInfo>, ServerError>
pub async fn get_template( &self, id: Uuid, ) -> Result<TemplateDetail, ServerError>
pub async fn find_template( &self, id: Uuid, ) -> Result<Option<TemplateDetail>, ServerError>
pub async fn create_template( &self, source: String, name: Option<String>, ) -> Result<Uuid, ServerError>
Sourcepub async fn update_template(
&self,
id: Uuid,
revision: &str,
name: Option<String>,
source: &str,
) -> Result<(), ServerError>
pub async fn update_template( &self, id: Uuid, revision: &str, name: Option<String>, source: &str, ) -> Result<(), ServerError>
Replace the template’s name and source in one transaction under the
name keys, refusing with ServerError::StaleTemplate when it no
longer matches revision.
§Errors
A missing template, a stale revision, or a failing write.
Sourcepub async fn delete_template(&self, id: Uuid) -> Result<bool, ServerError>
pub async fn delete_template(&self, id: Uuid) -> Result<bool, ServerError>
Whether the template existed.
Source§impl User
impl User
pub async fn add_commodity( &self, script: &[u8], ) -> Result<Commodity, ServerError>
pub async fn create_commodity( &self, symbol: String, name: String, ) -> Result<Commodity, ServerError>
pub async fn set_commodity_tag( &self, c: &Commodity, t: &Tag, ) -> Result<(), ServerError>
pub async fn get_commodity_tag( &self, c: &Commodity, tag: &String, ) -> Result<Tag, ServerError>
Source§impl User
impl User
Sourcepub async fn commodity_snapshot(
&self,
commodity_id: Uuid,
) -> Result<Option<StoredCommodity>, ServerError>
pub async fn commodity_snapshot( &self, commodity_id: Uuid, ) -> Result<Option<StoredCommodity>, ServerError>
The commodity’s tags as of one instant; None when the user has no
such commodity.
§Errors
The connection or a query failing.
Source§impl User
impl User
Sourcepub async fn transaction_snapshot(
&self,
tx_id: Uuid,
) -> Result<Option<TransactionSnapshot>, ServerError>
pub async fn transaction_snapshot( &self, tx_id: Uuid, ) -> Result<Option<TransactionSnapshot>, ServerError>
The transaction with everything attached to it, as of one instant;
None when it does not exist.
§Errors
The connection or a query failing.
Source§impl User
impl User
Sourcepub async fn require_transaction(&self, tx_id: Uuid) -> Result<(), ServerError>
pub async fn require_transaction(&self, tx_id: Uuid) -> Result<(), ServerError>
Sourcepub async fn require_split(&self, split_id: Uuid) -> Result<(), ServerError>
pub async fn require_split(&self, split_id: Uuid) -> Result<(), ServerError>
Sourcepub async fn get_transaction_splits(
&self,
tx_id: Uuid,
) -> Result<Vec<Split>, ServerError>
pub async fn get_transaction_splits( &self, tx_id: Uuid, ) -> Result<Vec<Split>, ServerError>
Every stored tag of each of splits, as split_tags_of reads them.
§Errors
The connection or a query failing.
Source§impl User
impl User
pub async fn create_tag( &self, name: String, value: String, description: Option<String>, ) -> Result<Uuid, ServerError>
Sourcepub async fn update_tag(
&self,
id: Uuid,
revision: &str,
name: String,
value: String,
description: Option<String>,
) -> Result<(), ServerError>
pub async fn update_tag( &self, id: Uuid, revision: &str, name: String, value: String, description: Option<String>, ) -> Result<(), ServerError>
Replace the tag, refusing with ServerError::StaleTag when it no
longer matches revision, checked under the key lock.
Sourcepub async fn create_transaction_tag(
&self,
tx_id: Uuid,
name: String,
value: String,
description: Option<String>,
) -> Result<Uuid, ServerError>
pub async fn create_transaction_tag( &self, tx_id: Uuid, name: String, value: String, description: Option<String>, ) -> Result<Uuid, ServerError>
Upsert the tag and link it to the transaction in one DB transaction, owner locked first.
Sourcepub async fn delete_tag(&self, id: Uuid) -> Result<bool, ServerError>
pub async fn delete_tag(&self, id: Uuid) -> Result<bool, ServerError>
Cascade-delete a tag: detach from every join table, then drop the
row from tags, under its key lock. Used by user-initiated tag
deletion in the UI.
§Errors
A failing write, or crate::db::DBError::WriteConflict when the
tag was renamed during every attempt.
Whether the tag existed.
pub async fn list_tag_names( &self, scope: TagScope, ) -> Result<Vec<String>, ServerError>
pub async fn list_tag_values_for( &self, scope: TagScope, tag_name: &str, ) -> Result<Vec<String>, ServerError>
pub async fn list_transaction_tag_names( &self, ) -> Result<Vec<String>, ServerError>
pub async fn list_transaction_tag_values( &self, tag_name: &str, ) -> Result<Vec<String>, ServerError>
Sourcepub async fn create_split_tag(
&self,
split_id: Uuid,
name: String,
value: String,
description: Option<String>,
) -> Result<Uuid, ServerError>
pub async fn create_split_tag( &self, split_id: Uuid, name: String, value: String, description: Option<String>, ) -> Result<Uuid, ServerError>
Split counterpart of create_transaction_tag; locks the split’s
owning transaction.
Sourcepub async fn set_split_tag(
&self,
split_id: Uuid,
t: &Tag,
) -> Result<(), ServerError>
pub async fn set_split_tag( &self, split_id: Uuid, t: &Tag, ) -> Result<(), ServerError>
Upsert-style set: replace any existing (split, tag_name) link with
the (tag_name, tag_value) pair from t. Mirrors set_account_tag
— script-friendly idempotent set semantics.
Sourcepub async fn set_transaction_tag(
&self,
tx_id: Uuid,
t: &Tag,
) -> Result<(), ServerError>
pub async fn set_transaction_tag( &self, tx_id: Uuid, t: &Tag, ) -> Result<(), ServerError>
Companion to set_split_tag for transactions.
Read all tags attached to a single split. Parallel to
get_transaction_tags; the script-side get-split-tag native
looks up by name in the returned vec.
pub async fn list_account_tag_names(&self) -> Result<Vec<String>, ServerError>
pub async fn list_account_tag_values( &self, tag_name: &str, ) -> Result<Vec<String>, ServerError>
pub async fn list_commodity_tag_names(&self) -> Result<Vec<String>, ServerError>
pub async fn list_commodity_tag_values( &self, tag_name: &str, ) -> Result<Vec<String>, ServerError>
pub async fn list_split_tag_names(&self) -> Result<Vec<String>, ServerError>
pub async fn list_split_tag_values( &self, tag_name: &str, ) -> Result<Vec<String>, ServerError>
Source§impl User
impl User
pub async fn get_connection(&self) -> Result<TenantConnection, DBError>
Auto Trait Implementations§
impl Freeze for User
impl RefUnwindSafe for User
impl Send for User
impl Sync for User
impl Unpin for User
impl UnsafeUnpin for User
impl UnwindSafe for User
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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