pub struct NetworkId {
pub network_type: NetworkType,
pub suffix: Option<u32>,
}Expand description
NetworkId is a unique identifier for a kaspa network instance. It is composed of a network type and an optional suffix.
@category Consensus
Fields§
§network_type: NetworkType§suffix: Option<u32>Implementations§
Source§impl NetworkId
impl NetworkId
pub const fn new(network_type: NetworkType) -> Self
pub fn try_new(network_type: NetworkType) -> Result<Self, NetworkIdError>
pub const fn with_suffix(network_type: NetworkType, suffix: u32) -> Self
pub fn network_type(&self) -> NetworkType
pub fn is_mainnet(&self) -> bool
pub fn suffix(&self) -> Option<u32>
pub fn default_p2p_port(&self) -> u16
pub fn iter() -> impl Iterator<Item = Self>
Sourcepub fn to_prefixed(&self) -> String
pub fn to_prefixed(&self) -> String
Returns a textual description of the network prefixed with kaspa-
pub fn from_prefixed(prefixed: &str) -> Result<Self, NetworkIdError>
Methods from Deref<Target = NetworkType>§
pub fn default_rpc_port(&self) -> u16
pub fn default_borsh_rpc_port(&self) -> u16
pub fn default_json_rpc_port(&self) -> u16
Trait Implementations§
Source§impl BorshDeserialize for NetworkId
impl BorshDeserialize for NetworkId
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Deserializes this instance from a given slice of bytes.
Updates the buffer to point at the remaining bytes.
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
Deserialize this instance from a slice of bytes.
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for NetworkId
impl BorshSerialize for NetworkId
Source§impl CastFromJs for NetworkId
impl CastFromJs for NetworkId
Source§fn try_ref_from_js_value<'a, R>(
js: &'a R,
) -> Result<<Self as RefFromWasmAbi>::Anchor, Error>
fn try_ref_from_js_value<'a, R>( js: &'a R, ) -> Result<<Self as RefFromWasmAbi>::Anchor, Error>
Obtain safe reference from
JsValueSource§fn try_long_ref_from_js_value<'a, R>(
js: &'a R,
) -> Result<<Self as RefFromWasmAbi>::Anchor, Error>
fn try_long_ref_from_js_value<'a, R>( js: &'a R, ) -> Result<<Self as RefFromWasmAbi>::Anchor, Error>
Obtain safe long reference from
JsValuefn try_ref_from_js_value_as_cast<'a, R>( js_value: &'a R, ) -> Result<Cast<'a, Self>, Error>
fn try_long_ref_from_js_value_as_cast<'a, R>( js: &'a R, ) -> Result<Cast<'a, Self>, Error>
Source§impl<'de> Deserialize<'de> for NetworkId
impl<'de> Deserialize<'de> for NetworkId
Source§fn deserialize<D>(deserializer: D) -> Result<NetworkId, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<NetworkId, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<NetworkId> for NetworkType
impl From<NetworkId> for NetworkType
Source§impl FromWasmAbi for NetworkId
impl FromWasmAbi for NetworkId
Source§impl IntoWasmAbi for NetworkId
impl IntoWasmAbi for NetworkId
Source§impl LongRefFromWasmAbi for NetworkId
impl LongRefFromWasmAbi for NetworkId
Source§impl OptionFromWasmAbi for NetworkId
impl OptionFromWasmAbi for NetworkId
Source§impl OptionIntoWasmAbi for NetworkId
impl OptionIntoWasmAbi for NetworkId
Source§impl Ord for NetworkId
impl Ord for NetworkId
Source§impl PartialOrd for NetworkId
impl PartialOrd for NetworkId
Source§impl RefFromWasmAbi for NetworkId
impl RefFromWasmAbi for NetworkId
Source§impl RefMutFromWasmAbi for NetworkId
impl RefMutFromWasmAbi for NetworkId
Source§impl TryCastFromJs for NetworkId
impl TryCastFromJs for NetworkId
type Error = NetworkIdError
Source§fn try_cast_from<'a, R>(value: &'a R) -> Result<Cast<'_, Self>, Self::Error>
fn try_cast_from<'a, R>(value: &'a R) -> Result<Cast<'_, Self>, Self::Error>
Try to cast a JsValue into a Rust object.
This should be user-defined function that
attempts to cast a JsValue into a Rust object
or interpret a source data and create a
temporary struct owned by by the
Cast.Source§fn try_owned_from(value: impl AsRef<JsValue>) -> Result<Self, Self::Error>
fn try_owned_from(value: impl AsRef<JsValue>) -> Result<Self, Self::Error>
Perform a user cast and consume the
Cast container.
This function will return a temporary user-created
object created during [try_cast_from] or a clone of the casted reference.fn try_captured_cast_from( js_value: impl AsRef<JsValue>, ) -> Result<Cast<'static, Self>, Self::Error>
Source§fn resolve<'a, R>(
js: &'a R,
create: impl FnOnce() -> Result<Self, Self::Error>,
) -> Result<Cast<'a, Self>, Self::Error>
fn resolve<'a, R>( js: &'a R, create: impl FnOnce() -> Result<Self, Self::Error>, ) -> Result<Cast<'a, Self>, Self::Error>
Try to cast a JsValue into a Rust object, in cast of failure
invoke a user-supplied closure that can try to create an instance
of the object based on the supplied JsValue.
Source§fn resolve_cast<'a, R>(
js: &'a R,
create: impl FnOnce() -> Result<Cast<'a, Self>, Self::Error>,
) -> Result<Cast<'a, Self>, Self::Error>
fn resolve_cast<'a, R>( js: &'a R, create: impl FnOnce() -> Result<Cast<'a, Self>, Self::Error>, ) -> Result<Cast<'a, Self>, Self::Error>
Try to cast a JsValue into a Rust object, in cast of failure
invoke a user-supplied closure that can try to create an instance
of the object based on the supplied JsValue. Unlike the [
resolve]
function, this function expects create closure to return a Cast.
This is useful when routing the creation of the object to another
function that is capable of creating a compatible Cast wrapper.Source§impl TryFrom<NetworkType> for NetworkId
impl TryFrom<NetworkType> for NetworkId
Source§type Error = NetworkIdError
type Error = NetworkIdError
The type returned in the event of a conversion error.
Source§impl TryFromJsValue for NetworkId
impl TryFromJsValue for NetworkId
Source§impl VectorFromWasmAbi for NetworkId
impl VectorFromWasmAbi for NetworkId
Source§impl VectorIntoWasmAbi for NetworkId
impl VectorIntoWasmAbi for NetworkId
impl Copy for NetworkId
impl Eq for NetworkId
impl StructuralPartialEq for NetworkId
impl SupportsConstructor for NetworkId
impl SupportsInstanceProperty for NetworkId
impl SupportsStaticProperty for NetworkId
Auto Trait Implementations§
impl Freeze for NetworkId
impl RefUnwindSafe for NetworkId
impl Send for NetworkId
impl Sync for NetworkId
impl Unpin for NetworkId
impl UnwindSafe for NetworkId
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.