2022-06-10 08:29:56 +03:00
|
|
|
/*
|
2024-06-26 12:34:36 +03:00
|
|
|
* AquaVM Workflow Engine
|
2022-06-10 08:29:56 +03:00
|
|
|
*
|
2024-06-26 12:34:36 +03:00
|
|
|
* Copyright (C) 2024 Fluence DAO
|
2022-06-10 08:29:56 +03:00
|
|
|
*
|
2024-06-26 12:34:36 +03:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation version 3 of the
|
|
|
|
* License.
|
2022-06-10 08:29:56 +03:00
|
|
|
*
|
2024-06-26 12:34:36 +03:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2022-06-10 08:29:56 +03:00
|
|
|
*/
|
|
|
|
|
2023-04-05 11:50:15 +03:00
|
|
|
use air_utils::auto_checked_add;
|
2022-06-10 08:29:56 +03:00
|
|
|
|
2023-04-05 11:50:15 +03:00
|
|
|
use newtype_derive::*;
|
2022-06-10 08:29:56 +03:00
|
|
|
|
2023-04-05 11:50:15 +03:00
|
|
|
use serde::Deserialize;
|
|
|
|
use serde::Serialize;
|
2022-06-10 08:29:56 +03:00
|
|
|
|
2023-04-05 11:50:15 +03:00
|
|
|
pub type PosType = u32;
|
2022-06-10 08:29:56 +03:00
|
|
|
|
2023-04-05 11:50:15 +03:00
|
|
|
#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
|
|
|
|
#[serde(transparent)]
|
|
|
|
#[repr(transparent)]
|
2024-01-09 21:22:11 +04:00
|
|
|
#[derive(::rkyv::Archive, ::rkyv::Serialize, ::rkyv::Deserialize)]
|
|
|
|
#[archive(check_bytes)]
|
2023-04-05 11:50:15 +03:00
|
|
|
pub struct TracePos(PosType);
|
|
|
|
|
|
|
|
NewtypeFrom! { () pub struct TracePos(PosType); }
|
|
|
|
NewtypeAdd! { (PosType) pub struct TracePos(PosType); }
|
|
|
|
NewtypeAdd! { () pub struct TracePos(PosType); }
|
|
|
|
NewtypeAddAssign! { () pub struct TracePos(PosType); }
|
|
|
|
NewtypeAddAssign! { (PosType) pub struct TracePos(PosType); }
|
|
|
|
NewtypeSub! { () pub struct TracePos(PosType); }
|
|
|
|
NewtypeSub! { (PosType) pub struct TracePos(PosType); }
|
|
|
|
NewtypeDebug! { () pub struct TracePos(PosType); }
|
|
|
|
NewtypeDisplay! { () pub struct TracePos(PosType); }
|
|
|
|
auto_checked_add![TracePos];
|
2022-06-10 08:29:56 +03:00
|
|
|
|
|
|
|
impl From<TracePos> for usize {
|
2023-04-05 11:50:15 +03:00
|
|
|
fn from(value: TracePos) -> Self {
|
|
|
|
value.0 as Self
|
2022-06-10 08:29:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-05 11:50:15 +03:00
|
|
|
impl TryFrom<usize> for TracePos {
|
|
|
|
type Error = <PosType as TryFrom<usize>>::Error;
|
2022-06-10 08:29:56 +03:00
|
|
|
|
2023-04-05 11:50:15 +03:00
|
|
|
fn try_from(value: usize) -> Result<Self, Self::Error> {
|
|
|
|
PosType::try_from(value).map(TracePos)
|
2022-06-10 08:29:56 +03:00
|
|
|
}
|
|
|
|
}
|