Struct ciphercore_base::custom_ops::CustomOperation
source · pub struct CustomOperation { /* private fields */ }
Expand description
A structure that stores a pointer to a custom operation.
A custom operation can be thought of as a polymorphic function, i.e., where the number of inputs and their types can vary.
Any struct can be a custom operation if it implements the CustomOperationBody trait. Then any such struct can be used to create a CustomOperation object that can be added to a computation graph with Graph::custom_op.
Rust crates
Clone trait duplicates the pointer, not the underlying custom operation.
PartialEq trait compares the related custom operations, not just pointer.
Example
let c = create_context().unwrap();
let g = c.create_graph().unwrap();
let t = array_type(vec![3, 2], BIT);
let n1 = g.input(t).unwrap();
let n2 = g.custom_op(CustomOperation::new(Not {}), vec![n1]).unwrap();
Implementations§
source§impl CustomOperation
impl CustomOperation
sourcepub fn new<T: 'static + CustomOperationBody>(op: T) -> CustomOperation
pub fn new<T: 'static + CustomOperationBody>(op: T) -> CustomOperation
Creates a new custom operation that can be added to a computation graph via Graph::custom_op.
Arguments
op
- struct that implements the CustomOperationBody trait
Returns
New custom operation
Example
let c = create_context().unwrap();
let g = c.create_graph().unwrap();
let t = array_type(vec![3, 2], BIT);
let n1 = g.input(t).unwrap();
let n2 = g.custom_op(CustomOperation::new(Not {}), vec![n1]).unwrap();
sourcepub fn get_name(&self) -> String
pub fn get_name(&self) -> String
Returns the name of the underlying custom operation by calling CustomOperationBody::get_name.
Returns
Name of this custom operation
Trait Implementations§
source§impl Clone for CustomOperation
impl Clone for CustomOperation
source§fn clone(&self) -> CustomOperation
fn clone(&self) -> CustomOperation
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for CustomOperation
impl Debug for CustomOperation
source§impl<'de> Deserialize<'de> for CustomOperation
impl<'de> Deserialize<'de> for CustomOperation
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl Hash for CustomOperation
impl Hash for CustomOperation
source§impl PartialEq<CustomOperation> for CustomOperation
impl PartialEq<CustomOperation> for CustomOperation
source§fn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
Tests whether self
and other
custom operations are equal.
The underlying custom operation structs are compared via the Eq trait.
Arguments
other
- another CustomOperation
Returns
true
if the pointers in self
and other
point to equal custom operations, false
otherwise
source§impl Serialize for CustomOperation
impl Serialize for CustomOperation
impl Eq for CustomOperation
Auto Trait Implementations§
impl !RefUnwindSafe for CustomOperation
impl Send for CustomOperation
impl Sync for CustomOperation
impl Unpin for CustomOperation
impl !UnwindSafe for CustomOperation
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.