Struct jet_margin::AccountPositionList
source · [−]#[repr(C)]pub struct AccountPositionList {
pub length: usize,
pub map: [AccountPositionKey; 32],
pub positions: [AccountPosition; 32],
}
Fields
length: usize
map: [AccountPositionKey; 32]
positions: [AccountPosition; 32]
Implementations
sourceimpl AccountPositionList
impl AccountPositionList
sourcepub fn add(
&mut self,
mint: Pubkey
) -> AnchorResult<(AccountPositionKey, &mut AccountPosition)>
pub fn add(
&mut self,
mint: Pubkey
) -> AnchorResult<(AccountPositionKey, &mut AccountPosition)>
Add a position to the position list.
Finds an empty slot in map
and positions
, and adds an empty position
to the slot.
sourcepub fn remove(
&mut self,
mint: &Pubkey,
account: &Pubkey
) -> AnchorResult<AccountPosition>
pub fn remove(
&mut self,
mint: &Pubkey,
account: &Pubkey
) -> AnchorResult<AccountPosition>
Remove a position from the margin account.
Error
- If an account with the
mint
does not exist. - If the position’s address is not the same as the
account
pub fn get(&self, mint: &Pubkey) -> Option<&AccountPosition>
pub fn get_mut(&mut self, mint: &Pubkey) -> Option<&mut AccountPosition>
pub fn get_key(&self, mint: &Pubkey) -> Option<&AccountPositionKey>
Trait Implementations
sourceimpl BorshDeserialize for AccountPositionListwhere
usize: BorshDeserialize,
[AccountPositionKey; 32]: BorshDeserialize,
[AccountPosition; 32]: BorshDeserialize,
impl BorshDeserialize for AccountPositionListwhere
usize: BorshDeserialize,
[AccountPositionKey; 32]: BorshDeserialize,
[AccountPosition; 32]: BorshDeserialize,
sourcefn 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. Read more
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.
sourceimpl BorshSerialize for AccountPositionListwhere
usize: BorshSerialize,
[AccountPositionKey; 32]: BorshSerialize,
[AccountPosition; 32]: BorshSerialize,
impl BorshSerialize for AccountPositionListwhere
usize: BorshSerialize,
[AccountPositionKey; 32]: BorshSerialize,
[AccountPosition; 32]: BorshSerialize,
sourceimpl Clone for AccountPositionList
impl Clone for AccountPositionList
sourcefn clone(&self) -> AccountPositionList
fn clone(&self) -> AccountPositionList
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for AccountPositionList
impl Debug for AccountPositionList
sourceimpl Default for AccountPositionList
impl Default for AccountPositionList
sourcefn default() -> AccountPositionList
fn default() -> AccountPositionList
Returns the “default value” for a type. Read more
sourceimpl Zeroable for AccountPositionList
impl Zeroable for AccountPositionList
impl Copy for AccountPositionList
impl Pod for AccountPositionList
Auto Trait Implementations
impl RefUnwindSafe for AccountPositionList
impl Send for AccountPositionList
impl Sync for AccountPositionList
impl Unpin for AccountPositionList
impl UnwindSafe for AccountPositionList
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
. Read more