RoleDef

Struct RoleDef 

Source
pub struct RoleDef {
    pub name: &'static str,
    pub superuser: Option<bool>,
    pub create_db: Option<bool>,
    pub create_role: Option<bool>,
    pub inherit: Option<bool>,
    pub can_login: Option<bool>,
    pub replication: Option<bool>,
    pub bypass_rls: Option<bool>,
    pub conn_limit: Option<i32>,
    pub password: Option<&'static str>,
    pub valid_until: Option<&'static str>,
}
Expand description

Const-friendly role definition for compile-time schema definitions.

Fields§

§name: &'static str

Role name

§superuser: Option<bool>

Superuser privilege

§create_db: Option<bool>

Can create databases?

§create_role: Option<bool>

Can create roles?

§inherit: Option<bool>

Inherit privileges?

§can_login: Option<bool>

Can login?

§replication: Option<bool>

Replication privilege

§bypass_rls: Option<bool>

Bypass row-level security

§conn_limit: Option<i32>

Connection limit (-1 for unlimited)

§password: Option<&'static str>

Password (encrypted)

§valid_until: Option<&'static str>

Password expiration date

Implementations§

Source§

impl RoleDef

Source

pub const fn new(name: &'static str) -> Self

Create a new role definition

Source

pub const fn superuser(self, value: bool) -> Self

Set superuser privilege

Source

pub const fn create_db(self, value: bool) -> Self

Set create_db flag

Source

pub const fn create_role(self, value: bool) -> Self

Set create_role flag

Source

pub const fn inherit(self, value: bool) -> Self

Set inherit flag

Source

pub const fn can_login(self, value: bool) -> Self

Set can_login flag

Source

pub const fn replication(self, value: bool) -> Self

Set replication privilege

Source

pub const fn bypass_rls(self, value: bool) -> Self

Set bypass_rls flag

Source

pub const fn conn_limit(self, limit: i32) -> Self

Set connection limit

Source

pub const fn password(self, password: &'static str) -> Self

Set password

Source

pub const fn valid_until(self, date: &'static str) -> Self

Set valid_until date

Source

pub const fn into_role(self) -> Role

Convert to runtime Role type

Trait Implementations§

Source§

impl Clone for RoleDef

Source§

fn clone(&self) -> RoleDef

Returns a duplicate 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 RoleDef

Source§

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

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

impl Default for RoleDef

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<RoleDef> for Role

Source§

fn from(def: RoleDef) -> Self

Converts to this type from the input type.
Source§

impl Hash for RoleDef

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for RoleDef

Source§

fn eq(&self, other: &RoleDef) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for RoleDef

Source§

impl Eq for RoleDef

Source§

impl StructuralPartialEq for RoleDef

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