#[non_exhaustive]pub struct Protocol {
pub name: &'static str,
pub method: Option<&'static str>,
pub hash: Hash,
/* private fields */
}Expand description
A pre-defined protocol function.
§Examples
use rune::runtime::Protocol;
let protocol = Protocol::GET;
assert_eq!(protocol.name, "GET");Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: &'static strThe name of the builtin function.
method: Option<&'static str>If this protocol defines an associated method, this is the name of that method.
hash: HashThe hash of the builtin function.
Implementations§
Source§impl Protocol
impl Protocol
Sourcepub const GET: Protocol
pub const GET: Protocol
The function to access a field.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::GET.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::GET));Sourcepub const SET: Protocol
pub const SET: Protocol
The function to set a field.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::SET.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::SET));Sourcepub const INDEX_GET: Protocol
pub const INDEX_GET: Protocol
The function to access an index.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::INDEX_GET.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::INDEX_GET));Sourcepub const INDEX_SET: Protocol
pub const INDEX_SET: Protocol
The function to set an index.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::INDEX_SET.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::INDEX_SET));Sourcepub const PARTIAL_EQ: Protocol
pub const PARTIAL_EQ: Protocol
Check two types for partial equality.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::PARTIAL_EQ.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::PARTIAL_EQ));Sourcepub const EQ: Protocol
pub const EQ: Protocol
Check two types for total equality.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::EQ.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::EQ));Sourcepub const PARTIAL_CMP: Protocol
pub const PARTIAL_CMP: Protocol
Perform an partial comparison between two values.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::PARTIAL_CMP.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::PARTIAL_CMP));Sourcepub const GT: Protocol
pub const GT: Protocol
The protocol behind the > operator.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::GT.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::GT));Sourcepub const GE: Protocol
pub const GE: Protocol
The protocol behind the >= operator.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::GE.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::GE));Sourcepub const LT: Protocol
pub const LT: Protocol
The protocol behind the > operator.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::LT.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::LT));Sourcepub const LE: Protocol
pub const LE: Protocol
The protocol behind the <= operator.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::LE.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::LE));Sourcepub const MAX: Protocol
pub const MAX: Protocol
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::MAX.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::MAX));Sourcepub const MIN: Protocol
pub const MIN: Protocol
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::MIN.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::MIN));Sourcepub const CMP: Protocol
pub const CMP: Protocol
Perform an total comparison between two values.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::CMP.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::CMP));Sourcepub const NEG: Protocol
pub const NEG: Protocol
The protocol for the unary negation operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::NEG.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::NEG));Sourcepub const NOT: Protocol
pub const NOT: Protocol
The protocol for the unary not operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::NOT.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::NOT));Sourcepub const ADD: Protocol
pub const ADD: Protocol
The protocol for the addition operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::ADD.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::ADD));Sourcepub const ADD_ASSIGN: Protocol
pub const ADD_ASSIGN: Protocol
The protocol for the addition assign operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::ADD_ASSIGN.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::ADD_ASSIGN));Sourcepub const SUB: Protocol
pub const SUB: Protocol
The protocol for the subtraction operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::SUB.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::SUB));Sourcepub const SUB_ASSIGN: Protocol
pub const SUB_ASSIGN: Protocol
The protocol for the subtraction assign operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::SUB_ASSIGN.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::SUB_ASSIGN));Sourcepub const MUL: Protocol
pub const MUL: Protocol
The protocol for the multiply operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::MUL.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::MUL));Sourcepub const MUL_ASSIGN: Protocol
pub const MUL_ASSIGN: Protocol
The protocol for the multiply assign operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::MUL_ASSIGN.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::MUL_ASSIGN));Sourcepub const DIV: Protocol
pub const DIV: Protocol
The protocol for the division operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::DIV.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::DIV));Sourcepub const DIV_ASSIGN: Protocol
pub const DIV_ASSIGN: Protocol
The protocol for the division assign operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::DIV_ASSIGN.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::DIV_ASSIGN));Sourcepub const REM: Protocol
pub const REM: Protocol
The protocol for the remainder operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::REM.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::REM));Sourcepub const REM_ASSIGN: Protocol
pub const REM_ASSIGN: Protocol
The protocol for the remainder assign operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::REM_ASSIGN.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::REM_ASSIGN));Sourcepub const BIT_AND: Protocol
pub const BIT_AND: Protocol
The protocol for the bitwise and operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::BIT_AND.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::BIT_AND));Sourcepub const BIT_AND_ASSIGN: Protocol
pub const BIT_AND_ASSIGN: Protocol
The protocol for the bitwise and assign operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::BIT_AND_ASSIGN.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::BIT_AND_ASSIGN));Sourcepub const BIT_XOR: Protocol
pub const BIT_XOR: Protocol
The protocol for the bitwise xor operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::BIT_XOR.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::BIT_XOR));Sourcepub const BIT_XOR_ASSIGN: Protocol
pub const BIT_XOR_ASSIGN: Protocol
The protocol for the bitwise xor assign operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::BIT_XOR_ASSIGN.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::BIT_XOR_ASSIGN));Sourcepub const BIT_OR: Protocol
pub const BIT_OR: Protocol
The protocol for the bitwise or operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::BIT_OR.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::BIT_OR));Sourcepub const BIT_OR_ASSIGN: Protocol
pub const BIT_OR_ASSIGN: Protocol
The protocol for the bitwise xor assign operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::BIT_OR_ASSIGN.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::BIT_OR_ASSIGN));Sourcepub const SHL: Protocol
pub const SHL: Protocol
The protocol for the bitwise shift left operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::SHL.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::SHL));Sourcepub const SHL_ASSIGN: Protocol
pub const SHL_ASSIGN: Protocol
The protocol for the bitwise shift left assign operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::SHL_ASSIGN.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::SHL_ASSIGN));Sourcepub const SHR: Protocol
pub const SHR: Protocol
The protocol for the bitwise shift right operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::SHR.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::SHR));Sourcepub const SHR_ASSIGN: Protocol
pub const SHR_ASSIGN: Protocol
The protocol for the bitwise shift right assign operation.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::SHR_ASSIGN.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::SHR_ASSIGN));Sourcepub const DISPLAY_FMT: Protocol
pub const DISPLAY_FMT: Protocol
Protocol function used by template strings.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::DISPLAY_FMT.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::DISPLAY_FMT));Sourcepub const DEBUG_FMT: Protocol
pub const DEBUG_FMT: Protocol
Protocol function used by custom debug impls.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::DEBUG_FMT.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::DEBUG_FMT));Sourcepub const INTO_ITER: Protocol
pub const INTO_ITER: Protocol
Function used to convert an argument into an iterator.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::INTO_ITER.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::INTO_ITER));Sourcepub const NEXT: Protocol
pub const NEXT: Protocol
The function to call to continue iteration.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::NEXT.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::NEXT));Sourcepub const NTH: Protocol
pub const NTH: Protocol
The function to call to continue iteration at the nth element.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::NTH.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::NTH));Sourcepub const NTH_BACK: Protocol
pub const NTH_BACK: Protocol
The function to call to continue iteration at the nth element form the back.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::NTH_BACK.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::NTH_BACK));Sourcepub const SIZE_HINT: Protocol
pub const SIZE_HINT: Protocol
Protocol used when getting the size hint of an iterator.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::SIZE_HINT.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::SIZE_HINT));Sourcepub const LEN: Protocol
pub const LEN: Protocol
Protocol used when getting the exact length of an iterator.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::LEN.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::LEN));Sourcepub const NEXT_BACK: Protocol
pub const NEXT_BACK: Protocol
Protocol used when cloning a value.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::NEXT_BACK.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::NEXT_BACK));Sourcepub const INTO_FUTURE: Protocol
pub const INTO_FUTURE: Protocol
Function used to convert an argument into a future.
Signature: fn(Value) -> Future.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::INTO_FUTURE.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::INTO_FUTURE));Sourcepub const INTO_TYPE_NAME: Protocol
pub const INTO_TYPE_NAME: Protocol
Coerce a value into a type name. This is stored as a constant.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::INTO_TYPE_NAME.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::INTO_TYPE_NAME));Sourcepub const IS_VARIANT: Protocol
pub const IS_VARIANT: Protocol
Function used to test if a value is a specific variant.
Signature: fn(self, Hash) -> bool.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::IS_VARIANT.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::IS_VARIANT));Sourcepub const TRY: Protocol
pub const TRY: Protocol
Function used for the question mark operation.
Signature: fn(self) -> Result.
Note that it uses the Result like Try uses ControlFlow i.e.,
for Result::<T, E> it should return Result<T, Result<(), E>>
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::TRY.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::TRY));Sourcepub const HASH: Protocol
pub const HASH: Protocol
Protocol used when calculating a hash.
§Examples
use rune::hash::IntoHash;
use rune::runtime::Protocol;
let hash = Protocol::HASH.into_hash();
let protocol = Protocol::from_hash(hash);
assert_eq!(protocol, Some(Protocol::HASH));