pub struct StreamId {
pub stream_type: StreamType,
pub cid: Cid,
}
Expand description
Stream identifier, no commit information included.
Contains stream type and CID of genesis commit.
Encoded as <multibase-prefix><multicodec-streamid><type><genesis-cid-bytes>
.
String representation is base36-encoding of the bytes above.
let cid = cid::Cid::from_str("bagcqcerakszw2vsovxznyp5gfnpdj4cqm2xiv76yd24wkjewhhykovorwo6a").unwrap();
let _stream_id = StreamId { stream_type: StreamType::Tile, cid };
Fields§
§stream_type: StreamType
§cid: Cid
Implementations§
source§impl StreamId
impl StreamId
sourcepub fn from_genesis(stream_type: StreamType, genesis: &Ipld) -> Result<Self>
pub fn from_genesis(stream_type: StreamType, genesis: &Ipld) -> Result<Self>
Create a StreamId
from a genesis commit.
let genesis = Ipld::Map(
[(
"header".into(),
Ipld::Map(
[
(
"controllers".into(),
Ipld::List(vec!["did:3:kjz...".into()]),
),
("family".into(), "IDX".into()),
]
.into_iter()
.collect(),
),
)]
.into_iter()
.collect(),
);
let _stream_id = StreamId::from_genesis(StreamType::Tile, &genesis);
pub fn from_slice<I: AsRef<[u8]>>(value: I) -> Result<Self>
Trait Implementations§
source§impl PartialEq<StreamId> for StreamId
impl PartialEq<StreamId> for StreamId
source§impl StreamRefExt for StreamId
impl StreamRefExt for StreamId
source§fn stream_type(&self) -> StreamType
fn stream_type(&self) -> StreamType
Get the
StreamType
.source§fn to_base_id(&self) -> StreamId
fn to_base_id(&self) -> StreamId
Get the
StreamId
without the commit.source§fn to_base36_string(&self) -> String
fn to_base36_string(&self) -> String
Encode the
StreamRef
into a string.