pub struct ServerIds(/* private fields */);Expand description
A non-empty, duplicate-free, bounded list of server ids: at most
MAX_RESTART_SERVER_IDS ids of MAX_SERVER_ID_BYTES bytes each.
§Examples
use mcpls_core::bridge::{ServerIds, ServerIdsError};
use mcpls_core::config::ServerId;
let ids = ServerIds::try_new(vec![ServerId::from_static("rust"), ServerId::from_static("rust")]).unwrap();
assert_eq!(ids.as_slice().len(), 1);
assert_eq!(ServerIds::try_new(Vec::new()), Err(ServerIdsError::Empty));Implementations§
Source§impl ServerIds
impl ServerIds
Sourcepub fn try_new(ids: Vec<ServerId>) -> Result<Self, ServerIdsError>
pub fn try_new(ids: Vec<ServerId>) -> Result<Self, ServerIdsError>
Build the list, dropping repeated ids.
§Errors
ServerIdsError when ids is empty, has more than
MAX_RESTART_SERVER_IDS entries, or holds an oversized id.
Sourcepub fn parse(ids: Vec<String>) -> Result<Self, ServerIdsError>
pub fn parse(ids: Vec<String>) -> Result<Self, ServerIdsError>
Parse the ids of a request, checking the count, blankness and length
in that order, then drop repeats like Self::try_new.
§Errors
ServerIdsError when ids is empty, has more than
MAX_RESTART_SERVER_IDS entries, or holds a blank or oversized id.
§Examples
use mcpls_core::bridge::{ServerIds, ServerIdsError};
assert_eq!(ServerIds::parse(vec![" ".to_owned()]), Err(ServerIdsError::Blank));
assert_eq!(ServerIds::parse(vec!["rust".to_owned()]).unwrap().as_slice().len(), 1);Trait Implementations§
impl Eq for ServerIds
impl StructuralPartialEq for ServerIds
Auto Trait Implementations§
impl Freeze for ServerIds
impl RefUnwindSafe for ServerIds
impl Send for ServerIds
impl Sync for ServerIds
impl Unpin for ServerIds
impl UnsafeUnpin for ServerIds
impl UnwindSafe for ServerIds
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.