Struct scilla_parser::contract::Contract
source · pub struct Contract {
pub name: String,
pub init_params: FieldList,
pub fields: FieldList,
pub transitions: TransitionList,
}Fields§
§name: StringName of the parsed contract
init_params: FieldListList of parameters needed to deploy the contract.
fields: FieldListList of the contract’s fields.
transitions: TransitionListList of the contract’s transitions.
Implementations§
source§impl Contract
impl Contract
sourcepub fn from_path(contract_path: &Path) -> Result<Self, Error>
pub fn from_path(contract_path: &Path) -> Result<Self, Error>
Parse a contract from a given path.
Examples
use std::{error::Error, path::PathBuf};
use scilla_parser::{Contract, Field, FieldList, Transition, TransitionList, Type};
let contract_path = PathBuf::from("tests/contracts/chainid.scilla");
let contract = Contract::from_path(&contract_path).unwrap();
assert_eq!(
contract,
Contract {
name: "ChainId".to_string(),
fields: FieldList::default(),
init_params: FieldList::default(),
transitions: TransitionList(vec![Transition::new(
"EventChainID",
FieldList::default()
)])
}
);Trait Implementations§
source§impl FromStr for Contract
impl FromStr for Contract
source§fn from_str(sexp: &str) -> Result<Self, Self::Err>
fn from_str(sexp: &str) -> Result<Self, Self::Err>
Parse a Contract from a string slice
Example
use std::{error::Error, path::PathBuf};
use scilla_parser::{run_scilla_fmt, Contract, Field, FieldList, Transition, TransitionList, Type};
let contract = run_scilla_fmt(&PathBuf::from("tests/contracts/chainid.scilla")).unwrap();
let contract = contract.parse::<Contract>().unwrap();
assert_eq!(
contract,
Contract {
name: "ChainId".to_string(),
fields: FieldList::default(),
init_params: FieldList::default(),
transitions: TransitionList(vec![Transition::new(
"EventChainID",
FieldList::default()
)])
}
);source§impl PartialEq for Contract
impl PartialEq for Contract
impl StructuralPartialEq for Contract
Auto Trait Implementations§
impl RefUnwindSafe for Contract
impl Send for Contract
impl Sync for Contract
impl Unpin for Contract
impl UnwindSafe for Contract
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
Mutably borrows from an owned value. Read more