def layer_uri(self, layer_name):
        """Get layer URI.

        For a vector layer :
        /path/to/the/geopackage.gpkg|layername=my_vector_layer

        For a raster :
        GPKG:/path/to/the/geopackage.gpkg:my_raster_layer

        :param layer_name: The name of the layer to fetch.
        :type layer_name: str

        :return: The URI to the layer.
        :rtype: str

        .. versionadded:: 4.0
        """
        for layer in self._vector_layers():
            if layer == layer_name:
                uri = '{}|layername={}'.format(
                    self.uri.absoluteFilePath(), layer_name)
                return uri
        else:
            for layer in self._raster_layers():
                if layer == layer_name:
                    uri = 'GPKG:{}:{}'.format(
                        self.uri.absoluteFilePath(), layer_name)
                    return uri
            else:
                return None