pub struct Alignment<'a> { /* private fields */ }
Implementations§
Source§impl<'a> Alignment<'a>
impl<'a> Alignment<'a>
pub fn from_raw(alignment: *mut PedAlignment) -> Alignment<'a>
Sourcepub fn new(offset: i64, grain_size: i64) -> Result<Alignment<'a>>
pub fn new(offset: i64, grain_size: i64) -> Result<Alignment<'a>>
Return an alignment object representing all sectors that are of the form
offset + X * grain_size
.
Sourcepub fn init(&mut self, offset: i64, grain_size: i64) -> Result<()>
pub fn init(&mut self, offset: i64, grain_size: i64) -> Result<()>
Initializes a preallocated piece of memory for an alignment object.
The object will represent all sectors for which the equation
S = offset + x * grain_size
holds.
Sourcepub fn align_down(&self, geom: &Geometry<'_>, sector: i64) -> Option<u64>
pub fn align_down(&self, geom: &Geometry<'_>, sector: i64) -> Option<u64>
Returns the sector that is closest to sector
, satifies the align
constraint, and lies
lies inside geom
.
Sourcepub fn align_nearest(&self, geom: &Geometry<'_>, sector: i64) -> Option<u64>
pub fn align_nearest(&self, geom: &Geometry<'_>, sector: i64) -> Option<u64>
Returns the sector that is closest to sector
, satisfies the align
constraint, and
lies inside of geom
.
Sourcepub fn align_up(&self, geom: &Geometry<'_>, sector: i64) -> Option<u64>
pub fn align_up(&self, geom: &Geometry<'_>, sector: i64) -> Option<u64>
Returns the sector that is closest to sector
, satifies the align
constraint, and lies
lies inside geom
.
Sourcepub fn duplicate<'b>(&self) -> Result<Alignment<'b>>
pub fn duplicate<'b>(&self) -> Result<Alignment<'b>>
Clones and returns a duplicate of the alignment, if possible.
pub fn grain_size(&self) -> i64
Sourcepub fn intersect(&self, other: &Alignment<'_>) -> Option<Alignment<'a>>
pub fn intersect(&self, other: &Alignment<'_>) -> Option<Alignment<'a>>
Returns a new Alignment object if an intersection can between
itself and a given other
Alignment.
Sourcepub fn is_aligned(&self, geom: &Geometry<'_>, sector: i64) -> bool
pub fn is_aligned(&self, geom: &Geometry<'_>, sector: i64) -> bool
Returns the sector that is closest to sector
, satifies the align
constraint, and lies
lies inside geom
.