Skip to main content

User

Struct User 

Source
pub struct User {
    pub id: Uuid,
}

Fields§

§id: Uuid

Implementations§

Source§

impl User

Source

pub async fn add_account(&self, script: &[u8]) -> Result<Account, ServerError>

Source

pub async fn create_account( &self, name: &str, parent: Option<Uuid>, ) -> Result<Account, ServerError>

Source

pub async fn update_account_tags( &self, a: &Account, tags: &[Tag], ) -> Result<(), ServerError>

Source

pub async fn set_account_tag( &self, a: &Account, t: &Tag, ) -> Result<(), ServerError>

Source

pub async fn get_account_tags( &self, a: &Account, ) -> Result<Vec<Tag>, ServerError>

Source

pub async fn list_transaction_ids_by_account( &self, account_id: Uuid, ) -> Result<Vec<Uuid>, ServerError>

Source

pub async fn get_account_tag( &self, a: &Account, tag: &String, ) -> Result<Tag, ServerError>

Source§

impl User

Source

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

Source

pub async fn list_scripts(&self) -> Result<Vec<ScriptInfo>, ServerError>

Source

pub async fn get_script(&self, id: Uuid) -> Result<ScriptDetail, ServerError>

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn delete_script(&self, id: Uuid) -> Result<bool, ServerError>

Whether the script existed.

Source

pub async fn set_script_enabled( &self, id: Uuid, enabled: bool, ) -> Result<(), ServerError>

Source

pub async fn update_script_name( &self, id: Uuid, name: Option<String>, ) -> Result<(), ServerError>

Source

pub async fn list_templates(&self) -> Result<Vec<TemplateInfo>, ServerError>

Source

pub async fn get_template( &self, id: Uuid, ) -> Result<TemplateDetail, ServerError>

Source

pub async fn find_template( &self, id: Uuid, ) -> Result<Option<TemplateDetail>, ServerError>

Source

pub async fn create_template( &self, source: String, name: Option<String>, ) -> Result<Uuid, ServerError>

Source

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.

Source

pub async fn delete_template(&self, id: Uuid) -> Result<bool, ServerError>

Whether the template existed.

Source§

impl User

Source

pub async fn add_commodity( &self, script: &[u8], ) -> Result<Commodity, ServerError>

Source

pub async fn create_commodity( &self, symbol: String, name: String, ) -> Result<Commodity, ServerError>

Source

pub async fn update_commodity_tags( &self, c: &Commodity, tags: &[Tag], ) -> Result<(), ServerError>

Source

pub async fn set_commodity_tag( &self, c: &Commodity, t: &Tag, ) -> Result<(), ServerError>

Source

pub async fn get_commodity_tags( &self, c: &Commodity, ) -> Result<Vec<Tag>, ServerError>

Source

pub async fn get_commodity_tag( &self, c: &Commodity, tag: &String, ) -> Result<Tag, ServerError>

Source§

impl User

Source

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

Source

pub async fn transaction_ids(&self) -> Result<Vec<Uuid>, DBError>

The ids of every stored transaction, splits or not.

§Errors

DBError on a connection or query error.

Source§

impl User

Source

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

Source

pub async fn require_transaction(&self, tx_id: Uuid) -> Result<(), ServerError>

Confirms the transaction exists.

§Errors

RowNotFound when it does not, or a failing query.

Source

pub async fn require_split(&self, split_id: Uuid) -> Result<(), ServerError>

Confirms the split exists.

§Errors

RowNotFound when it does not, or a failing query.

Source

pub async fn get_transaction_splits( &self, tx_id: Uuid, ) -> Result<Vec<Split>, ServerError>

The splits of a transaction, without their tags.

§Errors

The connection or the query failing.

Source

pub async fn split_tags_of( &self, splits: &[Split], ) -> Result<HashMap<Uuid, Vec<Tag>>, ServerError>

Every stored tag of each of splits, as split_tags_of reads them.

§Errors

The connection or a query failing.

Source§

impl User

Source

pub async fn create_tag( &self, name: String, value: String, description: Option<String>, ) -> Result<Uuid, ServerError>

Source

pub async fn list_tags(&self) -> Result<Vec<Tag>, ServerError>

Source

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.

Source

pub async fn get_transaction_tags( &self, tx_id: Uuid, ) -> Result<Vec<Tag>, ServerError>

Source

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.

Source

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.

Source

pub async fn list_tag_names( &self, scope: TagScope, ) -> Result<Vec<String>, ServerError>

Source

pub async fn list_tag_values_for( &self, scope: TagScope, tag_name: &str, ) -> Result<Vec<String>, ServerError>

Source

pub async fn list_transaction_tag_names( &self, ) -> Result<Vec<String>, ServerError>

Source

pub async fn list_transaction_tag_values( &self, tag_name: &str, ) -> Result<Vec<String>, ServerError>

Source

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.

Source

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.

Source

pub async fn set_transaction_tag( &self, tx_id: Uuid, t: &Tag, ) -> Result<(), ServerError>

Companion to set_split_tag for transactions.

Source

pub async fn get_split_tags( &self, split_id: Uuid, ) -> Result<Vec<Tag>, ServerError>

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.

Source

pub async fn list_account_tag_names(&self) -> Result<Vec<String>, ServerError>

Source

pub async fn list_account_tag_values( &self, tag_name: &str, ) -> Result<Vec<String>, ServerError>

Source

pub async fn list_commodity_tag_names(&self) -> Result<Vec<String>, ServerError>

Source

pub async fn list_commodity_tag_values( &self, tag_name: &str, ) -> Result<Vec<String>, ServerError>

Source

pub async fn list_split_tag_names(&self) -> Result<Vec<String>, ServerError>

Source

pub async fn list_split_tag_values( &self, tag_name: &str, ) -> Result<Vec<String>, ServerError>

Source§

impl User

Source

pub async fn find_tag(&self, id: Uuid) -> Result<Option<Tag>, ServerError>

The tag, None when the user has no such tag.

§Errors

The connection or the query failing.

Source§

impl User

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> 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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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