Struct CapeArrayRealScalar

Source
pub struct CapeArrayRealScalar {
    value: CapeReal,
}
Expand description

Scalar based CapeArrayRealOut implementation

ICapeArrayReal is passed as data container between CAPE-OPEN functions. It is up to the caller to provide the interface, and its implementation. This class provides a default impementation using a scalar CapeReal.

This class can be used as input and output argument. However, it should only be used as an output argument in case a scalar value is expected, such as for getting the density from a material object, as any attempt to resize the content to anything else but 1 will result in an error.

§Examples

use cobia::*;

fn set_content(a: &mut CapeArrayRealOut) {
	a.resize(1);
	a[0]=2.5;
}
 
let mut arr = cobia::CapeArrayRealScalar::new();
set_content(&mut CapeArrayRealOutFromProvider::from(&mut arr).as_cape_array_real_out());
assert_eq!(arr.value(), 2.5);

Fields§

§value: CapeReal

Implementations§

Source§

impl CapeArrayRealScalar

Source

const VTABLE: ICapeArrayReal_VTable

Interface v-table

Source

pub fn new() -> Self

Create a new CapeArrayRealScalar

Creates a new empty CapeArrayRealScalar

§Examples
use cobia;
let arr = cobia::CapeArrayRealScalar::new();
assert!(cobia::CapeReal::is_nan(arr.value()));
Source

pub fn from(value: CapeReal) -> Self

Create a new CapeArrayRealScalar with initial value

Creates a new empty CapeArrayRealScalar and sets the value

§Arguments
  • value - The initial value
§Examples
use cobia;
let arr = cobia::CapeArrayRealScalar::from(3.14);
assert_eq!(arr.value(),3.14);
Source

pub fn value(&self) -> CapeReal

Return value

Returns the value.

§Example
use cobia;
let arr = cobia::CapeArrayRealScalar::from(10.0);
assert_eq!(arr.value(),10.0);
Source

pub fn set(&mut self, value: CapeReal)

Set the value

Sets the value

§Arguments
  • value - The value to be set
§Example
use cobia;
let mut arr = cobia::CapeArrayRealScalar::from(10.0);
arr.set(11.0);
assert_eq!(arr.value(),11.0);
Source

extern "C" fn get( me: *mut c_void, data: *mut *mut CapeReal, size: *mut CapeSize, )

Interface member function

Source

extern "C" fn setsize( me: *mut c_void, size: CapeSize, data: *mut *mut CapeReal, ) -> CapeResult

Interface member function

Trait Implementations§

Source§

impl AsMut<f64> for CapeArrayRealScalar

Source§

fn as_mut(&mut self) -> &mut CapeReal

Return mutable reference to the scalar value

Returns a mutable reference to the scalar value.

§Example
use cobia;
let mut arr = cobia::CapeArrayRealScalar::from(10.0);
*arr.as_mut()=11.0;
assert_eq!(arr.value(),11.0);
Source§

impl CapeArrayRealProviderIn for CapeArrayRealScalar

Source§

fn as_cape_array_real_in(&self) -> ICapeArrayReal

Convert to ICapeArrayReal

Returns a reference to the ICapeArrayReal interface.

§Examples
use cobia::*;

fn test_content(a: &CapeArrayRealIn) {
    assert_eq!(a[0], 0.0);
}
 
let arr = cobia::CapeArrayRealScalar::from(0.0);
test_content(&CapeArrayRealInFromProvider::from(&arr).as_cape_array_real_in());
Source§

impl CapeArrayRealProviderOut for CapeArrayRealScalar

Source§

fn as_cape_array_real_out(&mut self) -> ICapeArrayReal

Convert to ICapeArrayReal

Returns a mutable reference to the ICapeArrayReal interface.

§Examples
use cobia::*;

fn set_content(a: &mut CapeArrayRealOut) {
	a.resize(1);
	a[0]=2.5;
}
 
let mut arr = cobia::CapeArrayRealScalar::new();
set_content(&mut CapeArrayRealOutFromProvider::from(&mut arr).as_cape_array_real_out());
assert_eq!(arr.value(), 2.5);
Source§

impl Clone for CapeArrayRealScalar

Source§

fn clone(&self) -> CapeArrayRealScalar

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

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> 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<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 = 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.