capnp-0.8.0.0: Cap'n Proto for Haskell
Safe HaskellNone
LanguageHaskell2010

Capnp.Address

Description

This module provides facilities for manipulating raw addresses within Cap'N Proto messages.

This is a low level module that very few users will need to use directly.

Synopsis

Documentation

data WordAddr Source #

The address of a word within a message

Constructors

WordAt 

Fields

Instances

Instances details
Eq WordAddr Source # 
Instance details

Defined in Capnp.Address

Show WordAddr Source # 
Instance details

Defined in Capnp.Address

newtype CapAddr Source #

The "address" of a capability

Constructors

Cap Word32 

Instances

Instances details
Eq CapAddr Source # 
Instance details

Defined in Capnp.Address

Methods

(==) :: CapAddr -> CapAddr -> Bool #

(/=) :: CapAddr -> CapAddr -> Bool #

Show CapAddr Source # 
Instance details

Defined in Capnp.Address

data Addr Source #

An address, i.e. a location that a pointer may point at.

Constructors

WordAddr !WordAddr

The address of some data in the message.

CapAddr !CapAddr

The "address" of a capability.

Instances

Instances details
Eq Addr Source # 
Instance details

Defined in Capnp.Address

Methods

(==) :: Addr -> Addr -> Bool #

(/=) :: Addr -> Addr -> Bool #

Show Addr Source # 
Instance details

Defined in Capnp.Address

Methods

showsPrec :: Int -> Addr -> ShowS #

show :: Addr -> String #

showList :: [Addr] -> ShowS #

data OffsetError Source #

An error returned by computeOffset; this describes the reason why a value cannot be directly addressed from a given location.

Constructors

DifferentSegments

The pointer and the value are in different segments.

OutOfRange

The pointer is in the correct segment, but too far away to encode the offset. (more than 30 bits would be required). This can only happen with segments that are > 8 GiB, which this library refuses to either decode or generate, so this should not come up in practice.

computeOffset :: WordAddr -> WordAddr -> Either OffsetError WordCount Source #

computeOffset ptrAddr valueAddr computes the offset that should be stored in a struct or list pointer located at ptrAddr, in order to point at a value located at valueAddr. If the value cannot be directly addressed by a pointer at ptrAddr, then this returns Left, with the OffsetError describing the problem.

pointerFrom :: WordAddr -> WordAddr -> Ptr -> Either OffsetError Ptr Source #

pointerFrom ptrAddr targetAddr ptr updates ptr, such that it is correct to target a value located at targetAddr given that the pointer itself is located at ptrAddr. Returns Left if this is not possible.

It is illegal to call this on a capability pointer.

For far pointers, targetAddr is taken to be the address of the landing pad, rather than the final value.