Skip to main content

Cell

Struct Cell 

Source
pub struct Cell<T: CellItem> { /* private fields */ }
Available on non-crate feature lock only.
Expand description

A CSPICE cell holding elements of type T.

The backing storage is owned, and released when the cell is dropped.

Implementations§

Source§

impl<T: CellItem> Cell<T>

Source

pub fn new(size: usize) -> Self

Allocate a cell able to hold size elements.

Character cells get slots of CELL_MAX_LEN bytes; use Cell::with_length to choose.

Source

pub fn with_length(size: usize, length: usize) -> Self

Allocate a cell able to hold size elements whose slots are length items long.

length is only meaningful for character cells, where it is the maximum length of an element.

Source

pub fn len(&self) -> usize

Number of elements currently held, the cardinality in SPICE terms.

Source

pub fn is_empty(&self) -> bool

Whether the cell holds no element.

Source

pub fn capacity(&self) -> usize

Number of elements the cell can hold.

Source

pub fn get(&self, index: usize) -> Option<T>

The element at index, or None past the cardinality.

Source

pub fn iter(&self) -> impl Iterator<Item = T> + '_

Iterate over the elements currently held.

Source

pub fn to_vec(&self) -> Vec<T>

Collect the elements currently held.

Source

pub fn push(&mut self, item: T)

Append an element, provided the cell is not full.

Source

pub fn clear(&mut self)

Drop every element, keeping the allocation.

Source

pub fn as_ptr(&self) -> *const SpiceCell

The cell descriptor, for calls to the unsafe C API.

Source

pub fn as_mut_ptr(&mut self) -> *mut SpiceCell

The cell descriptor, for calls to the unsafe C API.

The base and data pointers are refreshed from the backing buffer on every call, so the descriptor handed out is always the one CSPICE should write through.

Source§

impl Cell<i32>

Source

pub fn new_int(size: i32) -> Self

Allocate an integer cell able to hold size elements.

Source

pub fn new_bool(size: i32) -> Self

Allocate a boolean cell able to hold size elements.

Source

pub fn get_data_int(&self, index: usize) -> i32

The element at index, or 0 past the cardinality.

Source

pub fn get_data_bool(&self, index: usize) -> i32

The element at index as a boolean flag, or 0 past the cardinality.

Source§

impl Cell<f64>

Source

pub fn new_double(size: i32) -> Self

Allocate a double precision cell able to hold size elements.

Source

pub fn new_time(size: i32) -> Self

Allocate a time cell able to hold size elements.

Source

pub fn get_data_double(&self, index: usize) -> f64

The element at index, or 0.0 past the cardinality.

Source§

impl Cell<String>

Source

pub fn new_character(size: i32, length: i32) -> Self

Allocate a character cell able to hold size elements of at most length bytes.

Source

pub fn get_data_character(&self, index: usize) -> String

The element at index, or the empty string past the cardinality.

Trait Implementations§

Source§

impl<T: CellItem> Clone for Cell<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: CellItem + Debug> Debug for Cell<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: CellItem> Deref for Cell<T>

Read only access to the raw descriptor, for the card and size fields CSPICE maintains.

Source§

type Target = _SpiceCell

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T: CellItem + Send> Send for Cell<T>

Source§

impl<'a, T: CellItem> SpiceArg for &'a mut Cell<T>

A pointer to a cell, for the wrappers that take one as an input.

Source§

type Owned = &'a mut Cell<T>

Scratch storage that has to outlive the call, Self when nothing has to be allocated.
Source§

type Raw = *mut _SpiceCell

The value actually passed to the C routine.
Source§

fn own(self) -> Self::Owned

Move the value into its scratch storage.
Source§

fn raw(owned: &mut Self::Owned) -> Self::Raw

Borrow the scratch storage as the C representation.

Auto Trait Implementations§

§

impl<T> !Sync for Cell<T>

§

impl<T> Freeze for Cell<T>
where Vec<<T as CellItem>::Raw>: Freeze, PhantomData<fn() -> T>: Freeze,

§

impl<T> RefUnwindSafe for Cell<T>

§

impl<T> Unpin for Cell<T>
where Vec<<T as CellItem>::Raw>: Unpin, PhantomData<fn() -> T>: Unpin,

§

impl<T> UnsafeUnpin for Cell<T>
where Vec<<T as CellItem>::Raw>: UnsafeUnpin, PhantomData<fn() -> T>: UnsafeUnpin,

§

impl<T> UnwindSafe for Cell<T>
where Vec<<T as CellItem>::Raw>: UnwindSafe, PhantomData<fn() -> T>: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.