1use std::rc::Rc;
4
5#[derive(Clone, Copy, PartialEq, Eq, Debug)]
6pub(crate) enum BlobKind {
7 Input,
8 Output,
9}
10#[derive(Clone, Debug)]
13pub struct BlobId {
14 graph: Rc<()>,
15 index: i32,
16 kind: BlobKind,
17}
18impl BlobId {
19 pub(crate) fn new(graph: Rc<()>, index: i32, kind: BlobKind) -> Self {
20 Self { graph, index, kind }
21 }
22 pub(crate) fn kind(&self) -> BlobKind {
23 self.kind
24 }
25 pub(crate) fn belongs_to(&self, graph: &Rc<()>) -> bool {
26 Rc::ptr_eq(graph, &self.graph)
27 }
28 pub fn index(&self) -> i32 {
31 self.index
32 }
33}
34
35#[derive(Clone, Copy)]
37#[non_exhaustive]
38pub enum Endpoint<'a> {
39 Name(&'a str),
41 Index(i32),
43 Blob(&'a BlobId),
45}
46
47impl<'a> From<&'a str> for Endpoint<'a> {
48 fn from(name: &'a str) -> Self {
49 Self::Name(name)
50 }
51}
52
53impl From<i32> for Endpoint<'_> {
54 fn from(index: i32) -> Self {
55 Self::Index(index)
56 }
57}
58
59impl<'a> From<&'a String> for Endpoint<'a> {
60 fn from(name: &'a String) -> Self {
61 Self::Name(name)
62 }
63}
64
65impl<'a> From<&'a BlobId> for Endpoint<'a> {
66 fn from(blob: &'a BlobId) -> Self {
67 Self::Blob(blob)
68 }
69}