Skip to main content

ProtocolHelpers

Struct ProtocolHelpers 

Source
pub struct ProtocolHelpers;
Expand description

Shared stateless helpers used across all protocol adapters.

Implementations§

Source§

impl ProtocolHelpers

Source

pub fn lookup_event_type( name: &str, mapping: &[(&'static str, EventType)], ) -> Option<EventType>

Looks up an EventType by name from a static mapping table.

Source

pub fn parse_accounts(accounts_json: &Value) -> Result<Vec<AccountInfo>, Error>

Deserializes a JSON array of accounts into AccountInfo structs.

Source

pub fn find_signer(accounts: &[AccountInfo]) -> Option<&str>

Returns the pubkey of the first signer in the account list.

Source

pub fn find_account_by_name<'a>( accounts: &'a [AccountInfo], name: &str, ) -> Option<&'a AccountInfo>

Finds an account by its IDL-derived name.

Source

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.

Source

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.

Source

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”).

Source

pub fn checked_u16_to_i16(value: u16, field: &str) -> Result<i16, Error>

Converts u16 to i16, returning an error if the value exceeds i16::MAX.

Auto Trait Implementations§

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<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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V