Create euphoxide-client crate
This commit is contained in:
parent
7aba0eb50e
commit
4d09c0c4df
8 changed files with 780 additions and 2 deletions
40
euphoxide-client/src/builder.rs
Normal file
40
euphoxide-client/src/builder.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
use crate::ClientConfig;
|
||||
|
||||
pub trait ClientBuilderBase<'a> {
|
||||
type Base;
|
||||
}
|
||||
|
||||
pub struct ClientBuilder<'a, B: ClientBuilderBase<'a>> {
|
||||
pub(crate) base: B::Base,
|
||||
pub(crate) config: ClientConfig,
|
||||
}
|
||||
|
||||
impl<'a, B: ClientBuilderBase<'a>> ClientBuilder<'a, B> {
|
||||
pub fn config(&self) -> &ClientConfig {
|
||||
&self.config
|
||||
}
|
||||
|
||||
pub fn config_mut(&mut self) -> &mut ClientConfig {
|
||||
&mut self.config
|
||||
}
|
||||
|
||||
pub fn with_human(mut self, human: bool) -> Self {
|
||||
self.config.human = human;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_username(mut self, username: impl ToString) -> Self {
|
||||
self.config.username = Some(username.to_string());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_force_username(mut self, force_username: bool) -> Self {
|
||||
self.config.force_username = force_username;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_password(mut self, password: impl ToString) -> Self {
|
||||
self.config.password = Some(password.to_string());
|
||||
self
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue