Struct WorkspaceId
pub struct WorkspaceId(/* private fields */);Expand description
A unique identifier for a workspace. Workspace IDs are 10-byte random strings formatted in base32.
Internally, the workspace ID is stored as an ArrayString with a maximum length of 20 characters.
This means that values work entirely on the stack and implement the Copy trait.
§Example
use cts_common::WorkspaceId;
let workspace_id = WorkspaceId::generate().unwrap();
println!("Workspace ID: {}", workspace_id);A WorkspaceId can be converted from a string but will fail if the string is not a valid workspace ID.
use cts_common::WorkspaceId;
let workspace_id = WorkspaceId::try_from("JBSWY3DPEHPK3PXP").unwrap();
// This will fail because the string is not a valid workspace ID
let workspace_id = WorkspaceId::try_from("invalid-id").unwrap_err();§Comparison
Workspace IDs can be compared to strings.
use cts_common::WorkspaceId;
let workspace_id = WorkspaceId::try_from("E4UMRN47WJNSMAKR").unwrap();
assert_eq!(workspace_id, "E4UMRN47WJNSMAKR");§Use with Diesel
When the server feature is enabled, WorkspaceId can be used with Diesel in models and queries.
The underlying data type is a Text column in the database.
Implementations§
Source§impl WorkspaceId
impl WorkspaceId
Sourcepub fn generate() -> Result<WorkspaceId, WorkspaceIdGenerationError>
pub fn generate() -> Result<WorkspaceId, WorkspaceIdGenerationError>
Generate a new workspace ID with an entropy source.
To use a SafeRand instance, use the Generatable::random method instead.
pub fn as_str(&self) -> &str
Trait Implementations§
Source§impl<'__expr> AsExpression<Nullable<Text>> for &'__expr WorkspaceId
impl<'__expr> AsExpression<Nullable<Text>> for &'__expr WorkspaceId
Source§type Expression = Bound<Nullable<Text>, &'__expr WorkspaceId>
type Expression = Bound<Nullable<Text>, &'__expr WorkspaceId>
The expression being returned
Source§fn as_expression(
self,
) -> <&'__expr WorkspaceId as AsExpression<Nullable<Text>>>::Expression
fn as_expression( self, ) -> <&'__expr WorkspaceId as AsExpression<Nullable<Text>>>::Expression
Perform the conversion
Source§impl AsExpression<Nullable<Text>> for WorkspaceId
impl AsExpression<Nullable<Text>> for WorkspaceId
Source§type Expression = Bound<Nullable<Text>, WorkspaceId>
type Expression = Bound<Nullable<Text>, WorkspaceId>
The expression being returned
Source§fn as_expression(
self,
) -> <WorkspaceId as AsExpression<Nullable<Text>>>::Expression
fn as_expression( self, ) -> <WorkspaceId as AsExpression<Nullable<Text>>>::Expression
Perform the conversion
Source§impl<'__expr> AsExpression<Text> for &'__expr WorkspaceId
impl<'__expr> AsExpression<Text> for &'__expr WorkspaceId
Source§type Expression = Bound<Text, &'__expr WorkspaceId>
type Expression = Bound<Text, &'__expr WorkspaceId>
The expression being returned
Source§fn as_expression(
self,
) -> <&'__expr WorkspaceId as AsExpression<Text>>::Expression
fn as_expression( self, ) -> <&'__expr WorkspaceId as AsExpression<Text>>::Expression
Perform the conversion
Source§impl AsExpression<Text> for WorkspaceId
impl AsExpression<Text> for WorkspaceId
Source§type Expression = Bound<Text, WorkspaceId>
type Expression = Bound<Text, WorkspaceId>
The expression being returned
Source§fn as_expression(self) -> <WorkspaceId as AsExpression<Text>>::Expression
fn as_expression(self) -> <WorkspaceId as AsExpression<Text>>::Expression
Perform the conversion
Source§impl Clone for WorkspaceId
impl Clone for WorkspaceId
Source§fn clone(&self) -> WorkspaceId
fn clone(&self) -> WorkspaceId
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WorkspaceId
impl Debug for WorkspaceId
Source§impl<'de> Deserialize<'de> for WorkspaceId
impl<'de> Deserialize<'de> for WorkspaceId
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<WorkspaceId, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<WorkspaceId, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for WorkspaceId
impl Display for WorkspaceId
Source§impl Dummy<Faker> for WorkspaceId
impl Dummy<Faker> for WorkspaceId
Source§impl From<WorkspaceId> for String
impl From<WorkspaceId> for String
Source§fn from(value: WorkspaceId) -> String
fn from(value: WorkspaceId) -> String
Converts to this type from the input type.
Source§impl<DB> FromSql<Text, DB> for WorkspaceId
impl<DB> FromSql<Text, DB> for WorkspaceId
Source§impl FromStr for WorkspaceId
impl FromStr for WorkspaceId
Source§type Err = InvalidWorkspaceId
type Err = InvalidWorkspaceId
The associated error which can be returned from parsing.
Source§fn from_str(value: &str) -> Result<WorkspaceId, <WorkspaceId as FromStr>::Err>
fn from_str(value: &str) -> Result<WorkspaceId, <WorkspaceId as FromStr>::Err>
Parses a string
s to return a value of this type. Read moreSource§impl Generatable for WorkspaceId
impl Generatable for WorkspaceId
fn random(rng: &mut SafeRand) -> Result<WorkspaceId, RandomError>
Source§impl PartialEq<&str> for WorkspaceId
impl PartialEq<&str> for WorkspaceId
Source§impl PartialEq<String> for WorkspaceId
impl PartialEq<String> for WorkspaceId
Source§impl PartialEq for WorkspaceId
impl PartialEq for WorkspaceId
Source§impl<__DB, __ST> Queryable<__ST, __DB> for WorkspaceId
impl<__DB, __ST> Queryable<__ST, __DB> for WorkspaceId
Source§type Row = WorkspaceId
type Row = WorkspaceId
The Rust type you’d like to map from. Read more
Source§fn build(row: WorkspaceId) -> Result<WorkspaceId, Box<dyn Error + Sync + Send>>
fn build(row: WorkspaceId) -> Result<WorkspaceId, Box<dyn Error + Sync + Send>>
Construct an instance of this type
Source§impl Serialize for WorkspaceId
impl Serialize for WorkspaceId
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl<DB> ToSql<Text, DB> for WorkspaceId
impl<DB> ToSql<Text, DB> for WorkspaceId
Source§impl TryFrom<&str> for WorkspaceId
impl TryFrom<&str> for WorkspaceId
Source§type Error = InvalidWorkspaceId
type Error = InvalidWorkspaceId
The type returned in the event of a conversion error.
Source§fn try_from(
value: &str,
) -> Result<WorkspaceId, <WorkspaceId as TryFrom<&str>>::Error>
fn try_from( value: &str, ) -> Result<WorkspaceId, <WorkspaceId as TryFrom<&str>>::Error>
Performs the conversion.
Source§impl TryFrom<String> for WorkspaceId
impl TryFrom<String> for WorkspaceId
Source§type Error = InvalidWorkspaceId
type Error = InvalidWorkspaceId
The type returned in the event of a conversion error.
Source§fn try_from(
value: String,
) -> Result<WorkspaceId, <WorkspaceId as TryFrom<String>>::Error>
fn try_from( value: String, ) -> Result<WorkspaceId, <WorkspaceId as TryFrom<String>>::Error>
Performs the conversion.
Source§impl TryInto<HeaderValue> for WorkspaceId
Workspace IDs can be converted into HTTP header values.
impl TryInto<HeaderValue> for WorkspaceId
Workspace IDs can be converted into HTTP header values.
Source§type Error = InvalidHeaderValue
type Error = InvalidHeaderValue
The type returned in the event of a conversion error.
Source§fn try_into(
self,
) -> Result<HeaderValue, <WorkspaceId as TryInto<HeaderValue>>::Error>
fn try_into( self, ) -> Result<HeaderValue, <WorkspaceId as TryInto<HeaderValue>>::Error>
Performs the conversion.
impl Copy for WorkspaceId
impl Eq for WorkspaceId
impl StructuralPartialEq for WorkspaceId
Auto Trait Implementations§
impl Freeze for WorkspaceId
impl RefUnwindSafe for WorkspaceId
impl Send for WorkspaceId
impl Sync for WorkspaceId
impl Unpin for WorkspaceId
impl UnwindSafe for WorkspaceId
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
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 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>
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 moreSource§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
Convert
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
Convert
&self to an expression for Diesel’s query builder. Read moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Set the foreground color generically Read more
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Set the background color generically. Read more
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Change the foreground color to black
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Change the background color to black
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Change the foreground color to red
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Change the background color to red
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Change the foreground color to green
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Change the background color to green
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Change the foreground color to yellow
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Change the background color to yellow
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Change the foreground color to blue
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Change the background color to blue
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Change the foreground color to magenta
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Change the background color to magenta
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Change the foreground color to purple
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Change the background color to purple
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Change the foreground color to cyan
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Change the background color to cyan
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Change the foreground color to white
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Change the background color to white
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Change the foreground color to the terminal default
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Change the background color to the terminal default
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Change the foreground color to bright black
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Change the background color to bright black
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Change the foreground color to bright red
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Change the background color to bright red
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Change the foreground color to bright green
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Change the background color to bright green
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Change the foreground color to bright yellow
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Change the background color to bright yellow
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Change the foreground color to bright blue
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Change the background color to bright blue
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Change the foreground color to bright magenta
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Change the background color to bright magenta
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Change the foreground color to bright purple
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Change the background color to bright purple
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Change the foreground color to bright cyan
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Change the background color to bright cyan
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Change the foreground color to bright white
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Change the background color to bright white
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Make the text bold
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Make the text dim
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Make the text italicized
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Make the text underlined
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Make the text blink
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Make the text blink (but fast!)
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Swap the foreground and background colors
Hide the text
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Cross out the text
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
Set the foreground color at runtime. Only use if you do not know which color will be used at
compile-time. If the color is constant, use either
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
Set the background color at runtime. Only use if you do not know what color to use at
compile-time. If the color is constant, use either
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read moreSource§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Set the foreground color to a specific RGB value.
Source§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Set the background color to a specific RGB value.
Source§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Sets the foreground color to an RGB value.
Source§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Sets the background color to an RGB value.