surrealdb::dbs

Struct Options

Source
pub struct Options {
Show 14 fields pub auth: Arc<Auth>, pub auth_enabled: bool, pub live: bool, pub force: bool, pub perms: bool, pub strict: bool, pub fields: bool, pub events: bool, pub tables: bool, pub indexes: bool, pub futures: bool, pub projections: bool, pub sender: Option<Sender<Notification>>, pub capabilities: Arc<Capabilities>, /* private fields */
}
Expand description

An Options is passed around when processing a set of query statements. An Options contains specific information for how to process each particular statement, including the record version to retrieve, whether futures should be processed, and whether field/event/table queries should be processed (useful when importing data, where these queries might fail).

Fields§

§auth: Arc<Auth>

Connection authentication data

§auth_enabled: bool

Is authentication enabled?

§live: bool

Whether live queries are allowed?

§force: bool

Should we force tables/events to re-run?

§perms: bool

Should we run permissions checks?

§strict: bool

Should we error if tables don’t exist?

§fields: bool

Should we process field queries?

§events: bool

Should we process event queries?

§tables: bool

Should we process table queries?

§indexes: bool

Should we process index queries?

§futures: bool

Should we process function futures?

§projections: bool

Should we process variable field projections?

§sender: Option<Sender<Notification>>

The channel over which we send notifications

§capabilities: Arc<Capabilities>

Datastore capabilities

Implementations§

Source§

impl Options

Source

pub fn new() -> Options

Create a new Options object

Source

pub fn set_ns(&mut self, ns: Option<Arc<str>>)

Specify which Namespace should be used for code which uses this Options object.

Source

pub fn set_db(&mut self, db: Option<Arc<str>>)

Specify which Database should be used for code which uses this Options object.

Source

pub fn with_required( self, node_id: Uuid, ns: Option<Arc<str>>, db: Option<Arc<str>>, auth: Arc<Auth>, ) -> Self

Set all the required options from a single point. The system expects these values to always be set, so this should be called for all instances when there is doubt.

Source

pub fn with_id(self, id: Uuid) -> Self

Set the Node ID for subsequent code which uses this Options, with support for chaining.

Source

pub fn with_ns(self, ns: Option<Arc<str>>) -> Self

Specify which Namespace should be used for code which uses this Options, with support for chaining.

Source

pub fn with_db(self, db: Option<Arc<str>>) -> Self

Specify which Database should be used for code which uses this Options, with support for chaining.

Source

pub fn with_auth(self, auth: Arc<Auth>) -> Self

Specify the authentication options for subsequent code which uses this Options, with chaining.

Source

pub fn with_live(self, live: bool) -> Self

Specify whether live queries are supported for code which uses this Options, with chaining.

Source

pub fn with_perms(self, perms: bool) -> Self

Specify whether permissions should be run for code which uses this Options, with chaining.

Source

pub fn with_force(self, force: bool) -> Self

Source

pub fn with_strict(self, strict: bool) -> Self

Source

pub fn with_fields(self, fields: bool) -> Self

Source

pub fn with_events(self, events: bool) -> Self

Source

pub fn with_tables(self, tables: bool) -> Self

Source

pub fn with_indexes(self, indexes: bool) -> Self

Source

pub fn with_futures(self, futures: bool) -> Self

Source

pub fn with_projections(self, projections: bool) -> Self

Source

pub fn with_import(self, import: bool) -> Self

Create a new Options object for a subquery

Source

pub fn with_auth_enabled(self, auth_enabled: bool) -> Self

Create a new Options object with auth enabled

Source

pub fn with_capabilities(self, capabilities: Arc<Capabilities>) -> Self

Create a new Options object with the given Capabilities

Source

pub fn new_with_perms(&self, perms: bool) -> Self

Create a new Options object for a subquery

Source

pub fn new_with_force(&self, force: bool) -> Self

Create a new Options object for a subquery

Source

pub fn new_with_strict(&self, strict: bool) -> Self

Create a new Options object for a subquery

Source

pub fn new_with_fields(&self, fields: bool) -> Self

Create a new Options object for a subquery

Source

pub fn new_with_events(&self, events: bool) -> Self

Create a new Options object for a subquery

Source

pub fn new_with_tables(&self, tables: bool) -> Self

Create a new Options object for a subquery

Source

pub fn new_with_indexes(&self, indexes: bool) -> Self

Create a new Options object for a subquery

Source

pub fn new_with_futures(&self, futures: bool) -> Self

Create a new Options object for a subquery

Source

pub fn new_with_projections(&self, projections: bool) -> Self

Create a new Options object for a subquery

Source

pub fn new_with_import(&self, import: bool) -> Self

Create a new Options object for a subquery

Source

pub fn new_with_sender(&self, sender: Sender<Notification>) -> Self

Create a new Options object for a subquery

Source

pub fn selected_base(&self) -> Result<Base, Error>

Source

pub fn dive(&self, cost: u8) -> Result<Self, Error>

Create a new Options object for a function/subquery/future/etc.

The parameter is the approximate cost of the operation (more concretely, the size of the stack frame it uses relative to a simple function call). When in doubt, use a value of 1.

Source

pub fn id(&self) -> Result<Uuid, Error>

Get current Node ID

Source

pub fn ns(&self) -> &str

Get currently selected NS

Source

pub fn db(&self) -> &str

Get currently selected DB

Source

pub fn realtime(&self) -> Result<(), Error>

Check whether this request supports realtime queries

Source

pub fn valid_for_ns(&self) -> Result<(), Error>

Source

pub fn valid_for_db(&self) -> Result<(), Error>

Source

pub fn is_allowed( &self, action: Action, res: ResourceKind, base: &Base, ) -> Result<(), Error>

Check if the current auth is allowed to perform an action on a given resource

Source

pub fn check_perms(&self, action: Action) -> bool

Whether or not to check table permissions

TODO: This method is called a lot during data operations, so we decided to bypass the system’s authorization mechanism. This is a temporary solution, until we optimize the new authorization system.

Trait Implementations§

Source§

impl Clone for Options

Source§

fn clone(&self) -> Options

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Options

Source§

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

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

impl Default for Options

Source§

fn default() -> Self

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

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

Source§

fn vzip(self) -> V

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

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool

Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T

Source§

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