pub struct Servers(/* private fields */);Expand description
Wrapper for the servers: field that enforces the invariant
of “exactly one datastore” without losing the YAML list shape.
§Examples
use dynomite::conf::{ConfServer, Servers};
let s = Servers::from_vec(vec![ConfServer::parse("127.0.0.1:6379:1").unwrap()]);
assert_eq!(s.len(), 1);
assert!(!s.is_empty());
assert!(s.datastore().is_some());Implementations§
Source§impl Servers
impl Servers
Sourcepub fn from_vec(v: Vec<ConfServer>) -> Self
pub fn from_vec(v: Vec<ConfServer>) -> Self
Construct from an explicit list. Validation enforces a length
of one when called via Config::validate.
§Examples
use dynomite::conf::{ConfServer, Servers};
let s = Servers::from_vec(vec![ConfServer::parse("127.0.0.1:6379:1").unwrap()]);
assert_eq!(s.len(), 1);Source§impl Servers
impl Servers
Sourcepub fn entries(&self) -> &[ConfServer]
pub fn entries(&self) -> &[ConfServer]
Borrow the entries.
§Examples
use dynomite::conf::{ConfServer, Servers};
let s = Servers::from_vec(vec![ConfServer::parse("127.0.0.1:6379:1").unwrap()]);
assert_eq!(s.entries().len(), 1);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the list is empty.
§Examples
use dynomite::conf::Servers;
assert!(Servers::default().is_empty());Sourcepub fn datastore(&self) -> Option<&ConfServer>
pub fn datastore(&self) -> Option<&ConfServer>
The single datastore (returns the first entry, if any).
§Examples
use dynomite::conf::{ConfServer, Servers};
let s = Servers::from_vec(vec![ConfServer::parse("127.0.0.1:6379:1").unwrap()]);
assert!(s.datastore().is_some());
assert!(Servers::default().datastore().is_none());Trait Implementations§
Source§impl<'de> Deserialize<'de> for Servers
impl<'de> Deserialize<'de> for Servers
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
impl Eq for Servers
impl StructuralPartialEq for Servers
Auto Trait Implementations§
impl Freeze for Servers
impl RefUnwindSafe for Servers
impl Send for Servers
impl Sync for Servers
impl Unpin for Servers
impl UnsafeUnpin for Servers
impl UnwindSafe for Servers
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§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.