pub struct GoRegistry { /* private fields */ }Expand description
Client for interacting with proxy.golang.org.
Uses the Go module proxy protocol for version lookups and metadata. All requests are cached via the provided HttpCache.
Implementations§
Source§impl GoRegistry
impl GoRegistry
Sourcepub const fn new(cache: Arc<HttpCache>) -> Self
pub const fn new(cache: Arc<HttpCache>) -> Self
Creates a new Go registry client with the given HTTP cache.
Sourcepub async fn get_versions(&self, module_path: &str) -> Result<Vec<GoVersion>>
pub async fn get_versions(&self, module_path: &str) -> Result<Vec<GoVersion>>
Fetches all versions for a module from the /@v/list endpoint.
Returns versions in registry order (not sorted). Includes pseudo-versions.
§Errors
Returns an error if:
- HTTP request fails
- Response body is invalid UTF-8
- Module does not exist (404)
- Module path is invalid or too long
§Examples
let cache = Arc::new(HttpCache::new());
let registry = GoRegistry::new(cache);
let versions = registry.get_versions("github.com/gin-gonic/gin").await.unwrap();
assert!(!versions.is_empty());Sourcepub async fn get_version_info(
&self,
module_path: &str,
version: &str,
) -> Result<GoVersion>
pub async fn get_version_info( &self, module_path: &str, version: &str, ) -> Result<GoVersion>
Fetches version metadata from the /@v/{version}.info endpoint.
Returns version with timestamp information.
§Errors
Returns an error if:
- HTTP request fails
- JSON parsing fails
- Module path or version string is invalid
§Examples
let cache = Arc::new(HttpCache::new());
let registry = GoRegistry::new(cache);
let info = registry.get_version_info("github.com/gin-gonic/gin", "v1.9.1").await.unwrap();
assert_eq!(info.version, "v1.9.1");Sourcepub async fn get_latest(&self, module_path: &str) -> Result<GoVersion>
pub async fn get_latest(&self, module_path: &str) -> Result<GoVersion>
Fetches latest version using the /@latest endpoint.
Returns the latest stable version (non-pseudo).
§Errors
Returns an error if:
- HTTP request fails
- JSON parsing fails
- Module path is invalid
§Examples
let cache = Arc::new(HttpCache::new());
let registry = GoRegistry::new(cache);
let latest = registry.get_latest("github.com/gin-gonic/gin").await.unwrap();
assert!(!latest.is_pseudo);Sourcepub async fn get_go_mod(
&self,
module_path: &str,
version: &str,
) -> Result<String>
pub async fn get_go_mod( &self, module_path: &str, version: &str, ) -> Result<String>
Fetches the go.mod file for a specific version.
Returns the raw content of the go.mod file.
§Errors
Returns an error if:
- HTTP request fails
- Response body is invalid UTF-8
- Module path or version string is invalid
§Examples
let cache = Arc::new(HttpCache::new());
let registry = GoRegistry::new(cache);
let go_mod = registry.get_go_mod("github.com/gin-gonic/gin", "v1.9.1").await.unwrap();
assert!(go_mod.contains("module github.com/gin-gonic/gin"));Trait Implementations§
Source§impl Clone for GoRegistry
impl Clone for GoRegistry
Source§fn clone(&self) -> GoRegistry
fn clone(&self) -> GoRegistry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Registry for GoRegistry
impl Registry for GoRegistry
Source§fn get_versions<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Box<dyn Version>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_versions<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Box<dyn Version>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Fetches all available versions for a package. Read more
Source§fn get_latest_matching<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
_req: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Box<dyn Version>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_latest_matching<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
_req: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Box<dyn Version>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Finds the latest version matching a version requirement. Read more
Source§fn search<'life0, 'life1, 'async_trait>(
&'life0 self,
_query: &'life1 str,
_limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Box<dyn Metadata>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn search<'life0, 'life1, 'async_trait>(
&'life0 self,
_query: &'life1 str,
_limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Box<dyn Metadata>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Searches for packages by name or keywords. Read more
Source§fn package_url(&self, name: &str) -> String
fn package_url(&self, name: &str) -> String
Package URL for ecosystem (e.g., https://crates.io/crates/serde) Read more
Auto Trait Implementations§
impl Freeze for GoRegistry
impl !RefUnwindSafe for GoRegistry
impl Send for GoRegistry
impl Sync for GoRegistry
impl Unpin for GoRegistry
impl !UnwindSafe for GoRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more