pub struct MysqlConfig { /* private fields */ }Expand description
MySQL database configuration
Implementations§
Source§impl MysqlConfig
impl MysqlConfig
Sourcepub fn new(
host: impl Into<String>,
port: u16,
database_name: impl Into<String>,
username: impl Into<String>,
password: Password,
root_password: Password,
) -> Result<Self, MysqlConfigError>
pub fn new( host: impl Into<String>, port: u16, database_name: impl Into<String>, username: impl Into<String>, password: Password, root_password: Password, ) -> Result<Self, MysqlConfigError>
Creates a new MySQL configuration with validation
§Errors
EmptyDatabaseNameif database name is emptyEmptyHostif host is emptyInvalidPortif port is 0EmptyUsernameif username is emptyReservedUsernameif username is"root"
§Examples
use torrust_tracker_deployer_lib::domain::tracker::MysqlConfig;
use torrust_tracker_deployer_lib::shared::Password;
let config = MysqlConfig::new(
"localhost",
3306,
"tracker",
"tracker_user",
Password::from("secure_password"),
Password::from("root_password"),
).unwrap();
assert_eq!(config.host(), "localhost");
assert_eq!(config.port(), 3306);
assert_eq!(config.database_name(), "tracker");Sourcepub fn database_name(&self) -> &str
pub fn database_name(&self) -> &str
Returns the database name
Sourcepub fn root_password(&self) -> &Password
pub fn root_password(&self) -> &Password
Returns a reference to the MySQL root password.
Used as MYSQL_ROOT_PASSWORD in the rendered .env file.
Trait Implementations§
Source§impl Clone for MysqlConfig
impl Clone for MysqlConfig
Source§impl Debug for MysqlConfig
impl Debug for MysqlConfig
Source§impl<'de> Deserialize<'de> for MysqlConfig
impl<'de> Deserialize<'de> for MysqlConfig
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for MysqlConfig
impl PartialEq for MysqlConfig
Source§impl Serialize for MysqlConfig
impl Serialize for MysqlConfig
impl StructuralPartialEq for MysqlConfig
Auto Trait Implementations§
impl Freeze for MysqlConfig
impl RefUnwindSafe for MysqlConfig
impl Send for MysqlConfig
impl Sync for MysqlConfig
impl Unpin for MysqlConfig
impl UnsafeUnpin for MysqlConfig
impl UnwindSafe for MysqlConfig
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request