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 addded to a computation graph with Graph::custom_op.
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
sourceimpl 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
sourceimpl Clone for CustomOperation
impl Clone for CustomOperation
sourcefn clone(&self) -> CustomOperation
fn clone(&self) -> CustomOperation
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 more
sourceimpl Debug for CustomOperation
impl Debug for CustomOperation
sourceimpl<'de> Deserialize<'de> for CustomOperation
impl<'de> Deserialize<'de> for CustomOperation
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Hash for CustomOperation
impl Hash for CustomOperation
sourceimpl PartialEq<CustomOperation> for CustomOperation
impl PartialEq<CustomOperation> for CustomOperation
sourcefn 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
sourceimpl 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Serialize for T where
T: Serialize + ?Sized,
impl<T> Serialize for T where
T: Serialize + ?Sized,
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more