Struct ruserf_types::NodeId

source ·
pub struct NodeId(/* private fields */);
Expand description

A unique string identifying a server for all time. The maximum length of an id is 512 bytes.

Implementations§

source§

impl NodeId

source

pub const MAX_SIZE: usize = 512usize

The maximum length of an id is 512 bytes.

source

pub fn new<T>(src: T) -> Result<NodeId, NodeIdTransformError>
where T: AsRef<str>,

Creates a new Id from the source.

source

pub fn as_str(&self) -> &str

converts the Id into a &str.

source

pub fn as_bytes(&self) -> &[u8]

Returns a byte slice. To convert the byte slice back into a string slice, use the core::str::from_utf8 function.

Trait Implementations§

source§

impl AsRef<str> for NodeId

source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<str> for NodeId

source§

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
source§

impl CheapClone for NodeId

source§

fn cheap_clone(&self) -> Self

Returns a copy of the value.
source§

impl Clone for NodeId

source§

fn clone(&self) -> NodeId

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for NodeId

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for NodeId

source§

fn deserialize<__D>( __deserializer: __D ) -> Result<NodeId, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for NodeId

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl FromStr for NodeId

§

type Err = NodeIdTransformError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<NodeId, <NodeId as FromStr>::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for NodeId

source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for NodeId

source§

fn cmp(&self, other: &NodeId) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for NodeId

source§

fn eq(&self, other: &NodeId) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for NodeId

source§

fn partial_cmp(&self, other: &NodeId) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for NodeId

source§

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 Transformable for NodeId

source§

fn encode_to_writer<W>(&self, writer: &mut W) -> Result<usize, Error>
where W: Write,

Encodes the value into the given writer.

§Note

The implementation of this method is not optimized, which means if your writer is expensive (e.g. TcpStream, File), it is better to use a BufWriter to wrap your orginal writer to cut down the number of I/O times.

source§

async fn encode_to_async_writer<W>( &self, writer: &mut W ) -> Result<usize, Error>
where W: AsyncWrite + Send + Unpin, <NodeId as Transformable>::Error: Send + Sync + 'static,

Encodes the value into the given async writer.

§Note

The implementation of this method is not optimized, which means if your writer is expensive (e.g. TcpStream, File), it is better to use a BufWriter to wrap your orginal writer to cut down the number of I/O times.

source§

fn decode_from_reader<R>(reader: &mut R) -> Result<(usize, NodeId), Error>
where R: Read, NodeId: Sized,

Decodes the value from the given reader.

§Note

The implementation of this method is not optimized, which means if your reader is expensive (e.g. TcpStream, File), it is better to use a BufReader to wrap your orginal reader to cut down the number of I/O times.

source§

async fn decode_from_async_reader<R>( reader: &mut R ) -> Result<(usize, NodeId), Error>
where R: AsyncRead + Send + Unpin, NodeId: Sized, <NodeId as Transformable>::Error: Send + Sync + 'static,

Decodes the value from the given async reader.

§Note

The implementation of this method is not optimized, which means if your reader is expensive (e.g. TcpStream, File), it is better to use a BufReader to wrap your orginal reader to cut down the number of I/O times.

§

type Error = NodeIdTransformError

The error type returned when encoding or decoding fails.
source§

fn encode( &self, dst: &mut [u8] ) -> Result<usize, <NodeId as Transformable>::Error>

Encodes the value into the given buffer for transmission. Read more
source§

fn encoded_len(&self) -> usize

Returns the encoded length of the value. This is used to pre-allocate a buffer for encoding.
source§

fn decode( src: &[u8] ) -> Result<(usize, NodeId), <NodeId as Transformable>::Error>
where NodeId: Sized,

Decodes the value from the given buffer received over the wire. Read more
source§

fn encode_to_vec(&self) -> Result<Vec<u8>, Self::Error>

Encodes the value into a vec for transmission.
source§

impl TryFrom<&[u8]> for NodeId

§

type Error = NodeIdTransformError

The type returned in the event of a conversion error.
source§

fn try_from(value: &[u8]) -> Result<NodeId, <NodeId as TryFrom<&[u8]>>::Error>

Performs the conversion.
source§

impl TryFrom<String> for NodeId

§

type Error = NodeIdTransformError

The type returned in the event of a conversion error.
source§

fn try_from(s: String) -> Result<NodeId, <NodeId as TryFrom<String>>::Error>

Performs the conversion.
source§

impl TryFrom<Vec<u8>> for NodeId

§

type Error = NodeIdTransformError

The type returned in the event of a conversion error.
source§

fn try_from( value: Vec<u8> ) -> Result<NodeId, <NodeId as TryFrom<Vec<u8>>>::Error>

Performs the conversion.
source§

impl Eq for NodeId

source§

impl Id for NodeId

source§

impl StructuralPartialEq for NodeId

Auto Trait Implementations§

§

impl Freeze for NodeId

§

impl RefUnwindSafe for NodeId

§

impl Send for NodeId

§

impl Sync for NodeId

§

impl Unpin for NodeId

§

impl UnwindSafe for NodeId

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
source§

impl<T> Decodable for T
where T: Transformable,

§

type Error = <T as Transformable>::Error

The error type returned when encoding or decoding fails.
source§

fn decode(src: &[u8]) -> Result<(usize, T), <T as Decodable>::Error>

Decodes the value from the given buffer received over the wire. Read more
source§

fn decode_from_reader<R>(reader: &mut R) -> Result<(usize, T), Error>
where R: Read,

Decodes the value from the given reader received over the wire. Read more
source§

fn decode_from_async_reader<R>( reader: &mut R ) -> impl Future<Output = Result<(usize, T), Error>> + Send
where R: AsyncRead + Send + Unpin,

Decodes the value from the given async reader received over the wire. Read more
source§

impl<T> Encodable for T
where T: Transformable,

§

type Error = <T as Transformable>::Error

The error type returned when encoding or decoding fails.
source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, <T as Encodable>::Error>

Encodes the value into the given buffer for transmission. Read more
source§

fn encoded_len(&self) -> usize

Returns the encoded length of the value. This is used to pre-allocate a buffer for encoding.
source§

fn encode_to_vec(&self) -> Result<Vec<u8>, <T as Encodable>::Error>

Encodes the value into a vec for transmission.
source§

fn encode_to_writer<W>(&self, writer: &mut W) -> Result<usize, Error>
where W: Write,

Encodes the value into the given writer for transmission.
source§

fn encode_to_async_writer<W>( &self, writer: &mut W ) -> impl Future<Output = Result<usize, Error>> + Send
where W: AsyncWrite + Send + Unpin, T: Sync,

Encodes the value into the given async writer for transmission.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,