pub(crate) fn get_widget_state_no_fetch<S>(
        &self,
        url: &PathMaybeWithLocale,
        server_state: TemplateState,
    ) -> Result<Option<S::Rx>, ClientError>
    where
        S: MakeRx + Serialize + DeserializeOwned + 'static,
        S::Rx: MakeUnrx<Unrx = S> + AnyFreeze + Clone,
    {
        if let Some(held_state) = self.get_held_state::<S>(url, true)? {
            Ok(Some(held_state))
        } else if cfg!(client) {
            // On the browser-side, the given server state is empty, and we need to check
            // the preload
            match self.state_store.contains(url) {
                // This implies either user preloading, or initial load automatic preloading
                // from `__PERSEUS_INITIAL_WIDGET_STATES`
                PssContains::Preloaded => {
                    let page_data = self.state_store.get_preloaded(url).unwrap();
                    // Register an empty head
                    self.state_store.add_head(url, String::new(), true);
                    // And reactivize the state for registration
                    let typed_state = TemplateState::from_value(page_data.state)
                        .change_type::<Result<S, ServerErrorData>>();
                    // This attempts a deserialization from a `Value`, which could fail
                    let unrx_res = typed_state
                        .into_concrete()
                        .map_err(|err| ClientInvariantError::InvalidState { source: err })?;
                    match unrx_res {
                        Ok(unrx) => {
                            let rx = unrx.make_rx();
                            // Add that to the state store as the new active state
                            self.state_store.add_state(url, rx.clone(), false)?;

                            Ok(Some(rx))
                        }
                        // This would occur if there were an error in the widget that were
                        // transmitted to us
                        Err(ServerErrorData { status, msg }) => Err(ClientError::ServerError {
                            status,
                            message: msg,
                        }),
                    }
                }
                // We need to fetch the state from the server, which will require
                // asynchronicity, so bail out of this function, which is
                // not equipped for that
                PssContains::None => Ok(None),
                // Widgets have no heads, and must always be registered with a state
                PssContains::Head | PssContains::HeadNoState => {
                    Err(ClientInvariantError::InvalidWidgetPssEntry.into())
                }
                // These would have been caught by `get_held_state()` above
                PssContains::All | PssContains::State => unreachable!(),
            }
        }
        // On the engine-side, the given server state is correct, and `get_held_state()`
        // will definitionally return `Ok(None)`
        else if server_state.is_empty() {
            // This would be quite concerning...
            Err(ClientInvariantError::NoState.into())
        } else {
            // Fall back to the state we were given, first
            // giving it a type (this just sets a phantom type parameter)
            let typed_state = server_state.change_type::<S>();
            // This attempts a deserialization from a `Value`, which could fail
            let unrx = typed_state
                .into_concrete()
                .map_err(|err| ClientInvariantError::InvalidState { source: err })?;
            let rx = unrx.make_rx();
            // Add that to the state store as the new active state
            self.state_store.add_state(url, rx.clone(), false)?;

            Ok(Some(rx))
        }
    }
Gets the state for the given widget. This will return `Ok(None)`, if the
state needs to be fetched from the server.

This will check against the active and frozen states, but it will
extract state from the preload system on an initial load (as this is
how widget states are loaded in). Note that this also acts as a
general interface with the preload system for widgets, the role
of which is fulfilled for pages by the subsequent load system.

On the engine-side, this will use the given template state (which will
be passed through, unlike on the browser-side, where it will always
be empty).
packages/perseus/src/reactor/widget_state.rs