pub fn register_texture<P: AsRef<Path>>(
        &self,
        texture: Texture,
        path: P,
    ) -> Result<(), TextureRegistrationError> {
        let mut state = self.state();
        if state.find_texture(path.as_ref()).is_some() {
            Err(TextureRegistrationError::AlreadyRegistered)
        } else {
            let mut texture_state = texture.state();
            match &mut *texture_state {
                TextureState::Ok(texture_data) => {
                    texture_data.set_path(path);
                    if let Err(e) = texture_data.save() {
                        Err(TextureRegistrationError::Texture(e))
                    } else {
                        std::mem::drop(texture_state);
                        state.textures.push(TimedEntry {
                            value: texture,
                            time_to_live: DEFAULT_RESOURCE_LIFETIME,
                        });
                        Ok(())
                    }
                }
                _ => Err(TextureRegistrationError::InvalidState),
            }
        }
    }
/// Saves given texture in the specified path and registers it in resource manager, so
/// it will be accessible through it later.
Saves given texture in the specified path and registers it in resource manager, so
it will be accessible through it later.
Saves given texture in the specified path and registers it in resource manager so it will be accessible through it later .
pub fn register_texture<P: AsRef<Path>>(
        &self,
        texture: Texture,
        path: P,
    ) -> Result<(), TextureRegistrationError> {
        let mut state = self.state();
        if state.find_texture(path.as_ref()).is_some() {
            Err(TextureRegistrationError::AlreadyRegistered)
        } else {
            let mut texture_state = texture.state();
            match &mut *texture_state {
                TextureState::Ok(texture_data) => {
                    texture_data.set_path(path);
                    if let Err(e) = texture_data.save() {
                        Err(TextureRegistrationError::Texture(e))
                    } else {
                        std::mem::drop(texture_state);
                        state.textures.push(TimedEntry {
                            value: texture,
                            time_to_live: DEFAULT_RESOURCE_LIFETIME,
                        });
                        Ok(())
                    }
                }
                _ => Err(TextureRegistrationError::InvalidState),
            }
        }
    }
pub fn register_texture < P : AsRef < Path > > ( & self , texture : Texture , path : P , ) -> Result < ( ) , TextureRegistrationError > { let mut state = self . state ( ) ; if state . find_texture ( path . as_ref ( ) ) . is_some ( ) { Err ( TextureRegistrationError :: AlreadyRegistered ) } else { let mut texture_state = texture . state ( ) ; match & mut * texture_state { TextureState :: Ok ( texture_data ) => { texture_data . set_path ( path ) ; if let Err ( e ) = texture_data . save ( ) { Err ( TextureRegistrationError :: Texture ( e ) ) } else { std :: mem :: drop ( texture_state ) ; state . textures . push ( TimedEntry { value : texture , time_to_live : DEFAULT_RESOURCE_LIFETIME , } ) ; Ok ( ( ) ) } } _ => Err ( TextureRegistrationError :: InvalidState ) , } } }
Saves given texture in the specified path and registers it in resource manager, so
it will be accessible through it later.
Saves given texture in the specified path and registers it in resource manager so it will be accessible through it later .
&self
texture
Texture
path
P