pub async fn extract(
        wasm_payload: Option<LegacySmartModulePayload>,
        smartmodule: Option<SmartModuleInvocation>,
        derivedstream: Option<DerivedStreamInvocation>,
        version: i16,
        ctx: &DefaultSharedGlobalContext,
    ) -> Result<Option<Self>, ErrorCode> {
        let derived_sm_modules = if let Some(ss_inv) = derivedstream {
            Some(extract_derivedstream_context(ss_inv, ctx).await?)
        } else {
            None
        };

        // if module is come from smart stream, then we can use it
        let module = if let Some(derive) = derived_sm_modules {
            Some(derive)
        } else {
            smartmodule
        };

        match module {
            Some(smartmodule_invocation) => Ok(Some(
                Self::extract_smartmodule_context(smartmodule_invocation, version, ctx).await?,
            )),
            None => {
                if let Some(payload) = wasm_payload {
                    Ok(Some(Self {
                        smartmodule_instance: Self::payload_to_smartmodule(payload, version, ctx)?,
                        right_consumer_stream: None,
                    }))
                } else {
                    Ok(None)
                }
            }
        }
    }
/// find wasm payload, they can be loaded from payload or from smart module
/// smart module has precedent over payload
find wasm payload, they can be loaded from payload or from smart module
smart module has precedent over payload
find wasm payload they can be loaded from payload or from smart module smart module has precedent over payload
pub async fn extract(
        wasm_payload: Option<LegacySmartModulePayload>,
        smartmodule: Option<SmartModuleInvocation>,
        derivedstream: Option<DerivedStreamInvocation>,
        version: i16,
        ctx: &DefaultSharedGlobalContext,
    ) -> Result<Option<Self>, ErrorCode> {
        let derived_sm_modules = if let Some(ss_inv) = derivedstream {
            Some(extract_derivedstream_context(ss_inv, ctx).await?)
        } else {
            None
        };
        // if module is come from smart stream, then we can use it
        let module = if let Some(derive) = derived_sm_modules {
            Some(derive)
        } else {
            smartmodule
        };
        match module {
            Some(smartmodule_invocation) => Ok(Some(
                Self::extract_smartmodule_context(smartmodule_invocation, version, ctx).await?,
            )),
            None => {
                if let Some(payload) = wasm_payload {
                    Ok(Some(Self {
                        smartmodule_instance: Self::payload_to_smartmodule(payload, version, ctx)?,
                        right_consumer_stream: None,
                    }))
                } else {
                    Ok(None)
                }
            }
        }
    }
pub async fn extract ( wasm_payload : Option < LegacySmartModulePayload > , smartmodule : Option < SmartModuleInvocation > , derivedstream : Option < DerivedStreamInvocation > , version : i16 , ctx : & DefaultSharedGlobalContext , ) -> Result < Option < Self > , ErrorCode > { let derived_sm_modules = if let Some ( ss_inv ) = derivedstream { Some ( extract_derivedstream_context ( ss_inv , ctx ) . await ? ) } else { None } ; // if module is come from smart stream, then we can use it let module = if let Some ( derive ) = derived_sm_modules { Some ( derive ) } else { smartmodule } ; match module { Some ( smartmodule_invocation ) => Ok ( Some ( Self :: extract_smartmodule_context ( smartmodule_invocation , version , ctx ) . await ? , ) ) , None => { if let Some ( payload ) = wasm_payload { Ok ( Some ( Self { smartmodule_instance : Self :: payload_to_smartmodule ( payload , version , ctx ) ? , right_consumer_stream : None , } ) ) } else { Ok ( None ) } } } }
find wasm payload, they can be loaded from payload or from smart module
smart module has precedent over payload
find wasm payload they can be loaded from payload or from smart module smart module has precedent over payload
wasm_payload
Option<LegacySmartModulePayload>
smartmodule
Option<SmartModuleInvocation>
derivedstream
Option<DerivedStreamInvocation>
version
i16
ctx
&DefaultSharedGlobalContext
wasm_payload
Option<LegacySmartModulePayload>
smartmodule
Option<SmartModuleInvocation>
derivedstream
Option<DerivedStreamInvocation>
version
i16
ctx
&DefaultSharedGlobalContext