use hdi::prelude::LinkTypeFilterExt;
use holo_hash::{AgentPubKey, AnyLinkableHash};
use holochain_wasmer_guest::WasmError;
use holochain_zome_types::prelude::*;
#[derive(PartialEq, Clone, Debug)]
pub struct GetLinksInputBuilder(GetLinksInput);
impl GetLinksInputBuilder {
pub fn try_new(
base_address: impl Into<AnyLinkableHash>,
link_type: impl LinkTypeFilterExt,
) -> Result<Self, WasmError> {
Ok(GetLinksInputBuilder(GetLinksInput {
base_address: base_address.into(),
link_type: link_type.try_into_filter()?,
get_options: GetOptions::default(),
tag_prefix: None,
before: None,
after: None,
author: None,
}))
}
pub fn get_options(mut self, get_strategy: GetStrategy) -> Self {
self.0.get_options.strategy = get_strategy;
self
}
pub fn tag_prefix(mut self, tag_prefix: LinkTag) -> Self {
self.0.tag_prefix = Some(tag_prefix);
self
}
pub fn before(mut self, before: Timestamp) -> Self {
self.0.before = Some(before);
self
}
pub fn after(mut self, after: Timestamp) -> Self {
self.0.after = Some(after);
self
}
pub fn author(mut self, author: AgentPubKey) -> Self {
self.0.author = Some(author);
self
}
pub fn build(self) -> GetLinksInput {
self.0
}
}