pub struct ProtocolHelpers;Expand description
Shared stateless helpers used across all protocol adapters.
Implementations§
Source§impl ProtocolHelpers
impl ProtocolHelpers
Sourcepub fn lookup_event_type(
name: &str,
mapping: &[(&'static str, EventType)],
) -> Option<EventType>
pub fn lookup_event_type( name: &str, mapping: &[(&'static str, EventType)], ) -> Option<EventType>
Looks up an EventType by name from a static mapping table.
Sourcepub fn parse_accounts(accounts_json: &Value) -> Result<Vec<AccountInfo>, Error>
pub fn parse_accounts(accounts_json: &Value) -> Result<Vec<AccountInfo>, Error>
Deserializes a JSON array of accounts into AccountInfo structs.
Sourcepub fn find_signer(accounts: &[AccountInfo]) -> Option<&str>
pub fn find_signer(accounts: &[AccountInfo]) -> Option<&str>
Returns the pubkey of the first signer in the account list.
Sourcepub fn find_account_by_name<'a>(
accounts: &'a [AccountInfo],
name: &str,
) -> Option<&'a AccountInfo>
pub fn find_account_by_name<'a>( accounts: &'a [AccountInfo], name: &str, ) -> Option<&'a AccountInfo>
Finds an account by its IDL-derived name.
Sourcepub fn contains_known_variant(fields: &Value, known_names: &[&str]) -> bool
pub fn contains_known_variant(fields: &Value, known_names: &[&str]) -> bool
Returns true if the JSON object’s keys contain any of the known_names.
Sourcepub fn checked_u64_to_i64(value: u64, field: &str) -> Result<i64, Error>
pub fn checked_u64_to_i64(value: u64, field: &str) -> Result<i64, Error>
Converts u64 to i64, returning an error if the value exceeds i64::MAX.
Sourcepub fn optional_u64_to_i64(value: u64) -> Option<i64>
pub fn optional_u64_to_i64(value: u64) -> Option<i64>
Converts u64 to i64 for optional fields.
Returns None if the value exceeds i64::MAX (e.g. u64::MAX sentinel for “no limit”).
Auto Trait Implementations§
impl Freeze for ProtocolHelpers
impl RefUnwindSafe for ProtocolHelpers
impl Send for ProtocolHelpers
impl Sync for ProtocolHelpers
impl Unpin for ProtocolHelpers
impl UnsafeUnpin for ProtocolHelpers
impl UnwindSafe for ProtocolHelpers
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> 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 more