MCPcopy Create free account
hub / github.com/ceramicnetwork/rust-ceramic / build_start_stop_range

Method build_start_stop_range

api/src/server.rs:821–866  ·  view source on GitHub ↗
(
        &self,
        sep_key: &str,
        sep_value: &[u8],
        controller: Option<String>,
        stream_id: Option<String>,
    )

Source from the content-addressed store, hash-verified

819 }
820
821 fn build_start_stop_range(
822 &self,
823 sep_key: &str,
824 sep_value: &[u8],
825 controller: Option<String>,
826 stream_id: Option<String>,
827 ) -> Result<(EventId, EventId), ErrorResponse> {
828 let start_builder = EventId::builder()
829 .with_network(&self.network)
830 .with_sep(sep_key, sep_value);
831 let stop_builder = EventId::builder()
832 .with_network(&self.network)
833 .with_sep(sep_key, sep_value);
834
835 let (start_builder, stop_builder) = match (controller, stream_id) {
836 (Some(controller), Some(stream_id)) => {
837 let stream_id = StreamId::from_str(&stream_id)
838 .map_err(|err| ErrorResponse::new(format!("stream_id: {err}")))?;
839 (
840 start_builder
841 .with_controller(&controller)
842 .with_init(&stream_id.cid),
843 stop_builder
844 .with_controller(&controller)
845 .with_init(&stream_id.cid),
846 )
847 }
848 (Some(controller), None) => (
849 start_builder.with_controller(&controller).with_min_init(),
850 stop_builder.with_controller(&controller).with_max_init(),
851 ),
852 (None, Some(_)) => {
853 return Err(ErrorResponse::new(
854 "controller is required if stream_id is specified".to_owned(),
855 ))
856 }
857 (None, None) => (
858 start_builder.with_min_controller().with_min_init(),
859 stop_builder.with_max_controller().with_max_init(),
860 ),
861 };
862
863 let start = start_builder.with_min_event().build_fencepost();
864 let stop = stop_builder.with_max_event().build_fencepost();
865 Ok((start, stop))
866 }
867
868 async fn get_stream_state(
869 &self,

Callers 2

post_interestsMethod · 0.80

Calls 12

newFunction · 0.85
with_networkMethod · 0.80
with_initMethod · 0.80
with_min_initMethod · 0.80
with_max_initMethod · 0.80
with_min_controllerMethod · 0.80
with_max_controllerMethod · 0.80
with_min_eventMethod · 0.80
with_max_eventMethod · 0.80
with_sepMethod · 0.45
with_controllerMethod · 0.45
build_fencepostMethod · 0.45

Tested by

no test coverage detected