-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AnnotatedValue impl split into several files
- Loading branch information
1 parent
0b229c2
commit dc9c49b
Showing
4 changed files
with
218 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
framework/base/src/types/interaction/annotated/annotated_impl_big_uint.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
use crate::{ | ||
proxy_imports::ManagedRef, | ||
types::{heap::Address, BigUint, ManagedAddress, ManagedBuffer}, | ||
}; | ||
|
||
use super::{AnnotatedValue, TxEnv}; | ||
|
||
impl<Env> AnnotatedValue<Env, BigUint<Env::Api>> for BigUint<Env::Api> | ||
where | ||
Env: TxEnv, | ||
{ | ||
fn annotation(&self, _env: &Env) -> ManagedBuffer<Env::Api> { | ||
self.to_display() | ||
} | ||
|
||
fn to_value(&self, _env: &Env) -> BigUint<Env::Api> { | ||
self.clone() | ||
} | ||
|
||
fn into_value(self, _env: &Env) -> BigUint<Env::Api> { | ||
self | ||
} | ||
|
||
fn with_value_ref<F, R>(&self, env: &Env, f: F) -> R | ||
where | ||
F: FnOnce(&BigUint<Env::Api>) -> R, | ||
{ | ||
f(self) | ||
} | ||
} | ||
|
||
impl<Env> AnnotatedValue<Env, BigUint<Env::Api>> for &BigUint<Env::Api> | ||
where | ||
Env: TxEnv, | ||
{ | ||
fn annotation(&self, _env: &Env) -> ManagedBuffer<Env::Api> { | ||
self.to_display() | ||
} | ||
|
||
fn to_value(&self, _env: &Env) -> BigUint<Env::Api> { | ||
(*self).clone() | ||
} | ||
|
||
fn into_value(self, _env: &Env) -> BigUint<Env::Api> { | ||
self.clone() | ||
} | ||
|
||
fn with_value_ref<F, R>(&self, env: &Env, f: F) -> R | ||
where | ||
F: FnOnce(&BigUint<Env::Api>) -> R, | ||
{ | ||
f(self) | ||
} | ||
} | ||
|
||
impl<'a, Env> AnnotatedValue<Env, BigUint<Env::Api>> for ManagedRef<'a, Env::Api, BigUint<Env::Api>> | ||
where | ||
Env: TxEnv, | ||
{ | ||
fn annotation(&self, _env: &Env) -> ManagedBuffer<Env::Api> { | ||
self.to_display() | ||
} | ||
|
||
fn to_value(&self, _env: &Env) -> BigUint<Env::Api> { | ||
(*self).clone_value() | ||
} | ||
|
||
fn into_value(self, _env: &Env) -> BigUint<Env::Api> { | ||
self.clone_value() | ||
} | ||
|
||
fn with_value_ref<F, R>(&self, env: &Env, f: F) -> R | ||
where | ||
F: FnOnce(&BigUint<Env::Api>) -> R, | ||
{ | ||
f(self) | ||
} | ||
} | ||
|
||
impl<Env> AnnotatedValue<Env, BigUint<Env::Api>> for u64 | ||
where | ||
Env: TxEnv, | ||
{ | ||
fn annotation(&self, env: &Env) -> ManagedBuffer<Env::Api> { | ||
self.to_value(env).to_display() | ||
} | ||
|
||
fn to_value(&self, _env: &Env) -> BigUint<Env::Api> { | ||
BigUint::from(*self) | ||
} | ||
} | ||
|
||
impl<Env> AnnotatedValue<Env, BigUint<Env::Api>> for () | ||
where | ||
Env: TxEnv, | ||
{ | ||
fn annotation(&self, env: &Env) -> ManagedBuffer<Env::Api> { | ||
ManagedBuffer::from("0") | ||
} | ||
|
||
fn to_value(&self, _env: &Env) -> BigUint<Env::Api> { | ||
BigUint::zero() | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
framework/base/src/types/interaction/annotated/annotated_impl_managed_address.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
use crate::{ | ||
proxy_imports::ManagedRef, | ||
types::{heap::Address, BigUint, ManagedAddress, ManagedBuffer}, | ||
}; | ||
|
||
use super::{AnnotatedValue, TxEnv}; | ||
|
||
impl<Env> AnnotatedValue<Env, ManagedAddress<Env::Api>> for ManagedAddress<Env::Api> | ||
where | ||
Env: TxEnv, | ||
{ | ||
fn annotation(&self, _env: &Env) -> ManagedBuffer<Env::Api> { | ||
self.hex_expr() | ||
} | ||
|
||
fn to_value(&self, env: &Env) -> ManagedAddress<Env::Api> { | ||
self.clone() | ||
} | ||
|
||
fn into_value(self, _env: &Env) -> ManagedAddress<Env::Api> { | ||
self | ||
} | ||
|
||
fn with_value_ref<F, R>(&self, env: &Env, f: F) -> R | ||
where | ||
F: FnOnce(&ManagedAddress<Env::Api>) -> R, | ||
{ | ||
f(self) | ||
} | ||
} | ||
|
||
impl<Env> AnnotatedValue<Env, ManagedAddress<Env::Api>> for &ManagedAddress<Env::Api> | ||
where | ||
Env: TxEnv, | ||
{ | ||
fn annotation(&self, _env: &Env) -> ManagedBuffer<Env::Api> { | ||
self.hex_expr() | ||
} | ||
|
||
fn to_value(&self, env: &Env) -> ManagedAddress<Env::Api> { | ||
(*self).clone() | ||
} | ||
|
||
fn into_value(self, _env: &Env) -> ManagedAddress<Env::Api> { | ||
self.clone() | ||
} | ||
|
||
fn with_value_ref<F, R>(&self, env: &Env, f: F) -> R | ||
where | ||
F: FnOnce(&ManagedAddress<Env::Api>) -> R, | ||
{ | ||
f(self) | ||
} | ||
} | ||
|
||
impl<Env> AnnotatedValue<Env, ManagedAddress<Env::Api>> for Address | ||
where | ||
Env: TxEnv, | ||
{ | ||
fn annotation(&self, _env: &Env) -> ManagedBuffer<Env::Api> { | ||
ManagedAddress::from(self).hex_expr() | ||
} | ||
|
||
fn to_value(&self, env: &Env) -> ManagedAddress<Env::Api> { | ||
ManagedAddress::from(self) | ||
} | ||
} | ||
|
||
impl<Env> AnnotatedValue<Env, ManagedAddress<Env::Api>> for &Address | ||
where | ||
Env: TxEnv, | ||
{ | ||
fn annotation(&self, _env: &Env) -> ManagedBuffer<Env::Api> { | ||
ManagedAddress::from(*self).hex_expr() | ||
} | ||
|
||
fn to_value(&self, env: &Env) -> ManagedAddress<Env::Api> { | ||
ManagedAddress::from(*self) | ||
} | ||
} |
Oops, something went wrong.