1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
/*!
Improvement on the procedurally generated functions.
## Description
The idiomatic Rust bindings to CSPICE can be very hard to generate in a procedural macro in some
specific cases. You can find, in this module, functions wrapped from [`raw`] to better match
an idiomatic usage. The improvements consists in functions:
+ taking a string as input in C requires to also send the size of the pointer to a char array. In Rust, you
only send the string.
+ taking taking input for array size and outputing size whereas a vector can be used
+ which outputs string that be allocated from default length sometimes
*/
use crate::raw;
use crate::MAX_LEN_OUT;
#[cfg(any(feature = "lock", doc))]
use {crate::SpiceLock, spice_derive::impl_for};
/**
Translate the SPICE integer code of a body into a common name for that body.
See [`raw::bodc2n`] for the raw interface.
*/
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn bodc2n(code: i32) -> (String, bool) {
raw::bodc2n(code, MAX_LEN_OUT as i32)
}
/**
This routine converts an input epoch represented in TDB seconds past the TDB epoch of J2000 to a
character string formatted to the specifications of a user's format picture.
See [`raw::timout`] for the raw interface.
*/
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn timout(et: f64, pictur: &str) -> String {
raw::timout(et, pictur, pictur.len())
}
/**
Fetch triangular plates from a type 2 DSK segment.
See [`raw::dskp02`] for the raw interface.
*/
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn dskp02(handle: i32, dladsc: raw::DLADSC) -> Vec<[i32; 3]> {
let (_, np) = raw::dskz02(handle, dladsc);
raw::dskp02(handle, dladsc, 1, np).1
}
/**
Fetch vertices from a type 2 DSK segment.
See [`raw::dskv02`] for the raw interface.
*/
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn dskv02(handle: i32, dladsc: raw::DLADSC) -> Vec<[f64; 3]> {
let (nv, _) = raw::dskz02(handle, dladsc);
raw::dskv02(handle, dladsc, 1, nv).1
}
/**
Fetch vertices from a type 2 DSK segment.
See [`raw::kdata`] for the raw interface.
*/
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn kdata(which: i32, kind: &str) -> (String, String, String, i32, bool) {
raw::kdata(
which,
kind,
MAX_LEN_OUT as i32,
MAX_LEN_OUT as i32,
MAX_LEN_OUT as i32,
)
}