cursor.rs
1 use std::fmt::{self, Display}; 2 3 use apibara_core::node::v1alpha2::Cursor; 4 5 /// A newtype to display a cursor that may be `None` as "genesis". 6 pub struct DisplayCursor<'a>(pub &'a Option<Cursor>); 7 8 impl<'a> Display for DisplayCursor<'a> { 9 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 10 match self.0 { 11 Some(cursor) => write!(f, "{}", cursor), 12 None => write!(f, "Cursor(genesis)"), 13 } 14 } 15 }