Skip to main content

Crate opencellid

Crate opencellid 

Source
Expand description

Rust client for the OpenCellID public API.

§Features

  • async (default): asynchronous Client backed by reqwest::Client. Brings in tokio as a dependency.
  • blocking: synchronous BlockingClient backed by reqwest::blocking::Client.
  • csv (default): enables cell/getInArea (CSV-formatted bulk listing).
  • rustls-tls (default) / native-tls: select the TLS backend. If both are enabled, reqwest’s default applies — prefer choosing exactly one explicitly.

Both clients can be enabled simultaneously and share a single ClientBuilder.

§Logging

Every public call is wrapped in a tracing span. The API key is redacted from any URL emitted at debug level, and response bodies are length-bounded and escaped before being included in error messages or trace events. Enable e.g. tracing_subscriber::fmt().init() in application code to see the events.

§Quick start (async)

use opencellid::{CellKey, ClientBuilder, Radio};

let key = std::env::var("OPENCELLID_API_KEY")
    .map_err(|_| opencellid::Error::MissingConfig("OPENCELLID_API_KEY"))?;
let client = ClientBuilder::new().api_key(key).build()?;

let cell = client
    .get_cell(CellKey::new(250, 99, 7800, 200).with_radio(Radio::Lte))
    .await?;
println!("{:?}", (cell.lat, cell.lon));

Re-exports§

pub use error::ApiErrorCode;
pub use error::Error;
pub use error::ParseError;
pub use error::Result;
pub use error::TransportError;
pub use error::UrlError;
pub use params::AreaQuery;
pub use params::GetCellsInAreaParams;
pub use types::Bbox;
pub use types::Cell;
pub use types::CellCount;
pub use types::CellKey;
pub use types::DumpKind;
pub use types::DumpListing;
pub use types::Measurement;
pub use types::MeasurementsPayload;
pub use types::Radio;
pub use types::DumpRow;csv

Modules§

error
Error types for the OpenCellID client.
params
Strongly-typed query parameters for endpoints.
types
Domain types: cells, bounding boxes, radio technologies, measurements.

Structs§

BlockingClientblocking
Synchronous OpenCellID client.
Clientasync
Asynchronous OpenCellID client.
ClientBuilder
Builder for the OpenCellID clients.

Functions§

parse_dump_csvcsv
Iterator over rows of a downloaded (already-decompressed) dump CSV.